1

I tried to connect two modules that require I2C connection and they won't work at the same time.

I used the Arduino Sensor Kit - Base. This kit does not need any connection, you just have to code to get your desired output. I wanted to display the Air Pressure (BMP280) module values to the 0.96" OLED Display, however, it is refusing to run both the air pressire and the OLED display at the same time. Only running one module (either Air pressure or OLED) at a time makes it work. Does it have something to do with how the I2C connection is wired on the board?

#include "Arduino_SensorKit.h"

void setup() { // put your setup code here, to run once: Oled.begin(); Oled.setFlipMode(true); Oled.setFont(u8x8_font_7x14B_1x2_r);

Pressure.begin(); }

void loop() { // put your main code here, to run repeatedly: Oled.clear();

Oled.setCursor(0, 10); Oled.print("Temp: "); Oled.print(Pressure.readTemperature()); Oled.print(" C"); Oled.setCursor(0, 20); Oled.print("Pres: "); Oled.print(Pressure.readPressure()); Oled.print(" Pa"); Oled.setCursor(0, 30); Oled.print("Alti: "); Oled.print(Pressure.readAltitude()); Oled.print(" m");

delay(1000); }

What I did:

  1. Test to see if Air Pressure will still work while both Air Pressure and OLED is connected by using Serial.begin(). Now I know that only the OLED does not work when both modules are connected.
  2. Changed order of initialization. Same result: Air Pressure works but not OLED
