Relays Going Off

Yılmaz, I’m using the same internet and the same power supply. I just added your piece of code and it stopped crashing. I also realized that on my “void setup()” there was a duplicated line on my my pin mode output declarations. This error was not on the code that I wrote here, but it was on the code in my saved file.

If you are using the power supply 5V - 1A for all of those relays that I dont think it is sustainable for the case.

You are using 8 AC voltage sensors? What are they? Are they Hall effect sensors to detect if there is the current existing / flowing to the cables? I suppose why you did not search to use for the physical buttons instead? Let use the sketch sample provided by Blynk?

Last but not least, your relays board is designed to control low load devices like lights, bulbs so if you use to control high load devices like water heater, air-cons, ceiling fans, … no way lah :joy:

Oh bro, I’m just using it to control lights bulbs, nothing else.

Well, I did the math and even with all the relays turned ON, the esp32 with the 8 pins on high, and all the voltage sensors turned ON, I still don’t reach 1A.

Yes, I’m using 8 voltage sensors that are NOT Hall effect sensors. This is a module that can be used both to indicate a voltage and to check its presence. It has an optocoupler that ensures the esp32 isolation. As I said, I’m not using them yet, but they will be used to detect when the lights are turned ON by the wall switch (psychical button). Knowing this I can have an app button widget feedback.

Anyway, I just tested and it is doing it again. It is turning OFF all the relays just after they turn ON. I will try a 2A power supply.

Ok guys, I tried with a 5V 2.5A power supply and on another wifi and I the the relays keep turning off. This time all my sensors are disconnected. I THINK the problem might be the sensor. They’re somehow messing with the esp32.

Let me explain.

Right now the relays are turned ON and aren’t turning OFF. If I plug just one sensor in the esp32, few minutes later the relays will turn off. If I unplug everything and plug only the relays they will keep turning OFF. But, if I reprogram the esp32 and plug just the relays, they will be ok and will not turn OFF. The second I plug the sensors, the relays start turning OFF even if I unplug the sensor and reboot the esp32.

This might being caused by the Logical Level Voltage of the esp32. It works with 3.3V and the signal thats coming from the sensors are 5V. I probably need voltage divider to use those sensors.

I think you need to more clear about what you are actually doing. In your initial post you stated that the sensors were not connected, and even showed that with the picture you posted. Now you are stating the issue is only present when the sensors are connected.

Additionally, using different code than what you posted doesn’t help either. Make sure that if you make changes (either from suggestions or experimentation) that you re-post the code you are actually using.

If the issue occurs when you add the wires for the sensors then that is were I would look. Make sure your wiring for the sensor(s) is correct, that you are not using any “special” pins on the ESP32 that is causing resets/reboots, that your logic level is correct and that you have declared the pins as inputs (and not floating).

If you happen to have a data sheet for your AC Sensor that may be helpful as well.

@elsonmpf
hi
what do you use as AC Voltage sensors ?
AC Voltage sensors are for analog input
the ESP8266 only has one analog pin

Alexis, I’m not using esp8266, I’m using esp32.

check it out:

My AC Voltage Sensors are the P8 Sensors from KGB.

Here you can find a sort of Datasheet, with not that much information: https://www.eletruscomp.com.br/arquivos/1488561410_dados_tecnicos_p8___gbk_sensor_de_tensao_ac.pdf

Unfortunately it is in Portuguese and I can’t find this kind of sensor outside of Brazil to have an English Datasheet.

Sorry man, I didn’t explain it in a proper way.

Firstly I was not using the sensor as I said. I came here asking for help and Yilmazyurdakul gave a tip about adding a piece of code. I did it and somehow my circuit started working without problem for 12 hours. I turned it off and went to sleep. On the next day I added the sensor and the circuit started acting weird again, turning off right after I turn it on. So I assumed that sensors were the problem this time.

Secondly, I didn’t realize that the code was different. I was coping and pasting parts of the code from my file to this post. When I was doing this I wrote the code here without the duplicated line without realizing it.

Finally my wirings from my sensors were ok and I finally realized what I was doing wrong. As Alexis said, I started to monitor the serial. I realized that it wasn’t just the relays that were turning off, but the esp32 was turning off and on as well. I made a dumb mistake and just got it today.

My relay board has two 5v pins and a power supply born. After all I WASN’T using this power supply born. I was powering the relay board through one of those 5v pins. I was also powering the esp32 on the another 5v pin on the relay board. It comes out that those 5v pins are outputs, so I shouldn’t be powering the relay board through them. I’m now powering it properly, as well as the esp32. I’m going to leave it on as long as possible to be sure it will not turn off.

If you check my first picture, you will see what I was doing wrong. This post is probably solved but I will wait few more hours with the circuit turned on to make sure this was the problem.

thank you @elsonmpf
next time I 'll buy a nodemcu ESP32S
now I am using 2 nodmcu esp8266, so only one analog pin

I’m the one who needs to thank all the help you guys are giving :slight_smile:

1 Like

don’t worry, we all need help one day !

2 Likes

Maybe that can help you