Principles
- Use a relay module to switch the mains for a LED light.
- Use an Arduino Nano
- The HLK-PM01 power supply is permanently on
- The 230V AC of the LED power supply is switched by the relay module.
The result
Testing with 2 very bright LED bars
Used Components
- An ArduinoNano5V based RFNanoKeywish which includes a NRF24L01+.
- A power supply for the Arduino based on the PowerSupply_HLK-PM01.
- A 12V DC 60W power supply.
- LED bars 12V.
Wiring
| Component | Pin | Wire/Component | Pin | Component |
|---|---|---|---|---|
| Arduino | D3 | white | input | Relay module |
Programming
- Select as board: Arduino Nano
- Processor: ATmega328P (5V, 16MHz)
- Serial monitor: 115200 Baud
- Use platformio
Code at LightRelayNano.ino and platformio.ini.
First sign of life
Serial output after first successful start, node id 22 was already assigned:
__ __ ____
| \/ |_ _/ ___| ___ _ __ ___ ___ _ __ ___
| |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
| | | | |_| |___| | __/ | | \__ \ _ | | \__ \
|_| |_|\__, |____/ \___|_| |_|___/\___/|_| |___/
|___/ 2.3.2
16 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=16,REL=255,VER=2.3.2
26 TSM:INIT
28 TSF:WUR:MS=0
34 TSM:INIT:TSP OK
36 TSF:SID:OK,ID=22
38 TSM:FPAR
41 ?TSF:MSG:SEND,22-22-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
1021 TSF:MSG:READ,0-0-22,s=255,c=3,t=8,pt=1,l=1,sg=0:0
1027 TSF:MSG:FPAR OK,ID=0,D=1
1972 TSF:MSG:READ,7-7-22,s=255,c=3,t=8,pt=1,l=1,sg=0:1
1981 TSF:MSG:READ,17-17-22,s=255,c=3,t=8,pt=1,l=1,sg=0:2
2050 TSM:FPAR:OK
2051 TSM:ID
2052 TSM:ID:OK
2054 TSM:UPL
2059 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
2067 TSF:MSG:READ,0-0-22,s=255,c=3,t=25,pt=1,l=1,sg=0:1
2072 TSF:MSG:PONG RECV,HP=1
2074 TSM:UPL:OK
2076 TSM:READY:ID=22,PAR=0,DIS=1
2083 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
2089 TSF:MSG:READ,0-0-22,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
2098 TSF:MSG:SEND,22-22-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
2108 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
2122 TSF:MSG:READ,0-0-22,s=255,c=3,t=6,pt=0,l=1,sg=0:M
2129 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=11,pt=0,l=14,sg=0,ft=0,st=OK:LightRelayNano
2142 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
2150 TSF:MSG:SEND,22-22-0-0,s=1,c=0,t=3,pt=0,l=11,sg=0,ft=0,st=OK:LRN - Light
2207 MCO:REG:REQ
2212 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
2219 TSF:MSG:READ,0-0-22,s=255,c=3,t=27,pt=1,l=1,sg=0:1
2225 MCO:PIM:NODE REG=1
2227 MCO:BGN:STP
LightRelayNano 1.02230 MCO:BGN:INIT OK,TSP=1
13480 TSF:MSG:READ,0-0-22,s=1,c=1,t=2,pt=0,l=1,sg=0:1
Incoming change for light relay: 1, New status: 1
19479 TSF:MSG:READ,0-0-22,s=1,c=1,t=2,pt=0,l=1,sg=0:0
Incoming change for light relay: 1, New status: 0
22942 TSF:MSG:READ,0-0-22,s=1,c=1,t=2,pt=0,l=1,sg=0:1
Incoming change for light relay: 1, New status: 1
25408 TSF:MSG:READ,0-0-22,s=1,c=1,t=2,pt=0,l=1,sg=0:0
Incoming change for light relay: 1, New status: 0
295506 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
295512 TSF:MSG:BC
296124 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
296130 TSF:MSG:READ,0-21-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
296136 TSF:MSG:BC
296137 TSF:MSG:READ,0-7-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
296143 TSF:MSG:BC
296536 TSF:MSG:READ,0-20-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
296541 TSF:MSG:BC
1495640 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
1495645 TSF:MSG:BC
1496257 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
1496311 TSF:MSG:READ,0-21-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
1496316 TSF:MSG:BC
1496569 TSF:MSG:READ,0-20-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
1496576 TSF:MSG:BC
1496676 TSF:MSG:READ,0-7-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
1496681 TSF:MSG:BC
2695773 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
2695778 TSF:MSG:BC
2696396 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
2696402 TSF:MSG:READ,0-21-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
2696409 TSF:MSG:BC
2696628 TSF:MSG:READ,0-7-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
2696633 TSF:MSG:BC
Comments: