Arduino + oled + sgp30 = CRASH

Hi,

I have a grove beginners kid.
When I read the temperature and humidity sensor (“DHT.h”) and output to the oled screen this works fine. Oled uses i2c with <U8x8lib.h>,

I have also bought a Grove VoC and eCo2 sensor that works with i2c (and cable) that works when printing to the serialoutput with “sgp30.h” ,

However, when I include the Co2 library the oled stops working. How to troubleshoot such a thing?

just fior the record:

The oled is on the grove beginners kid and so is the temperature and humidity sensor. So I quess they are connected by usb?

The co2 sensor is not since I bought it seperately, I have connected it to a i2c grove board plugin thingy

Hello, if you can provide the wiring diagram and the program, this can facilitate the community to help you.

1 Like

Hi,
yes I understand. The wiring I will send in a photo. As you can see all is connected via a print. Only the gas monitor is connected via wire.

The code that shows how it crashed is this.
It prints :

Blockquote DHTxx test!
get ram signal!
woop we are now in the loop
CO2eq C[]

The oled shows a white stripe, meaning it has crashed badly properly
The code I run is bewlo

Blockquote
#include <Arduino.h>
#include “sensirion_common.h” // co2
#include “sgp30.h” // co2
// #include “DHT.h” //humid
#include <U8x8lib.h> // oled

U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);

void setup(void) {
Serial.begin(9600);
Serial.println(“DHTxx test!”);
u8x8.begin();
u8x8.setPowerSave(0);
u8x8.setFlipMode(1);

// co2 code sgp30
s16 err;
u16 scaled_ethanol_signal, scaled_h2_signal;
/* Init module,Reset all baseline,The initialization takes up to around 15 seconds, during which
all APIs measuring IAQ(Indoor air quality ) output will not change.Default value is 400(ppm) for co2,0(ppb) for tvoc*/
while (sgp_probe() != STATUS_OK) {
Serial.println(“SGP failed”);
while (1);
}
/Read H2 and Ethanol signal in the way of blocking/
err = sgp_measure_signals_blocking_read(&scaled_ethanol_signal,
&scaled_h2_signal);
if (err == STATUS_OK) {
Serial.println(“get ram signal!”);
} else {
Serial.println(“error reading signals”);
}
err = sgp_iaq_init();
}

void loop(void) {
Serial.println(“woop we are now in the loop”);

u8x8.setFont(u8x8_font_chroma48medium8_r);
u8x8.setCursor(0,1);
u8x8.print(“Temp:”);
// u8x8.print(temp);
u8x8.print(“C”);
u8x8.setCursor(0,2);
u8x8.print(“Humidity:”);
// u8x8.print(humi);
u8x8.print("%");

s16 err = 0;
u16 tvoc_ppb, co2_eq_ppm;
err = sgp_measure_iaq_blocking_read(&tvoc_ppb, &co2_eq_ppm);
if (err == STATUS_OK) {
Serial.print(“CO2eq Concentration:”);
Serial.print(co2_eq_ppm);
Serial.println(“ppm”);
u8x8.setCursor(0,3);
u8x8.print(“tVOC :”);
u8x8.print(tvoc_ppb);
u8x8.print(“ppb”);
u8x8.setCursor(0,4);
u8x8.print(“Co2eq :”);
u8x8.print(co2_eq_ppm);
u8x8.print(“ppb”);
} else {
Serial.println(“error reading IAQ values\n”);
}

u8x8.refreshDisplay();
delay(1200);
}

so it crashes exactly at the moment the oled is called to print something.
My quess is that both the oled and the gas sensor use I2C and somehow the interfere?
Should I use other code when using I2C or something?

here you can see the oled working fine

so nobody knows why this happens :frowning: Thats dissapointing

This is a Thought , I use the DEV board display like this

//Create a instance of class LSM6DS3 and OLED
LSM6DS3 myIMU(I2C_MODE, 0x6A);      //I2C device address 0x6A  // IMU 
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* clock=*/ PIN_WIRE_SCL, /* data=*/ PIN_WIRE_SDA, /* reset=*/ U8X8_PIN_NONE);
 // OLEDs without Reset of the Display

My best .02 worth
HTH
GL :wink: