I designed a system that gets the Temperature with ds18b20 and shows it on LCD using PC8574T I2C module, and then if any errors happen, It sends an alert to my phone with sim800l,
my problem is that when I start my device, the whole mega 2560 freezes, and the time of freezing varies from the first 30 seconds to 15 hours from starting, and everything will be good after a hard-restart.
Most of the freezings happen when the system wants to send an alert message with sim800l, Although some of them happen in the normal situation. This program without LCD i2c works fine, but due to many problems with natural LCD, I prefer to use the i2c module.
I have read all of the topics about LCD I2C freeze problems and done them, like changing libraries or editing twi.c file but none of them helps me
If anyone knows the answer that solves my problem, I will appreciate that because I tried all of the solutions and still I have this problem.
missdrew:
You need to work out where it freezes, then why it freezes & then we MAY come up with a solution.
And don't you think it would help if you had posted your code and a schematic/wiring diagram?
Thank you for replying to my question
About the freezings, there is no particular place that it freezes it can happen in the normal cycle, incoming messages or outgoing messages, but 90% of them happen when the system is sending message or process incoming messages and after that when it freezes sometimes when the message sent and sometimes when it is sending.
my code is 1700 line so it is the reason that I didn't post it here. but about the code and algorithm :
I use the original liquid crystal I2C library for LCD and "Seeeduino_GPRS" for sim800l.
in the loop at first, the system gets temperature limitations using EEPROM and then get the temperature with ds18b20, after that it checks the temperature to not be higher or lower than the set limit, then checks if there are any incoming messages to change the limitations, and if there's is any errors it sends messages to my phone, there is a relay a siren and a buzzer for times that temperature is high or low, but all of them are isolated throw transistors.
the reason that I chose LCD i2c is :
at first, my system works fine with natural LCD and sim800l and other stuff
then I realize sometimes my LCD shows something like "@##$#%FGDF^$" instead of "Temp: 23.00 C"
after I searched a little I found out the LCD.init() will help and this function is in LCD i2c so I designed my system to work with i2c and now I have these freezing problems