Hi, I bougth some sensor from DFRobot (ENS160 + BME280 Multi-function Environmental Sensor5, SEN0377 Gravity MEMS Gas Sensor and Gravity: IIC Ozone Sensor), on their webpage an their wikipage they have codes for using them, also I have the lilyGO-T-SIM7000G to use it, im new on this so i've been watching videos and reading a book about Arduino Ide also, the code programming, libraries and some other github questions of lilyGO, but im still no able to make the lilyGO make readings (I have tried using the gps and some other functions until now and they have worked, but now when compiling it said like sensor not found), searching more there was a "wire.h" that supposed to work for the readings and that kind of stuff, I assigned the pins and still no readings, then i wrote like de digitalpin and aldo doesnt work, so I don`t know what to really do, also the readings are in I2C, and i have assigned the address that correspond to each sensor and nothing. I was looking if someone has some kind of recommendations on these that could help, i have tried different kind of ways and neither worked.
I have it conected like this.
The original code is:
#include <DFRobot_ENS160.h>
#include "DFRobot_BME280.h"
#define SEA_LEVEL_PRESSURE 1015.0f
DFRobot_ENS160_I2C ENS160(&Wire, /*i2cAddr*/ 0x53);
typedef DFRobot_BME280_IIC BME; // ******** use abbreviations instead of full names ********
BME bme(&Wire, 0x76); // select TwoWire peripheral and set sensor address
// show last sensor operate status
void printLastOperateStatus(BME::eStatus_t eStatus)
{
switch(eStatus) {
case BME::eStatusOK: Serial.println("everything ok"); break;
case BME::eStatusErr: Serial.println("unknow error"); break;
case BME::eStatusErrDeviceNotDetected: Serial.println("device not detected"); break;
case BME::eStatusErrParameter: Serial.println("parameter error"); break;
default: Serial.println("unknow status"); break;
}
}
void setup(void)
{
Serial.begin(115200);
bme.reset();
Serial.println("bme read data test");
while(bme.begin() != BME::eStatusOK) {
Serial.println("bme begin faild");
printLastOperateStatus(bme.lastOperateStatus);
delay(2000);
}
Serial.println("bme begin success");
delay(100);
// Init the sensor
while( NO_ERR != ENS160.begin() ){
Serial.println("Communication with device failed, please check connection");
delay(3000);
}
/**
* Set power mode
* mode Configurable power mode:
* ENS160_SLEEP_MODE: DEEP SLEEP mode (low power standby)
* ENS160_IDLE_MODE: IDLE mode (low-power)
* ENS160_STANDARD_MODE: STANDARD Gas Sensing Modes
*/
ENS160.setPWRMode(ENS160_STANDARD_MODE);
/**
* Users write ambient temperature and relative humidity into ENS160 for calibration and compensation of the measured gas data.
* ambientTemp Compensate the current ambient temperature, float type, unit: C
* relativeHumidity Compensate the current ambient temperature, float type, unit: %rH
*/
ENS160.setTempAndHum(/*temperature=*/bme.getTemperature(), /*humidity=*/bme.getHumidity());
}
void loop()
{
float temp = bme.getTemperature();
uint32_t press = bme.getPressure();
float alti = bme.calAltitude(SEA_LEVEL_PRESSURE, press);
float humi = bme.getHumidity();
Serial.println();
Serial.println("======== start print ========");
Serial.print("temperature (unit Celsius): "); Serial.println(temp);
Serial.print("pressure (unit pa): "); Serial.println(press);
Serial.print("altitude (unit meter): "); Serial.println(alti);
Serial.print("humidity (unit percent): "); Serial.println(humi);
Serial.println("======== end print ========");
/**
* Get the sensor operating status
* Return value: 0-Normal operation,
* 1-Warm-Up phase, first 3 minutes after power-on.
* 2-Initial Start-Up phase, first full hour of operation after initial power-on. Only once in the sensor’s lifetime.
* note: Note that the status will only be stored in the non-volatile memory after an initial 24h of continuous
* operation. If unpowered before conclusion of said period, the ENS160 will resume "Initial Start-up" mode
* after re-powering.
*/
uint8_t Status = ENS160.getENS160Status();
Serial.print("Sensor operating status : ");
Serial.println(Status);
/**
* Get the air quality index
* Return value: 1-Excellent, 2-Good, 3-Moderate, 4-Poor, 5-Unhealthy
*/
uint8_t AQI = ENS160.getAQI();
Serial.print("Air quality index : ");
Serial.println(AQI);
/**
* Get TVOC concentration
* Return value range: 0–65000, unit: ppb
*/
uint16_t TVOC = ENS160.getTVOC();
Serial.print("Concentration of total volatile organic compounds : ");
Serial.print(TVOC);
Serial.println(" ppb");
/**
* Get CO2 equivalent concentration calculated according to the detected data of VOCs and hydrogen (eCO2 – Equivalent CO2)
* Return value range: 400–65000, unit: ppm
* Five levels: Excellent(400 - 600), Good(600 - 800), Moderate(800 - 1000),
* Poor(1000 - 1500), Unhealthy(> 1500)
*/
uint16_t ECO2 = ENS160.getECO2();
Serial.print("Carbon dioxide equivalent concentration : ");
Serial.print(ECO2);
Serial.println(" ppm");
Serial.println();
delay(1000);
}
The one I tried to apply is:
#include <DFRobot_ENS160.h>
#include "DFRobot_BME280.h"
#define SEA_LEVEL_PRESSURE 1015.0f
#define I2C_SDA 21
#define I2C_SCL 22
DFRobot_ENS160_I2C ENS160(&Wire, /*i2cAddr*/ 0x53);
typedef DFRobot_BME280_IIC BME; // ******** use abbreviations instead of full names ********
BME bme(&Wire, 0x76); // select TwoWire peripheral and set sensor address
// show last sensor operate status
void printLastOperateStatus(BME::eStatus_t eStatus)
{
switch(eStatus) {
case BME::eStatusOK: Serial.println("everything ok"); break;
case BME::eStatusErr: Serial.println("unknow error"); break;
case BME::eStatusErrDeviceNotDetected: Serial.println("device not detected"); break;
case BME::eStatusErrParameter: Serial.println("parameter error"); break;
default: Serial.println("unknow status"); break;
}
}
void setup(void)
{
Serial.begin(115200);
bme.reset();
Serial.println("bme read data test");
while(bme.begin() != BME::eStatusOK) {
Serial.println("bme begin faild");
printLastOperateStatus(bme.lastOperateStatus);
delay(2000);
}
Serial.println("bme begin success");
delay(100);
// Init the sensor
while( NO_ERR != ENS160.begin() ){
Serial.println("Communication with device failed, please check connection");
delay(3000);
}
/**
* Set power mode
* mode Configurable power mode:
* ENS160_SLEEP_MODE: DEEP SLEEP mode (low power standby)
* ENS160_IDLE_MODE: IDLE mode (low-power)
* ENS160_STANDARD_MODE: STANDARD Gas Sensing Modes
*/
ENS160.setPWRMode(ENS160_STANDARD_MODE);
/**
* Users write ambient temperature and relative humidity into ENS160 for calibration and compensation of the measured gas data.
* ambientTemp Compensate the current ambient temperature, float type, unit: C
* relativeHumidity Compensate the current ambient temperature, float type, unit: %rH
*/
ENS160.setTempAndHum(/*temperature=*/bme.getTemperature(), /*humidity=*/bme.getHumidity());
}
void loop()
{
float temp = bme.getTemperature();
uint32_t press = bme.getPressure();
float alti = bme.calAltitude(SEA_LEVEL_PRESSURE, press);
float humi = bme.getHumidity();
Serial.println();
Serial.println("======== start print ========");
Serial.print("temperature (unit Celsius): "); Serial.println(temp);
Serial.print("pressure (unit pa): "); Serial.println(press);
Serial.print("altitude (unit meter): "); Serial.println(alti);
Serial.print("humidity (unit percent): "); Serial.println(humi);
Serial.println("======== end print ========");
/**
* Get the sensor operating status
* Return value: 0-Normal operation,
* 1-Warm-Up phase, first 3 minutes after power-on.
* 2-Initial Start-Up phase, first full hour of operation after initial power-on. Only once in the sensor’s lifetime.
* note: Note that the status will only be stored in the non-volatile memory after an initial 24h of continuous
* operation. If unpowered before conclusion of said period, the ENS160 will resume "Initial Start-up" mode
* after re-powering.
*/
uint8_t Status = ENS160.getENS160Status();
Serial.print("Sensor operating status : ");
Serial.println(Status);
/**
* Get the air quality index
* Return value: 1-Excellent, 2-Good, 3-Moderate, 4-Poor, 5-Unhealthy
*/
uint8_t AQI = ENS160.getAQI();
Serial.print("Air quality index : ");
Serial.println(AQI);
/**
* Get TVOC concentration
* Return value range: 0–65000, unit: ppb
*/
uint16_t TVOC = ENS160.getTVOC();
Serial.print("Concentration of total volatile organic compounds : ");
Serial.print(TVOC);
Serial.println(" ppb");
/**
* Get CO2 equivalent concentration calculated according to the detected data of VOCs and hydrogen (eCO2 – Equivalent CO2)
* Return value range: 400–65000, unit: ppm
* Five levels: Excellent(400 - 600), Good(600 - 800), Moderate(800 - 1000),
* Poor(1000 - 1500), Unhealthy(> 1500)
*/
uint16_t ECO2 = ENS160.getECO2();
Serial.print("Carbon dioxide equivalent concentration : ");
Serial.print(ECO2);
Serial.println(" ppm");
Serial.println();
delay(1000);
}
