0

I have a NodeMCU and a website (free website domain provided by hpage.com) and I have to send and receive some data (suppose a 8-bit number) from the website to the NodeMCU via internet.

The NodeMCU is connected to internet through WiFi hotspot of an Android phone.

Can anyone provide an example code?

I have seen the system working on WiFi LAN, and I don't want to limit it to local network.

  • How can I address the NodeMCU from the website?
  • Does the NodeMCU need to be a server or just a client?

Thanks in advance for kind help. I can't use a WiFi router, I have to use a android phone hotspot in this case.

Electric_90
  • 2,112
  • 13
  • 25
Shounak
  • 3
  • 2
  • pushing _to_ the site isn't a problem. Pushing _from_ the site require poking through the firewall, but you shouldn't need to do that anyway, – dandavis Feb 11 '19 at 21:22
  • Yes, that's where the real problem arise. But, when I request anything to the webserver, can't the server send some data by then? – Shounak Feb 12 '19 at 02:57

1 Answers1

0

It is a bit difficult to address local device from the internet due to the protection provided by the firewall.

There are may ways to solve this problem (i.e. opening a port on the router, creating a server to address queries coming from the internet etc.).

I use Firebase as an external database and make my NodeMCU such that it listens to changes on the Firebase real time database.

  • You can integrate firebase with your website and using the website you can update database values.
  • Whenever a value is changed the NodeMCU will respond to it.
  • Example code for the same can be obtained from the internet. There are many tutorials, videos on this topic which you can go through.
Electric_90
  • 2,112
  • 13
  • 25
  • That's a good idea to use firebase for database. Is there any way to directly communicate with the nodemcu from the website? If I can send and receive an 8 bit data after a few milliseconds delay, that would be enough for me. I can't open a port of router as I am using an Android phone as wifi router, is there any way to do that? – Shounak Feb 11 '19 at 14:49
  • If I create a server in nodemcu to address queries from internet as you said will it affect the working of nodemcu as a client to the web server? Can I use php to connect the nodemcu server from website when I have one? – Shounak Feb 11 '19 at 14:58