MOD-ENV with the ESP32-POE-IND

Started by mavenpioneer10, January 11, 2025, 03:12:24 AM

Previous topic - Next topic

mavenpioneer10

I am just getting into the world of ESP32 and received my ESP32-POE-IND along with the MOD-ENV sensor. I don't see any samples for the MOD-ENV on their github. I am able to flash it with their sample of the BME280 sketch and get the temperature, pressure, altitude, and humidity readings but I am unsure how to get the information from the CCS811B sensor.

Does anyone have an example sketch they could share and/or provide some guidance on how I could of figured this out from the documents olimex does link to on their product page?

I tried under the "software" section but that just goes to a pdf of how to install the ESP32 board in arduino ide.


LubOlimex

In Arduino install the libraries suitable for MOD-ENB from adafruit (Sketch -> Inlcude Libarary -> Manage Libraries):

- adafruit ccs811

- adafruit bme280 library

Then use the code we provide for MOD-ENV as basis and modify it to fit the ESP32-POE (the code was made for AVR boards but should easily work with ESP32-POE):

/**************************************************************************
 *  This demo is based on two examples provided by Adafruit Industries:
 *  Adafruit CCS811 Library v1.0.2 (CCS811_test example)
 *  Adafruit BME280 Library v2.0.1 (bme280test example)
 *
 * These examples are combined and modified
 * to work for Olimex board MOD-ENV rev.B:
 * https://www.olimex.com/Products/Modules/Sensors/MOD-ENV/
 * Below you can read the header comments of the 2 examples:
 ***************************************************************************
  This is a library for the CCS811 air

  This sketch reads the sensor

  Designed specifically to work with the Adafruit CCS811 breakout
  ----> http://www.adafruit.com/products/3566

  These sensors use I2C to communicate. The device's I2C address is 0x5A

  Adafruit invests time and resources providing this open source code,
  please support Adafruit andopen-source hardware by purchasing products
  from Adafruit!

  Written by Dean Miller for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
***************************************************************************
  This is a library for the BME280 humidity, temperature & pressure sensor

  Designed specifically to work with the Adafruit BME280 Breakout
  ----> http://www.adafruit.com/products/2650

  These sensors use I2C or SPI to communicate, 2 or 4 pins are required
  to interface. The device's I2C address is either 0x76 or 0x77.

  Adafruit invests time and resources providing this open source code,
  please support Adafruit andopen-source hardware by purchasing products
  from Adafruit!

  Written by Limor Fried & Kevin Townsend for Adafruit Industries.
  BSD license, all text above must be included in any redistribution
  See the LICENSE file for details.
 **************************************************************************/

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_CCS811.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_CCS811 ccs;
Adafruit_BME280 bme; // I2C

//#define BME_SCK 13
//#define BME_MISO 12
//#define BME_MOSI 11
//#define BME_CS 10
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI

void print_CCS811_Values()
{
  if(ccs.available())
  {
    if(!ccs.readData())
    {
      Serial.print("CO2: ");
      Serial.print(ccs.geteCO2());
      Serial.print(" ppm\nTVOC: ");
      Serial.println(ccs.getTVOC());
    }
    else
      Serial.println("ERROR!");
  }
}

void print_BME280_Values()
{
    Serial.print("Temperature = ");
    Serial.print(bme.readTemperature());
    Serial.println(" *C");

    Serial.print("Pressure = ");

    Serial.print(bme.readPressure() / 100.0F);
    Serial.println(" hPa");

    Serial.print("Approx. Altitude = ");
    Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
    Serial.println(" m");

    Serial.print("Humidity = ");
    Serial.print(bme.readHumidity());
    Serial.println(" %");
}

void setup()
{
#ifdef  ARDUINO_AVR_OLIMEXINO_32U4
  //power pin on the UEXT (D8) set as low output (only for Olimexino-32U4)
  pinMode (8, OUTPUT);
  digitalWrite (8, LOW);
#endif
  Serial.begin(9600);
  while(!Serial);    // time to get serial running
  Serial.println(F("CCS811 & BME280 initializing..."));

  unsigned status;

  // default settings
  status = bme.begin(); 
  // You can also pass in a Wire library object like &Wire2
  // status = bme.begin(0x76, &Wire2)
  if (!status)
  {
    Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
    Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16);
    Serial.print("        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
    Serial.print("  ID of 0x56-0x58 represents a BMP 280,\n");
    Serial.print("        ID of 0x60 represents a BME 280.\n");
    Serial.print("        ID of 0x61 represents a BME 680.\n");
    while (1);
  }

  status = ccs.begin();
  if(!status)
  {
    Serial.println("Failed to start sensor! Please check your wiring.");
    while(1);
  }
  // Wait for the sensor to be ready
  while(!ccs.available());

  Serial.println(F("CCS811 & BME280 initialized!\n"));
}

void loop()
{
  print_CCS811_Values ();
  print_BME280_Values ();

  Serial.println();
  delay(1000);
}

Technical support and documentation manager at Olimex