I work on an Arduino Mega 2560. I use a humidity/temperature sensor (HTU21DF) and a Serial Oled Screen (DigoleSerialDisp DS160128COLED-46). These two use I2C connection. They have different adress and they are connected in parallel.
My program is for now really simple, I get temperature and humidity by the Adafruit library HTU21DF (Note : I also try with different library than this one) I send it to a Http server by a 3G module and display it on my oled screen.
So, there is the problem : my system works perfectly but then the screen freeze for no reason randomly (it could happen after 1min or 1h of execution).
However, the program still running (the 3G module send data to the cloud each 5 seconds and I can check it from my navigator). And on the navigator, I receive temperature and humidity data correctly.
If I unplugged / replugged my screen, it works again.
If I unplugged my HTU module and remove it from my code, my screen has no displaying problem after few hours of execution.
I also changed my Wire library many times, it doesn't to change anything...
I change all of my devices (I also pass on a Arduino uno), nothing happened...
Could also be a hardware problem.
What is the combined pull-up resistance on your I2C lines.
I know the Mega has 10k resistors, the Uno has none.
If you use cable to connect to the devices, what is the length and what is the total cable capacitance.
Leo..
Based on I2C specs, non of the devices should have pull up resisters. But in real world some devices do have pull up resistors.
Based on I2C specs, you should place the two pull up resistors on the wires yourself.
If your devices do have pull up resisters built onboard, it could be that there are to many on the network. Check your devices. The I2C network is designed for short distance wiring (about 2 meters). If you have a long wire, it could cause problems.
It does not make a difference if the resistors are located on the wires or on the devices.
You should however know the I2C specs of the devices and the total pull-up resistance you have in your circuit.
Wire length is not important. Bus (wire) capacitance is.
Cat-6 wire is 51pf/meter (wire pair).
AFAIK, standard I2C specs <=400pf and <=3mA pull-up (1k6).
If you run clock and ground over different pairs, you could have upto ~7meters (total) length.
I actually have a home lighting system running 24/7, without problems, with ~7meters of Cat-6 between a Mega and two I2C devices.
Leo…
johnwasser:
It could be a programming error but without seeing the programming it will be hard to tell.
[quote author=Archibald
link=msg=2393558 date=1442020077]
There is a lot of information on the internet about the WIRE library “hanging” or “freezing” at times.
Obviously, it’s not a programming error because it’s the screen whose freezing. The program still running (It keep send me data via 3G). And if I unplugged/replugged the screen, data is updating on it again.
Where you have the jumpers from the sensor and the display coming together, can you spread the rows out so you have a vacant row between lines, that is instead of power and data lines being in side by side rows place a blank row between them.
You might have some crosstalk.
Also the humdity sensor breakout is..
so we spun up a breakout board that includes the Filtered version (the white bit of plastic which is a PTFE filter to keep the sensor clean), a 3.3V regulator and I2C level shifting circuitry. This lets you use it safely with any kind of microcontroller with 3.3V-5V power or logic.
The display can pull up to 110mA, not sure what the 5V of the mega is able to supply....
Tom....
TomGeorge:
The display can pull up to 110mA, not sure what the 5V of the mega is able to supply....
Good question.
110mA should be no problem with a 9volt supply on the DC socket, but there is also a shield on top of the Mega.
Not sure if that's drawing power from Vin or from 5volt.
OP could feel the temp of the regulator next to the DC socket.
I still think OP should try two 4k7 pull-up resistors on the I2C bus.
One from 5volt to clock, and one from 5volt to data.
Leo..
Hi,
You symptoms appear to me to be a slowly overheating 5V regulator on the mega board.
With display and G3 and sensor ,I'd say its well and truly on the cards.
The G3 will probably put a heavy load on the 5V when it transmits, so if the regulator is near its maximum limits when just idling, then going into transmit may cause it to drop out of regulation.
Tom....
Not sure where the 5v regulator is on the mega but if you know, place your finger on it after it has been on for a while, or when your display locks up and see if its hot.
You might want to get a regulated 5V power supply and connect power and ground lines to your shield and any other boards from it, of course connecting ground from that to ground on the Mega as well. Distribute power and ground, less will need to come through the Mega which has a limit.
This year I’ve gotten into DC-DC converters. You can drop 12V to 5V and instead of 7V of that being converted to HEAT, most is converted to current. A 3A buck converter can be had for < $2.
If you’re running on batteries, converters should be just about required. :o
"I notice that once the screen freezes, if I unplugged/replugged it, it freeze again later but between 10seconds or 1min this time."
I am not sure if the screen freezes, or the processor stops working. Your code seems not to have a "blink LED function" that would let us know if the processor is still running. Can you add that function so we can tell if the processor is halted or running?