Closed wilhelmzeuschner closed 5 years ago
Basically it should work. Maybe the activated display disturbs the other two sensors.
You could change "cs" pin and check whether the data from the sensor is correct (of course the display will not work). If this is the case, then there is a hardware problem, not a software problem.
@olikraus I found my mistake, it had absolutely nothing to do with your code:
U8G2_ST7565_ERC12864_ALT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ SS, /* dc=*/ D3, /* reset=*/ D2);
D2 is SDA, so it makes perfect sense that I2C didn't work.
Unfortunately I was testing out which pins I didn't need to connect to the display and one of them is the CS / SS pin which can be tied to GND directly if no other SPI device is on the bus. That's why I didn't find it earlier...
Sorry for bothering you!
:-)
Hardware:
I want to use an LCD display and have successfully tested it. Here's the constructor for my display:
U8G2_ST7565_ERC12864_ALT_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ SS, /* dc=*/ D3, /* reset=*/ D2); // contrast improved version for ERC12864
Additionally I have two I2C devices connected (HTU21D and DS3231). Both work fine when tested separately. As soon as I callu8g2.begin();
the sensors are "broken" and don't return data. If I read the sensor(s) beforeu8g2.begin();
it works fine!I'm quite puzzled since I can't really explain that behavior... Is the u8g2 library somehow interfering with the I2C bus when initializing it?
Here's my complete sketch: