Chat freely about anything...

User avatar
By poida97
#66910 After hours of wasted time I realised that I was working with a BMP280 instead of a BME280. The ebay seller that I purchased from sent the wrong sensor (the board is labelled GY-BME/P280 as it suits either sensor).

Use the Sparkfun "I2C_ReadAllData.ino" example to confirm whether your sensor returns 0x58 (BMP) or 0x60 (BME).
https://learn.sparkfun.com/tutorials/sp ... okup-guide
User avatar
By Riaz Ahmed
#67262 Hi, I am using Logoele LGAQS-HT01 (CCS811 and SI7021) with Wemos. Using the Wire.begin(sda, scl) it was possible to get values from CCS811. However the SI7021 gives odd values. I think it has to do with WIre.begin(sda, scl) for CCS811 and Wire.begin() for SI7021 as it was in its original Basic Reading program. I am attaching my code. Please help.
Code: Select all/***************************************************
  This is an example that uses also the CCS811 digital TVOC/eCO2 Sensor by CCMOSS/AMS
  http://www.ccmoss.com/gas-sensors#CCS811 in addition to Si7021 temp humidity sensor.
  It uses Wire.begin library so as to indicate to microcontroller the pins of sda and scl.
  Updated: March 28, 2017
 
  The sensor uses I2C protocol to communicate, and requires 2 pins - SDA and SCL
  Another GPIO is also required to assert the WAKE pin for communication. this
  pin is passed by an argument in the begin function.
  A breakout board is available: https://github.com/AKstudios/CCS811-Breakout
  The ADDR pin on the sensor can be connected to VCC to set the address as 0x5A.
  The ADDR pin on the sensor can be connected to GND to set the address as 0x5B.
  Written by Akram Ali from AKstudios (www.akstudios.com)
  GitHub: https://github.com/AKstudios/
 ****************************************************/

#include <CCS811.h>
#include "SparkFun_Si7021_Breakout_Library.h"
#include <Wire.h>
#define ADDR      0x5A
//#define ADDR      0x5B
#define WAKE_PIN  4

// SI7021 I2C address is 0x40(64)
#define si7021Addr 0x40

CCS811 sensor;

float humidity = 0;
float tempf = 0;


void setup()
{
//CO2 TVOC CCS811 setup
  Wire.begin(D2, D1);
  Serial.begin(9600);
  Serial.println("CCS811 test");
  if(!sensor.begin(uint8_t(ADDR), uint8_t(WAKE_PIN)))
    Serial.println("Initialization failed.");
delay(3000);


// Humidity Temp SI7021 setup 
//  Wire.begin(D2,D1);
//      Serial.begin(9600);
  Wire.beginTransmission(si7021Addr);
  Wire.endTransmission();
  delay(3000);


}

void loop()
{
 
// temp humidity part of loop
  unsigned int data[2];
 
  Wire.beginTransmission(si7021Addr);
  //Send humidity measurement command
  Wire.write(0xF5);
  Wire.endTransmission();
  delay(500);
 
  // Request 2 bytes of data
  Wire.requestFrom(si7021Addr, 2);
  // Read 2 bytes of data to get humidity
  if(Wire.available() == 2)
  {
    data[0] = Wire.read();
    data[1] = Wire.read();
   
  }
 
  // Convert the data
  float humidity  = ((data[0] * 256.0) + data[1]);
  humidity = ((125 * humidity) / 65536.0) - 6;
Wire.begin();
  Wire.beginTransmission(si7021Addr);
  // Send temperature measurement command
  Wire.write(0xF3);
  Wire.endTransmission();
  delay(500);
 
  // Request 2 bytes of data
  Wire.requestFrom(si7021Addr, 2);
 
  // Read 2 bytes of data for temperature
  if(Wire.available() == 2)
  {
    data[0] = Wire.read();
    data[1] = Wire.read();
  }
 
  // Convert the data
  float temp  = ((data[0] * 256.0) + data[1]);
  float celsTemp = ((175.72 * temp) / 65536.0) - 46.85;
  float fahrTemp = celsTemp * 1.8 + 32;
 
  // Output data to serial monitor
  Serial.print("Humidity : ");
  Serial.print(humidity);
  Serial.println(" % RH");
  Serial.print("Celsius : ");
  Serial.print(celsTemp);
  Serial.println(" C");
//  Serial.print("Fahrenheit : ");
//  Serial.print(fahrTemp);
//  Serial.println(" F");
  delay(3000);


//sensor.compensate(22.56, 30.73);  // replace with t and rh values from sensor


  sensor.getData();
  Serial.print("CO2 concentration : "); Serial.print(sensor.readCO2()); Serial.println(" ppm");
  Serial.print("TVOC concentration : "); Serial.print(sensor.readTVOC()); Serial.println(" ppb");
  Serial.println();
  delay(3000);

}