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.

  • \$\begingroup\$ 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, \$\endgroup\$
    – dandavis
    Feb 11, 2019 at 21:22
  • \$\begingroup\$ 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? \$\endgroup\$
    – Shounak
    Feb 12, 2019 at 2:57

1 Answer 1


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.
  • \$\begingroup\$ 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? \$\endgroup\$
    – Shounak
    Feb 11, 2019 at 14:49
  • \$\begingroup\$ 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? \$\endgroup\$
    – Shounak
    Feb 11, 2019 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.