Trigger send sms node Nexmo, when GPIO changes


I want to trigger the sms node the moment the status of a GPIO pin on my raspberry pi changes from high to low. I have no idea how this must be done. When I add a timestamp the sms is send. So the nexmo node is working properly, but I don't know how I can trigger it with a status change of a pin.
I hope somebody can give me some advice.

Thank you.

Add the rpi gpio in node

Configure it to use whatever pin you want (Pin 11 being a standard one to use) and also configure it with a pull-up resistor

Then when you connect that pin to ground (obviously being very careful about how you do that - I find a female-male breadboard lead is a good way as least likely to short any Pi pins out) it will send out a 0 and when you un-ground it, it will go back to a 1

Hi Cymplecy,

Thank for your answer. But how can I read if the GPIO pin status changes?
Do I need to write code in a function node or is there another way?

Can you post what you have working at the moment?

I have a magnetic door sensor which is attached to a raspberry pi. When the door opens, it triggers a transistor. A relaymodule is set low when the door is open and a switch in my node-red web frontend is set to on, with the result that a sirene blows. As you can see in the flow, I use a python script to create a MQTT connection. I attach the code. My thought is that I use the send sms node of Nexmo in order to send an SMS when the same criteria are met. My problem is that I have no idea how I can trigger the send sms node. I don't want to use the nexmo code as described on their website, because I think it's not always reliable. So I want to give the Nexmo node a try.
I hope you see the picture as I tried to describe it here.
Thank you for your help.Steve.txt (2.1 KB)
flows.json (1.1 KB)


Something like this works (using gpio pin 12). Define two sms messages, one for "door open" and one for "door closed". Use the switch node to select the proper message to send, all depending on the state of the door/pin

1 Like

use node-change
and you can change to boolean, or made a function with a variable like this

msg.payload = {
"bState": false

// to get variable 
// msg.payload.bState 
// return a false

return msg;

And...??? what is this? A solution to what??