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
Explore... Chat... Share...
/***************************************************
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);
}
It takes about 20-25 seconds for home assistant c[…]
I tried to upgrade tof my sonoff basic R2 with the[…]
a problem Perhaps you want to define "Probl[…]
Rebooting your router will not give you a faster I[…]
There are no other notifications from esptool.py i[…]
Using the Arduino IDE, you'll learn how to set up […]
In this project, you will post to Twitter using an[…]
In this project, we will build a water level contr[…]
I guess I'm late, but I had the same problem and f[…]
Last night I received my first D1 Minis for a lear[…]
Although I am aware that this is an old post, I fe[…]