Chat freely about anything...

User avatar
By forlotto
#29057 Anyone have an example of the following things:

-Sending On/Off from a remote web server.
-Reading Status Of Pin from a remote web server.
-Init.lua I would need to load to work with your example.
-Connecting and staying connected to this remote web server maybe with a user name and password IDK.

Lets say I click a button on a remote website I would like it to relay the information to my NodeMCU using html if possible.
What I am trying to accomplish is a bit more in depth but I need to know how to do these basic things first.

IDK what I need to do this or how it is done etc... I don't get it.

Please help me out here I feel like the answers are just not available anywhere been searching for weeks.
User avatar
By forlotto
#29215 DOH!

No one with a few minutes is able to lend a hand I presume?
User avatar
By anupak
#29220 Not sure what programming mode you are using, Ardruino/SDK? i have a few examples documented for SDK (code available at https://github.com/anupak/esp8266-samplecode ). The documentation/explanation is available at my blog: http://forgetfullbrain.blogspot.in.

Hope it helps.

Anup
User avatar
By bjpirt
#29225 You've just run into the classic beginner's problem on a forum where you've asked in quite a confused way about something relatively complex, which means the answer is probably going to be quite complex and so people don't respond because it's going to take too much time.

But I'll try to give you some pointers for how to approach solving the problem on your own because it's doable, but you need to get it clear how all of this stuff works (not meaning to be patronising, just honest!). I haven't used lua on NodeMCU so can't give you specifics, but once you break down your problem then it should be pretty easy to ask on the NodeMCU part of the forum.

So, you want to click a button on a website and have something happen on the ESP. The solution depends on how quick you need the response to be. If it's not urgent, then you can store the value of the switch on the server and then have the ESP poll using HTTP occasionally and checking the value. There are a bunch of services out there which will let you do this (search for IoT platform) but Thingspeak is probably easiest at this point (though it pains me to say that...) if you don't want to build it yourself.

If you want an immediate response, then you want to keep a socket open to the web server which can then push out a message as soon as the switch changes state. This is more complex on the server side, but again, there are a bunch of services you could use to do this part so you don't have to build it yourself.

So that should get you started. If you look for examples on either making a HTTP request form lua or keeping a socket open it should get you going.

Hope that helps,
Ben