• Use a 8 channel relay module to switch the mains for 6 units of 3 Watt LED.
  • Use an Arduino Nano with NRF24L01+ and adapter module to communicate with the MySensors gateway.
  • Use a PCF8575 based IO-expander module to increase the number of I/O pins.
  • Use 7 switches wired to the PCF8575 as light switches.
  • The 5V HLK-PM01 based power supply is permanently on. The 5V is used by the relais and the Arduino.
  • The 230V AC of the 24V LED power supply is switched by the relay module.
  • Two relais are used for the LED strip, to create a rush-in current limiting system - so that the relay contacts won't fuse.
  • Since the Arduino is permanently powered, switching on the power of the Arduino should result in all the lights off. Restoring of the last light status is not wished.

The result

Testing with 2 very bright LED bars

Power consumption 5V:

  • with all relays on: 450mA
  • with all relays off: 33mA

Used Components

The modules connected


Component Pin Wire/Component Pin Component
Arduino Nano A4   SDA PCF8575 Module
Arduino Nano A5   SCL PCF8575 Module
The wiring
The 7 buttons


  • Select as board: Arduino Nano
  • Processor: ATmega328P (5V, 16MHz)
  • Serial monitor: 115200 Baud
  • Use platformio

Code at LEDstripAnd7Spots.ino and platformio.ini.

The statemachine riclim

Switching a heavy load with relays can be done by dimensioning the relays correctly. We use a 250W power supply and switch 250V AC, hence the maximum stable current is 1A, which is well within the specifications of the relays. The relays used here are 10A at 250VAC.

However, heavy power supplies tend to have high rush-in currents with a peak of up to 80A, which normally lasts very short, but is sufficient to melt the relay contacts together. Mechanical relays often have the property that the melted contacts can be opened again by tapping on them. This is ofcourse not a desired situation, so we look for a way to limit the rush-in current.

In the industry, rush-in currents are limited by putting an NTC resistor in series: at switching on, the resistor limits the current. E.g. a 47 Ohm resistor limits the current to 5 A for a 240V AC supply. But that only applies when the resistor is at room temperature. Since the resistor in this case "burns" 5A * 240V = 1200 Watt, it quickly starts to heat up, reducing its resistance to a much lower value, until it stabelises.

Hence, we can safely switch on a load with a high rush-in current. But there are some problems with this set-up:

  • When we switch the load off, and then inmediately back on again: In this situation, the thermistor is still hot, and does not limit the current sufficiently.
  • The thermistor remains at a high temperature all the time, for which we need to take precautions to do this safely.
  • The thermistor remains at a high temperature all the time, burning needless energy,
  • The thermistor needs enough ventilation to cool down rapidly.

We try to fix these problems as follows:

We use two relais to switch the power supply of the LED strip at mains voltage 230V AC.

When switching on, the first relais connects the power supply to the mains via a number of NTC Thermistor Resistors of type 47D-15, which are 47 Ohm at room temperature. Hence, the rush-in current of the power supply goes via the resistors, and is limited. After a few moments, the thermistors heat up, and their resistence goes down. At that moment, the second relay bridges the thermistors, so that no current will flow any more through them, and they can cool down. Switching off is done with both relays at the same time. The software takes care of the timing, and prevents the user to switch on too soon: i.e. before the thermistors are cooled down.

Automaton graph of the statemachine that implements a Rush-In Current LIMiter

The statemachine figure shows the states in the left column, and the transitions are in the top row.

UML diagram of the statemachine that implements a Rush-In Current LIMiter

First sign of life

Serial output after first successful start, node id 23 is assigned here:

__  __       ____
|  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
| |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
| |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
|_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
       |___/                      2.3.2

