Go Down

Topic: home automation Project  (Read 766 times) previous topic - next topic

mokioki

hello, i have made my home automation using 4 channel relay and Node mcu
every thing went well but i am facing two problems,( i have used D1, D2, D3, D8 of Node MCU with the relay )

1) when i turn on the supply of the board relay connected to D3 turns on for a fraction of second and then turns off, how to remove this problem??

2) If all my devices are in ON state and if i turn off the power to the main board, after turning it ON again it gets reset means all the devices are in OFF state now how to remove this problem ??

Thank you

anbu123

Actually nothing you can do.It will take fraction of seconds to restart.May be you can add EEPROM to remember previous state :)

pylon

You may change to bistable relays, they don't switch if you not actively are forcing them to. But you need twice as many outputs...

Watcher

#3
May 09, 2018, 06:40 am Last Edit: May 09, 2018, 06:45 am by Watcher
Quote
1) when i turn on the supply of the board relay connected to D3 turns on for a fraction of second and then turns off, how to remove this problem??

2) If all my devices are in ON state and if i turn off the power to the main board, after turning it ON again it gets reset means all the devices are in OFF state now how to remove this problem ??
1. That fraction of a second is the time it takes for the software (your sketch) to turn the D3 at low state.
The solution is to use inverse logic , ie logic zero is the ON state of the relay and logic 1 is the Off state
If you had posted a schematic would have been easier to help.

2. This problem is more difficult to solve. You need to somehow save the current state of the relay before power off. Provided this doesn't happen too often you can save the relay state in the MCU EEPROM and then at power on read the saved state and activate the relays accordingly.

ie add the following line to your loop:

Code: [Select]
EEPROM.update(address, relayState);

EEPROM.update doesnt actually write to the EEPROM unless the value to be written is different from the current value. Therefore the EEPROM life doesnt get wasted.

pylon

Quote
Provided this doesn't happen too often you can save the relay state in the MCU EEPROM and then at power on read the saved state and activate the relays accordingly.
NodeMCU doesn't have any EEPROM as far as I know, unfortunately.

Wawa

I have several WeMos boards running 24/7 on a tiny 5volt cellphone charger plugged into the USB socket.
Never turning them off will fix your startup problems.

With an Uno/Mega/Nano, that can have that same behaviour with certain relay boards, you have to digitalWrite a HIGH to the pin BEFORE setting the pin to OUTPUT with pinMode.
Not sure if this works with an ESP8266.

Maybe you should have posted a link to the relay, and your code (inside code tags) for better help.
Leo..

P.S. The NodeMCU has 4MB of flash that you can write to (SPIFFS).

Watcher

Quote
NodeMCU doesn't have any EEPROM as far as I know, unfortunately.
You are right. I just realized that its a nodeMCU!

martinius96

I can code it for you :-) If you want: martinius96@gmail.com

Wawa

I can code it for you :-) If you want: martinius96@gmail.com
Give a man fish...

People only get proper help if they read the "how to post" sticky that's on top of every main page.
To solve this we need at least links to the parts used (there are many different 4-relay boards),
and the code used (inside code tags).
Leo..

Go Up