Everything is working but trouble appears by applying power to the relay board

Hello Arduino community,

First off all: happy New Year!

I am using an ESP32 connected via bluetooth and combined with 4 extension Boards and five 8 channel relay boards (12V).
W/o applying voltage to the relay boards every thing is working as expected. By using the app "bluetooth electronics" every button is showing the correct answer on the related relay (visible by the indicator led).
Therefore everything is working as planned.

But by switching on the 12V power supply to the relay boards everything seems to be out off control.
By clicking a button on the tablet

  • the related relay is working as planned
    Or
  • other relays beside the correct one are switching in parallel
    Or
  • except the correct relay other relays are switching.

By using one button many times all 3 combinations are appearing randomly.

I have no idea, why the power supply is changing the obviously correct installation to a random working one.

Is this phenomenom allready known or has anybody an idea how to solve this trouble?

Thank you very much in advance, thodine

How are you supplying power to relay vcc? ESP is a 3.3v device and relays need 5v usually. Alternatively are the grounds connected?

Hello mugambi,

The Arduino is using a standard USB plug-in power supply, the relay boards are powered by a seperate power supply with 12V.
Details:
Arduino is linked to 4 expansion boards by using VCC, GRD, SDA and SCL.
Expansion boards are linked by VCC and the 8 pins to the relay board (no GRD)
Relay boards are powered via GRD and JD-VCC with 12V.
Whole setup
Detail 1
Detail 2
Detail 3
In addition I added the pictures as an attachment.

Thank you for your fast replay.
Looking forward for your feedback,
Regards Thodine

I can't see much, from what I can see, it all looks OK.

This claim you made is important. That without 12 volts powering the relay boards, everything appears to work correctly. That is the indicator leds of the the correct relay modules are lit at the appropriate times. I guess you've tested them all. That rules out any addressing problems on those I2C port expanders.

Incidentally, those expander boards are powered at 3.3 volts from the ESP32 3V3 pin ?

For the power connection to the relay boards, you have used GND and JD-VCC and no relay board has a jumper between VCC and JD-VCC. Is that correct ?

From what I can see here: 8 Channel 5V Relay Module - Wiki , you omit the GND connection on the 10 pin headers of each relay board. There is then full opto isolation between the relay power and the relay signals.

You are also certain that those relay modules are specified for 12 volt ?
The only other thing I can suggest is to check for a short between the relay power pins VCC (not used) and JD-VCC on each board.

Edit 1.
Maybe supply a link to those expander boards and show your code for configuring them.

Edit 2.
Also try powering the relay boards 0ne at a time, to see if only one relay board is causing the problem.

Hello 6v6gt
Regarding your questions:
Yes, the relay boards are all 12v types and I replaced them already by other 12V boards --> no change.
Therefore the relay boards shall not be the root cause.
There are no remaining jumpers on the boards, all are connected only via JD-VCC and GRD.

The expansion boards are connected via 3V3 pin of the arduino ESP32

I also unplugged 3 of 4 expansion boards.
The remaining expansion board and the related relay board are showing same effect: firstly the relays are following the button typed on the via bluetooth connected tablet and then other relays are also switching.
I tried this with 2 of four expansion boards, same effect.

Next try:
Everything connected, but no power on the relay board.
By pressing all buttons randomly the reaction of the indicator LEDs on the relay board is as expected.
BUT after pressing one button many times after 15 – 20 times the system is getting out off control. Other relay indicator LEDs (no power on relay board) are switching on and off randomly, sometimes all together.
The software is switching the relays on by pressing the button and with a delay of 200ms the relay is switching off.
But even this is not working anymore; sometimes the relay is switched only on and is remaining on. After pressing the button again the LED is switched off?!?
This all is only related to the relay board with the related button. All other relays are not involved. Butt this effect is appearing on all boards.
And then after clicking some times more everything is dead, no indicator LED is swithing on /off until depowering the arduino, waiting for a while and starting again.

Now I have two different situations:
With powered relay boards the mismatch between pressing the buttons and the uncontrolled switch of the relay is happening imediatelly.
With unpowered relay board the first system behaviour is as expected, but after pressing one button many times the trouble is appearing also.

Therefore maybe no hardware related trouble?
But why this is happening only after pressing a button many times and why the switching off operation with the software controlled delay is ignored?

Below you will find a link to my sketch, something wrong here?
For better understanding:
Purpose for this setup is to controll the crossovers of my model railway.
Every crossover needs one relay powered for 200ms for direction „straight“ and one for „turn“.
I started the sketch in German, therefore the variables are using mainly German words, I added English translations, hopefully understandable.
As you can see on my setup, not all relays are available as given by the sketch.
I blanked them out as a comment, but didn´t deleted them.

Link:Sketch model railway crossover

Sketch with .doc format

Trouble description, sketch.doc (73.5 KB)

OK.
So you can replicate the problem with just:

One ESP32
One MCP23017 port expansion break out board
One 8 Channel relay module.

Is that correct ?

I think you have to, for this trouble shooting exercise, reduce your circuit to just those components, then look for the instability in that reduced configuration.

  1. Can you produce a schematic diagram of those components and their interconnections. Pin numbers / labelling should be visible on your schematic. It can be a (in focus) picture of a hand drawn circuit.

  2. Post links to those 3 boards ( ESP32, MCP23017, relay board)

  3. instead of a Word document, please supply the original .ino file in text form and attach that.

EDIT

We'll have to see all the documentation to be sure, but it is likely that a 3.3volt Vcc is at border line for those relay modules, since there are 2 leds in series (one being the opto coupler LED and the other an indicator led) plus (probably) a 1k resistor.

I guess you may have to start thinking of using an I2C level shifter and running the MCP23017 / relay module isolated side at 5.0 volts (which you can derive from the ESP32 module).

Hello 6v6gt,

as I already explained before I already tried many different variants by in and excluding the expansion and relay boards. The base was always the setup I showed in my first picture.

Driven by your hints and requests and the confirmation from you and other community members, that the wiring should be OK I tried all variants again. Due to the different combinations the wiring got more and more confused and I started to use different wires and exchanged the half cutted bread board on my set up by a new one.

Finally every variants worked well and I connected all wires back to the initial combination by excluding the half breadboard.
EVERYTHING IS WORKING, HURRAY!!!

It seems to be, that by cutting the board something went wrong (partial randomly short cuts by touching the wires, leackage current, ??? maybe something else).
Why I cutted the board?:
Unfortunatelly the ESP32 is too big to use one of my breadboards on both sides. Instead of using two boards like done on my setup I halfend one bread board.

Tommorrow I will do some additional trials and hopefully I don´t need your support again.

Nevertheless thank you for your unexpected very short termed support by confirming my setup and thoughts and asking specific questions, which leeds finally to my motivation to rewire everything.

Therefore please cross your fingers, that I found my troubleshooter and I will come back, if I have additional questions.

Thanx and regards Thodine