Two way communication NodeMCU

Hello everyone

I've made a project with a NodeMCU to cotnrol my lamp with my phone using Appinventor. This works fine but i'd like to have the lamp sending data back to my phone (Lamp is on/off). I've looked online but I don't find information on two way communication with a NodeMCU and Appinventor. Is there someone who can help me on my way?

Thank you in advance!


Did you find any information how to find out if the lamp is on/off with nodeMcu using other ways (not AppInventor)? The real question being, is this possible at all, regardless of AppInventor? And if yes, how.

Hello Miel

Unusual request, which is probably why a forum search didn't help.
If you are controlling the Lamp with your App, surely you can simply store the status (on/off) - or are you saying the lamp can be switched on/off by something else?

Here an example with ESP8266

Hi there, thanks for your answer!
When I shut off the app and/or lamp there's no way of knowing if the lamp is on/off, that's why I need some feedback from the lamp to the app.

Hi Ghica, thanks for your answer!
I know it's possible with the similar ESP8266 so I expect the same from the NodeMCU but it might be a good idea to look for an other kind of interface.

Hi Juan, thanks for your answer. I will look into it, maybe it's the same.

When you first start controlling the lamp, let's say it's off. After that initial setup, your App can always know if the lamp is on or off (provided the App is the only control of the lamp). You simply store an integer in TinyDb - 1 for on, 0 for off.

To handle the situation, how about attaching a LDR sensor along with the lamp and getting the current status of lamp.

The problem remains, for example: When the arduino inside the lamp is powerd on, the lamp is normally off. When I open the app, the status of the lamp is also off. There's is no problem when I turn the lamp on using the app for the first time. But then, I pull the lamp out of the plug and replug it, the arduino is reset and the lamp is by default normally off while the status in the app will still show that the lamp is on. Note that there isn't a way for the arduino to remember what the value of the variables were before it was shut off.
There are other situations where this can happen; second person with the app turns lamp on/off, arduino is reset...
I really need a way that the appinventor can ask the NodeMCU for a status update and change the variables in the app accordingly. But therefore, the NodeMCU needs to send data and the app needs to receive it. The app -> arduino way works perfect.

Well no, because the arduino always knows the status of the lamp (it decides when the relay is turned on/off). It's the app that doesn't know it's status!

You need to have some common place from where both Lamp and App can be in sync, maybe firebase cloud DB.

Perhaps this way,

In this example with ESP32 you can turn on/off two LEDs and get status