38 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
246 TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0
2049 TSM:ID
2053 TSF:MSG:SEND,255-255-0-0,s=2,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
2069 TSF:MSG:READ,0-0-255,s=2,c=3,t=4,pt=0,l=2,sg=0:23
2074 TSF:SID:OK,ID=23
2076 TSM:ID:OK
2078 TSM:UPL
2107 TSF:MSG:SEND,23-23-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
2128 TSF:MSG:READ,0-21-255,s=2,c=3,t=4,pt=0,l=2,sg=0:23
2136 TSF:MSG:READ,0-0-23,s=255,c=3,t=25,pt=1,l=1,sg=0:1
2145 TSM:READY:ID=23,PAR=0,DIS=1
2150 TSF:MSG:SEND,23-23-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
2157 TSF:MSG:READ,0-0-23,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
2164 TSF:MSG:SEND,23-23-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
2172 TSF:MSG:SEND,23-23-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
2189 TSF:MSG:READ,0-0-23,s=255,c=3,t=6,pt=0,l=1,sg=0:M
2197 TSF:MSG:SEND,23-23-0-0,s=255,c=3,t=11,pt=0,l=22,sg=0,ft=0,st=OK:LEDstripAnd6Spots(LAS)
2207 TSF:MSG:SEND,23-23-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
2216 TSF:MSG:SEND,23-23-0-0,s=0,c=0,t=3,pt=0,l=25,sg=0,ft=0,st=OK:LAS 1 - E61 Voorkamer spo
2231 TSF:MSG:SEND,23-23-0-0,s=1,c=0,t=3,pt=0,l=25,sg=0,ft=0,st=OK:LAS 2 - E62 Voorkamer spo
2242 TSF:MSG:SEND,23-23-0-0,s=2,c=0,t=3,pt=0,l=25,sg=0,ft=0,st=OK:LAS 3 - E63 Voorkamer spo
2255 TSF:MSG:SEND,23-23-0-0,s=3,c=0,t=3,pt=0,l=25,sg=0,ft=0,st=OK:LAS 4 - E64 Voorkamer spo
2267 TSF:MSG:SEND,23-23-0-0,s=4,c=0,t=3,pt=0,l=25,sg=0,ft=0,st=OK:LAS 5 - E65 Voorkamer spo
2278 TSF:MSG:SEND,23-23-0-0,s=5,c=0,t=3,pt=0,l=25,sg=0,ft=0,st=OK:LAS 6 - E66 Voorkamer spo
2289 TSF:MSG:SEND,23-23-0-0,s=6,c=0,t=3,pt=0,l=25,sg=0,ft=0,st=OK:LAS S - E67 Voorkamer LED
2298 TSF:MSG:READ,0-21-255,s=2,c=3,t=4,pt=0,l=2,sg=0:23
2350 TSF:MSG:SEND,23-23-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
2357 TSF:MSG:READ,0-0-23,s=255,c=3,t=27,pt=1,l=1,sg=0:1
LEDstripAnd6Spots(LAS) 1.0PCF8575_LIB_VERSION:  0.1.4  => connected!!

The Domoticz log says:

2021-12-24 17:36:21.705 MySensors-Gateway-LAN-W5100: Light/Switch (LAS 1 - E61 Voorkamer spo)
2021-12-24 17:36:21.719 MySensors-Gateway-LAN-W5100: Light/Switch (LAS 2 - E62 Voorkamer spo)
2021-12-24 17:36:21.732 MySensors-Gateway-LAN-W5100: Light/Switch (LAS 3 - E63 Voorkamer spo)
2021-12-24 17:36:21.744 MySensors-Gateway-LAN-W5100: Light/Switch (LAS 4 - E64 Voorkamer spo)
2021-12-24 17:36:21.758 MySensors-Gateway-LAN-W5100: Light/Switch (LAS 5 - E65 Voorkamer spo)
2021-12-24 17:36:21.772 MySensors-Gateway-LAN-W5100: Light/Switch (LAS 6 - E66 Voorkamer spo)
2021-12-24 17:36:21.790 MySensors-Gateway-LAN-W5100: Light/Switch (LAS S - E67 Voorkamer LED)
2021-12-24 17:36:21.681 Status: MySensors-Gateway-LAN-W5100: Node: 23, Sketch Name: LEDstripAnd6Spots(LAS)
2021-12-24 17:36:21.689 Status: MySensors-Gateway-LAN-W5100: Node: 23, Sketch Version: 1.0 
Tags: domotica nodes