Two years ago I made a project to control the terrarium for my reptile.
My background is computer engineering so I struggle a bit with the electronics part.
The setup includes two fans, several lights and two ceramic heaters.
The objectives consisted in:
Turning the lights on/off depending on the time
Turning the heaters on/off depending on the temperature readings
Turning the fans on/off depending on the time
To sum it up, the UNO reads from the DHT22 and according to the time on the RTC acts on the 4 channel relay board to control everything, info is displayed on the LCD.
This project has two main problems, the LCD randomly freezed or went blank and sometimes all the project hanged.
I know that most of this is solved with circuit design tweaks but at the time I just used software fixes such has implementing a watchdog and reloading the LCD each time a relay takes action.
Now I want to upgrade my project but i want to correct the mistakes first, and as I'll be changing the circuit part I want to make the necessary alterations altogether.
The update is to add a dimmer module but I'll get on that later when all is fixed. Right now it seems to be working fine but I still see some restarts ocasionally wich means something caused the watchdog to act.
I'll leave some pictures bellow to show the LCD and the different parts (I know the wiring is really bad, it i'll be adressed as part of the update too).
The code and different schematics will be attached, the fritz shows the way the relay board is powered, the EDA is more detailed. Again, I'm not experienced in making schematics.
I'll be thankfull if you can help me correct anything that I did wrong
I don't see how your Uno is grounded in the fritz drawing. You need a common ground from the relay board to the DH11 sensors to the breadboard to the UNO just like +5V.
The most common cause of locking up with i2c is noise on the lines which confuses the hardware and then the wire library gets in a state it can never get out of so the UNO appears to hang. It is best to keep i2c wires as short as possible. You could also try adding some 4.7k pullup resistors to SCL and SDA. (the wire library uses the internal pullup resistors, but they are ~20k. The RTC module and the LCD module both *probably have onboard pull-up resistors, but you'd have to check the datasheets or inspect them)
blh64:
I don't see how your Uno is grounded in the fritz drawing.
You could also try adding some 4.7k pullup resistors to SCL and SDA.
Thank you for your help blh64. I forgot to metion that the Uno is being powered via USB. That 5v DC is the external power to the relay board, that is connected just as larryd suggested in the reply bellow.
So one pull up on each SDA and SCL segment like in this example?
Both between Uno-RTC and RTC-LCD? For a total of 4 pull up resistors?
larryd:
Suggest you wire the relay board similar to this.
Also, use star configuration for grounds and power supplies.
Thanks for the tip larryd, the relay board is being powered exactly as in your picture. I forgot to remove the GND from the relay board in the EDA diagram and the jumper is not represented there, but you can see it in the fritz diagram.
I didn't understand what you mean by using star configuration for grounds and power supplies. Do you mean all the power and gnd to go individually to the breadboard? If so, they are wired that way I just simplified in the fritz diagram. It is more accurate to look at the EDA diagram I guess, my bad.
DanielCabaceira:
So one pull up on each SDA and SCL segment like in this example?
Both between Uno-RTC and RTC-LCD? For a total of 4 pull up resistors?
larryd:
It’s more accurate to look at a correct drawing
True. Attached is the correct drawing, I hope it can give you the right perspective now.
I believe I have the star power connections converging in the breadboard, is this correct? Thank you.
blh64:
No, just one on SCL and one on SDA - total = 2.
Got it, I will update as soon as I make the alterations. Thanks!