B4R Question How to setup Wemos D1 R2 as server?

rbghongade

Active Member
Licensed User
Longtime User
Dear Erel and friends,
I received my Wemos D1 R2 yesterday. Tried example in " getting started" worked great. Now I want to setup a server on Wemos board and acquire analog input from A0 pin, then send it to a client on Android (B4A). Tried using topic info at https://www.b4x.com/android/forum/threads/esp8266-connect-as-server-to-b4a-solved.69547/ but am getting nowhere.
It would be great if you guys create a step by step tutorial for the same.
regards,
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
upload_2016-8-3_16-1-27.png


A complete example is attached.
 

Attachments

  • B4R_Server.zip
    981 bytes · Views: 933
  • B4A_Client.zip
    8.2 KB · Views: 879
Upvote 0

rbghongade

Active Member
Licensed User
Longtime User
Dear Erel,
Thanks for the solution. Can I do the same with B4J instead of B4A? Please point me to the correct library for B4J.
warm regards,
 
Upvote 0

rbghongade

Active Member
Licensed User
Longtime User
Dear Erel,
I could do it quickly! Thanks. Works great, but I did not use watchdog timer. Can you please elaborate as to why it is used? I an a total newbie with ip related concept!
thanks once again.
 
Upvote 0

Bert Oudshoorn

Member
Licensed User
Erel answered with a TCP example(?) Here a very simple UDP one, derived from b4x information.
Erel deserves a Nobel price, Anywhere Software transformed in Universal Software :) u4x.co...

Sub Process_Globals
Private wifi As ESP8266WiFi
Private udp As WiFiUDP
End Sub

Private Sub AppStart
wifi.Connect2("Hawaii","where???”)
udp.Initialize(6000, "Udp_PacketArrived")
End Sub

Sub Udp_PacketArrived (Data() AsByte, Ip() AsByte, Port AsUInt)
udp.BeginPacket(Ip,Port)
udp.Write(Data) '//echo, or more writes and/or udp.Write("abcd".GetBytes)
udp.SendPacket
End Sub
 
Upvote 0
Top