ESP8266 constantly crashing when data from the SCD30 sensor is being outputted

  arduino, arduino-esp8266, arduino-ide, c++, esp8266

I am using the ESP8266 to read data from the grove SCD30 sensor.

When I upload the code, the sensor starts off fine, after a few returns from the sensor, the LED on the ESP stops flashing and stays lit.

The output on the serial monitor also stops outputting anything with no error.

#include "SCD30.h"

#if defined(ARDUINO_ARCH_AVR)
#pragma message("Defined architecture for ARDUINO_ARCH_AVR.")
#define SERIAL Serial
#elif defined(ARDUINO_ARCH_SAM)
#pragma message("Defined architecture for ARDUINO_ARCH_SAM.")
#define SERIAL SerialUSB
#elif defined(ARDUINO_ARCH_SAMD)
#pragma message("Defined architecture for ARDUINO_ARCH_SAMD.")
#define SERIAL SerialUSB
#elif defined(ARDUINO_ARCH_STM32F4)
#pragma message("Defined architecture for ARDUINO_ARCH_STM32F4.")
#define SERIAL SerialUSB
#else
#pragma message("Not found any architecture.")
#define SERIAL Serial
#endif
   
void setup() {
  Wire.begin(D4, D5);
  SERIAL.begin(115200);
  Serial.println("SCD30 Raw Data");
  scd30.initialize();
}

void loop() {
  float result[3] = {0};
  if (scd30.isAvailable()) {
    scd30.getCarbonDioxideConcentration(result);
    SERIAL.print("Carbon Dioxide Concentration is: ");
    SERIAL.print(result[0]);
    SERIAL.println(" ppm");
    SERIAL.println(" ");
    SERIAL.print("Temperature = ");
    SERIAL.print(result[1]);
    SERIAL.println(" ℃");
    SERIAL.println(" ");
    SERIAL.print("Humidity = ");
    SERIAL.print(result[2]);
    SERIAL.println(" %");
    SERIAL.println(" ");
    SERIAL.println(" ");
    SERIAL.println(" ");
  }}

The wiring is also not the problem as the sensor is being read at the start, but then crashes

The image shows that the last section of code ran, however, nothing comes after the "Humidity = 38.47 %"

enter image description here

Source: Windows Questions C++

LEAVE A COMMENT