So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By The_Novice
#75629 Hi, I am a newbie to WeMoS and esp8266. So, I created a PHP page that will read data sent from my wemos and store it in a database. I wrote the corresponding wemos (Arduino) code that will post data to the IP address of my raspberrypi . This is working fine.
Now I want to send data from raspberrypi to wemos. What I have is a text box. If the user enters 1, a light bulb switches on and if he enters 0 it switches off. I created the HTML and javascript codes for this and stored it in my Raspberry Pi. Now how would and in what format should I send this data to my wemos?
Thank You.
User avatar
By lapgoch
#75665 Just put your switch status 0 or 1 in a txt file eg status.txt on your RPI server.
In your wemos code use client.println("GET /RPIserverFilepath/status.txt");
User avatar
By btidey
#75675 Or use a Web Server on the Wemos
Code: Select allESP8266WebServer server(80);

Define a response mechanism to a url to the server in setup
Code: Select allserver.on("/switch", doSwitch);
doSwitch should now be a void function that will get called when say a GET is done to
Code: Select allhttp://ip/switch?state=1

This includes 0 or 1 'state' argument in the get and extract it in the doSwitch function and action it.

Code: Select allvoid doSwitch() {
   int state = server.arg("state").toInt();
   //do something with 'state to action switch
   server.send(200, "text/html", "switch done");
}