fireblazer10
  • 111
  • 1
  • 10
  • "it is refusing to do so" means what? It's printing nothing to the OLED? It's printing things but getting the values wrong? Please be more specific. – Majenko Jan 20 '21 at 15:21
  • it has nothing to do with how the I2C connection is wired on the Base shield. run the I2C scanner sketch to see the devices I2C addresses – Juraj Jan 20 '21 at 15:45
  • @Majenko The OLED is not working at all. Air pressure works (tested with Serial.print()) – fireblazer10 Jan 20 '21 at 15:56
  • You tested the pressure using Serial.print() while the OLED code was there? – Majenko Jan 20 '21 at 15:58
  • @Juraj The OLED has the address 0x3C and the Air Pressure has the address 0x77. Was also able to confirm it on their site: wiki.seeedstudio.com/I2C_And_I2C_Address_of_Seeed_Product/ – fireblazer10 Jan 20 '21 at 15:59
  • @Majenko Yes I did – fireblazer10 Jan 20 '21 at 16:00
  • try to swap the initialization order – Juraj Jan 20 '21 at 17:57
  • 1
    @Juraj Still the same output. OLED won't work :( – fireblazer10 Jan 21 '21 at 01:40
  • Perhaps it is something simple like: If you print the float pressure value (like 920.2773), the OLED line might overflow and cause and error/reset in the OLED lib. Did you try to print only one value without any prefixed text? Best would be to round the value before printing ;-) – Peter Paul Kiefer Jan 21 '21 at 10:06
  • @PeterPaulKiefer Yes, I tried to only print the letter "T" at the start of the loop (both air pressure and OLED are initialized) and the OLED still isn't working :( – fireblazer10 Jan 21 '21 at 11:56
  • Just for my understanding: You tried to print only the letter "T" and nothing else after that. When the pressure module is initialized the OLED does not display the "T" and when the Pressure Module is not initialized, the OLED shows the "T". – Peter Paul Kiefer Jan 21 '21 at 12:27
  • I've looked into the u8g2 lib that is used for the OLEAD. And I've found a possible issue with the constructor signature of this lib. But it could be a typo in the documentation. Later this day, I'll try to find the implementation and if it is an error I will report it with the resp. projects. It might not be you probleme here, as Olead can not work if this is really an error. But I may find an explanation while investigating the code. – Peter Paul Kiefer Jan 21 '21 at 12:28
  • I've also read that the Oled lib uses high speed I2C and that could be in conflict with the low speed Pressure I2C. Sadly, I forgott the reference. I'll have to look into the libs code. ;-) – Peter Paul Kiefer Jan 21 '21 at 12:33
  • @PeterPaulKiefer, regarding the I2C speed. I tested a similar OLED clone on the oscilloscope just now at 352kHZ, which would indicate it likely operates in fast I2C mode (up to 400kHz). The datasheet for the BMP280 indicates it is compatible with standard, fast or high speed I2C. – RowanP Jan 24 '21 at 13:23
  • @fireblazer10, Juraj suggested (Jan 20) running an I2C Scanner sketch to see which devices it can see on your I2C bus. Did you get a chance to do that? An example is https://forum.arduino.cc/index.php?topic=197360. This will check addresses (and verify the information you found on the Seeed Studio website) and frequency compatability. – RowanP Jan 24 '21 at 13:40
  • 2
    @RowanP Thank you for clearifying and for reminding me of what I what to do last evening. I completely forgott :-(. The BMP280 and Oled speed capabilities can be the same but as the Pressure lib and the Oled lib both use the Wire lib when they initialize, there may be a side effect if both specify different speeds. It is just a guess. Perhaps the Wire lib gets confused. – Peter Paul Kiefer Jan 24 '21 at 13:41
  • @RowanP I apologize I honestly have forgotten about this but yes I did: 0x3C for the OLED and 0x77 for the pressure sensor – fireblazer10 Jan 25 '21 at 07:09
  • @PeterPaulKiefer Oh, that's a shame :(( I guess I would have to leave this project for a bit. I'll try other OLED libraries for a start and see if it changes anything – fireblazer10 Jan 25 '21 at 07:12
  • @fireblazer10, thanks for confirming the I2C scanner results. I put some general comments about I2C debugging on another question earlier today which may help. It may be difficult to make more progress without access to some additional test equipment. – RowanP Jan 25 '21 at 07:41
  • 2
    I opend an issue on github. I think there is a problem with the Oled constructor. https://github.com/arduino-libraries/Arduino_SensorKit/issues/15 If i'm right, the clock of the 'I2C bus resets the OLED. If Pressure is active the I2C clock is active. -> reset the Oled. Tada. ;-) – Peter Paul Kiefer Jan 25 '21 at 19:04

1 Answers1

3

About two weeks ago there was a change in the Arduino_SensorKit Library that introduced an error with the instanciation of the Oled object.

I found the error in the release (v1.0.6) of the library. The previous release (v1.0.5) could cause another issue, as it uses a software I2C. I doubt the hardwired sensores are connected with the correct pins. But I have no hardware, so I can not check this.

I propose a workaround to see, if the identified issue caused your observations.

#include "Arduino_SensorKit.h"

U8X8_SSD1306_128X64_NONAME_HW_I2C Oled2; // if the line above does not work // comment it and uncomment the following line. // U8X8_SSD1306_128X64_NONAME_HW_I2C Oled2(U8X8_PIN_NONE);

void setup() { Oled2.begin(); Oled2.setFlipMode(true); Oled2.setFont(u8x8_font_7x14B_1x2_r);

Pressure.begin(); }

void loop() { Oled2.clear();

Oled2.setCursor(0, 10); Oled2.print("Temp: "); Oled2.print(Pressure.readTemperature()); Oled2.print(" C");

delay(1000); }

Could you please try out and report your experience. If it would work, I can support the fixing of the issue.

Peter Paul Kiefer
  • 1,883
  • 8
  • 10
  • It works! OLED just keeps blinking but it shows the output now! The blinking could be fixed by changing Oled2.clear() to Oled2.refreshDisplay(). Thank you so much! – fireblazer10 Jan 28 '21 at 13:19
  • 1
    You're welcome. Meanwhile I got feedback from marqdevx. He is about to release a new version of the lib. I think as soon as it is available, this workaround is not necessary furthermore (<- don'T know if this is an english word. But it sounds good ;-) ). As soon as the new revision is available I'll edit my answer and add your "blinking" solution too. Cheers! – Peter Paul Kiefer Jan 28 '21 at 13:30
  • FWIW, I had the same issue with the latest version at the time - 1.0.10, and this fixed it. I have no idea what this does but it fixed it. – davetron5000 Oct 04 '23 at 14:08
  • @davetron5000 Thank you for this comment. I completely forgot about this topic. I just remember that I waited for the new release and it had last longer then I expected. And then the topic get's out of my view ;-). I simply forgott it. In the very Moment I have not the time to look after it. Perhaps if I find some time in November I check what happend with the fix. It's in my calender. – Peter Paul Kiefer Oct 07 '23 at 18:34