Relay switch to control lamp

never mind, on your pi terminal add this line cat /etc/myDevices/devices.json and share the it here.

Here it is, thank you!

pi@raspberrypi:~ $ cat /etc/myDevices/devices.json
[{“name”: “xHwG9xwyv3IJGoF”, “description”: “Relay Switch”, “device”:
“RelaySwitch”, “type”: [“DigitalActuator”], “status”: 1, “args”:
{“gpio”: “GPIO”, “channel”: 26, “invert”: true, “last_state”: 0},
“origin”: “rest”, “install_date”: 1581529843}]pi@raspberrypi:~ $ cat
/etc/myDevices/devices.json
[{“name”: “xHwG9xwyv3IJGoF”, “description”: “Relay Switch”, “device”:
“RelaySwitch”, “type”: [“DigitalActuator”], “status”: 1, “args”:
{“gpio”: “GPIO”, “channel”: 26, “invert”: true, “last_state”: 1},
“origin”: “rest”, “install_date”: 1581529843}]pi@raspberrypi:~ $

try this command now tail -f /var/log/myDevices/cayenne.log | grep sys:gpio:26;value and turn ON/OFF the button.

Nothing happens, the lamp stays on when the widget it’s on or off

do one thing, remove this button. then follow this: add new—> device/widget —> actuator —> generic —> fill add details with channel 26

I have done that. I created a widget->actuator->generic->digital output with channel 26. The widget on/off doesn’t control the lamp.
I tried to create a similar widget but this time in channel 19 (GPIO 19), connected my IN terminal of relay to GPIO19 and it does not control either.

After I delete the channel 26 widget, if I connect the IN terminal of relay to GPIO 26 it will turn ON the lamp, i feel like cayenne platform puts the GPIO forever ON when it creates the widgets, but it does not turn them off

see if this code works for you https://tutorials-raspberrypi.com/raspberry-pi-control-relay-switch-via-gpio/ and you can control the relay.

I implemented the tutorial with sucess.
But when I’m using cayenne, I can turn the lamp ON/OFF by connecting and disconnecting the IN terminal of relay to the GPIO pin 26. Isn’t it supposed to control the lamp trough the widget at cayenne dashboard by simply pressing it?

can you private message me your email_id.

Hello,

I solved the problem. For some reason the 5V DC relay switch of “TONGLING” doesn’t work or isn’t compatible with raspberry pi, and consequently cayenne.
I bought a relay switch of the brand “SONGLE” from Robotdyn: https://robotdyn.com/relay-module-1-relay-5v.htm , and the ON/OFF widget on my cayenne dashboard is controling the lamp perfectly.
Thank you!

2 Likes