Sensor and status text OPEN or ClOSED

Hi!

I have a magnetic sensor that indicates the state of a door. When it is open, it sends logic level 1 (3.3V) to pin D4 of a NodeMCU. When it is closed it sends logic level 0 (0V) to pin D4.

I would like to know how to send text to the Blynk app, for example: When the door opened, I wanted to send the text OPEN to appear in blynk app and when the door closed I wanted to send the text CLOSED to appear in the blynk app.

Is there a specific command to send texts? Can anybody help me?

Just to start, you said you were using pin D4 of a NodeMCU board, this isn’t the best choice for sensors as it is pulled high at startup, thus can cause interference. I would recomend taking a look at this post, and choosing another pin.

As for displaying this data, there are lots of ways of doing it. Blynk.virtualWrite(VirtualPin, Data); will send most things you could want it to. More information on it’s limitations can be found in the docs.

As to how you wish to display it in the app is a different matter. If you want to keep a history of the door’s state over time, that way you can see what times it was opened or closed, I would recommend using using the SuperChart. This will let you plot a graph, where you can assign a name (eg. open or closed) for state (1 or 0). This would require the least programming on the hardware, so I thinks it’s probably the easiest / nicest way of doing it.

If you need any help setting up the SuperChart, I would be more than happy to take you through the process. (It’s really quite simple) :slight_smile:

Thank you! I got it using Blynk.virtualWrite (pin, “abc”);

Now I would like to know if you can send the text and according to the state of the sensor the text will change color, for example:

Open Door, sends the text OPEN with the color red.

Door closed, sends the text CLOSED with the color green.

Yes You can change the color, along with the text.

1 Like