I've made a display for my home made car to display temperatures, pressure, fuel level etc.
It works sometimes, but most of the time the display isn't initialized.
It is a large 4x20 LCD with i2c interface.
The strange thing is that if I have my laptop connected to the Arduino and upload the program again or open serial monitor, the display starts working every time.
But if I trigger a reset with the button on the Arduino it doesn't help.
Why is the reset triggered by serial monitor different from the button on the board?
The power supply is not the problem. It works with a 5 V, 500 mA USB power supply. And in the car it gets its power from a 7 V, 2 A supply.
I see a ribbon cable with 4 wires going to the display. Can seperate all those wires ? The SDA and SCL don't like it to be that close.
A reset via the serial monitor, or a reset via the button is the same. I think there might something else that has influence.
Can you add a delay after Wire.begin() and before you start using the I2C bus. For example 100ms should be enough, so make it 500ms.
What about pullup-resistors for the SDA and SCL ? For testing about 10k is okay, but in a noisy environment it should be 4k7 or a little less. The display and the sensors might already have pullup resistors, you have to calculate the resulting pullup impedance.
Is your MAX31855 compatible with a 5V Arduino ? It is the only device using the SPI ?
Suggestion : You could try a OLED display. That LCD display will always look cheap, but you can make a OLED display look awesome. But I don't know if they can be that big....
I haven't used the LiquidCrystal_I2C library, but the constructor call looks weird:
LiquidCrystal_I2C lcd(0x27 , 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
For most Arduino boards, pins 0, 1 are used by the Serial object and pins 2,3 are for external interrupts. In most examples I've seen for I2C use, the constructor is:
LiquidCrystal_I2C lcd(0x27 , 16, 4); // Set the LCD I2C address
which sets the slave/master address and the column/row count. Have you tried the simpler constructor?
The ribbon cable is from the testing. Now it is about 50 cm of round cable with 6 conductors, but I guess the problem is the same.
I'm using 4,7 k pullup resistors. Dont know if the display have internal too.
I aslo have a slave arduino communicating over i2c, can that affect things? I don't think so since that is after the display initialization. That communication works great by the way, and it is with 2 meter of the same cable (6 conductors)
With a good cable (that has less coupling between SDA and SCL) you can get 2 meters with I2C.
With just a bunch of loose wires you can get more. If I remember it right, someone could do 5 meters with slow I2C. But I would not even try that. I think your cables are one of the problems.
An Arduino as i2c slave is only active when it has been addressed. But the 2 meters cable to the slave will hurt the whole I2C bus.
You might use the i2c slave in a way that it starts sending data to the master. That could destroy the I2C communication.
When you use the slave only as slave, with onRequest and onReceive, it is slower, but no chance for collision.
I'll do that. The external power supply is an ordinary switched module (cheap ebay LM2596) set to 7 V and connected to Vin.
The external power is connected when I get it to work with the "serial monitor trigger". I can then disconnect the laptop and it keeps on working fine.
I tried resetting the board with the button while connected to the laptop, thinking that the applied USB power should help. But it didn't.
Try moving lcd.clear() to immediately after lcd.begin().
I looked at some of my code (but it's a 16x2 display, not 20x4), and that's how I have it. I'm using the same LCD library.