Skip to content

Commit f3b64a2

Browse files
committed
add new sensor info
1 parent 4bca971 commit f3b64a2

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

sense_env.h

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ Average<float> avg_a(20);
1414
// SHT21
1515
// HTU21D
1616
//
17-
// BMP280
17+
// BMP280 - !reads 40k alt when offline, 0 psi, 0 temp
1818
// BME280
19-
// CS811
19+
// CS811 - CO2
2020
// TSL2561
2121
// BH1750 https://github.com/claws/BH1750
2222
// APDS9960
2323
// GP2Y
2424
// PM Dust sensors https://github.com/avaldebe/PMserial
2525
// MPU6050
2626
// PCF8591
27-
// scd4x C02 sensor
27+
// SCD4x CO2 sensor
2828
// VEML6070 // UV
29+
// SI7021
30+
// AHTx0 - T/H
2931

3032
// NOT IMPLEMENTED @TODO
3133
// HMC5883L
@@ -34,6 +36,10 @@ Average<float> avg_a(20);
3436
// INA219
3537
// MCP4725
3638
// MCP3421
39+
// SGP30 - tvoc
40+
// SGP40 - tvoc
41+
// SGP41 - tvoc
42+
// ENS160 - CO2
3743

3844
// BUGS
3945
// sensors do not reinit is they drop out, add heathcheck()
@@ -48,15 +54,20 @@ Average<float> avg_a(20);
4854
//MOTION
4955
#define MPU6050 // MPU 6050 GY521 3axis gyro/accel
5056
#define HMC5883L // NI Honeywell HMC5883L
51-
57+
#define MLX90393 // 3 axis magnetometer
5258

5359
// TEMP/HUMIDITY/GAS
5460
#define SI7021
61+
5562
#define AHTX0
5663

64+
// Sensiron
5765
#define USESHT31 // SHT31 Temp/Humidity
5866
#define USESHT21 // SHT21 / HTU21D Temp/Humidity
5967

68+
69+
// BOSCH
70+
6071
// #define USEBMP180 // BMP180 Temp/Pressure/Altitude (replaces BMP085) https://www.adafruit.com/product/1603
6172
/*
6273
Vin: 3 to 5VDC
@@ -66,7 +77,6 @@ Up to 0.03hPa / 0.25m resolution
6677
-40 to +85°C operational range, +-2°C temperature accuracy
6778
This board/chip uses I2C 7-bit address 0x77.
6879
*/
69-
7080
#define USEBMP280 // BMP280 Temp/Pressure/Altitude (upgrade for BMP085/BMP180/BMP183)
7181
// #define USEBME280 // BME280 Humidity/Pressure/Altitude
7282
// Pressure: 300...1100 hPa
@@ -137,7 +147,6 @@ Interface: I2C
137147
#define MAX9814 // MAX9814 Auto GC amplifier
138148
#define MAX4466 // MAX4466 Adj GC amplifier
139149

140-
141150
// Energy
142151
#define INA219 // INA219 current sense
143152

@@ -147,16 +156,20 @@ Interface: I2C
147156
// #define PCF8591 // PCF8591 io expander
148157

149158

159+
// ADDRESSES
160+
150161
// 0x23 0x46 BH1750
151-
// 0x38 0x70
152-
// 0x39 0x72 APDS9960 / TSL2561
162+
// 0x38 0x70 VEML6070 / AHTx0
163+
// 0x39 0x72 APDS9960 / TSL2561 / VEML6070 / AHTx0
153164
// 0x3C 0x78
154165
// 0x44 0x88
155166
// 0x48 0x90
156167
// 0x5A 0xB4 CS811
157168
// 0x62 0xC4 SCD4X
158169
// 0x68 0xD0
159170
// 0x76 0xEC
171+
// 0x77 0xEE
172+
// 0x0D 0x1A MLX90393
160173

161174
/*
162175
#ifdef ENV_TEMPLATE
@@ -766,7 +779,7 @@ bool init_apds(){
766779
}
767780

768781
void init_apds_color(){
769-
//enable color sensign mode
782+
//enable color sensing mode
770783
apds.enableColor(true);
771784
}
772785

@@ -806,11 +819,11 @@ String get_apds_gesture(){
806819
}
807820

808821
void print_apds_color(){
809-
uint16_t r, g, b, c;
810-
822+
uint16_t r, g, b, c, cnt;
811823
//wait for color data to be ready
812-
while(!apds.colorDataReady()){
824+
while(!apds.colorDataReady() && cnt <100){
813825
delay(5);
826+
cnt++;
814827
}
815828

816829
//get the data and print the different channels
@@ -826,12 +839,15 @@ void print_apds_color(){
826839

827840
Logger.print(" clear: ");
828841
Logger.println(c);
829-
Logger.println();
842+
Logger.println();
830843
}
831844

832845
float get_apds_color(uint8_t channel = 0){
833846
// print_apds_color();
834847
uint16_t r, g, b, c;
848+
while(!apds.colorDataReady()){
849+
delay(5);
850+
}
835851
if(!apds.colorDataReady()) return 0;
836852
apds.getColorData(&r, &g, &b, &c);
837853
if(channel == 0) return r;
@@ -910,11 +926,13 @@ Adafruit_SHT31 sht31 = Adafruit_SHT31();
910926
#ifdef USEBMP280
911927
#include <Adafruit_BMP280.h>
912928
Adafruit_BMP280 bmp; // I2C
929+
// #define BMP280_ADDRESS (0x77) /**< The default I2C address for the sensor. */
930+
// #define BMP280_ADDRESS_ALT (0x76)
913931
#endif
914932

915933
#ifdef USEBMP280
916934
void init_bmp280(){
917-
if (!bmp.begin(BMP280_ADDRESS_ALT)) {
935+
if (!bmp.begin(BMP280_ADDRESS)) {
918936
Logger.println(F("[ERROR] BMP280 init FAILED"));
919937
}
920938
else Logger.println(F("[ENV] BMP280 is ACTIVE"));
@@ -1355,6 +1373,8 @@ float get_bmp180(uint8_t channel = 0){
13551373

13561374

13571375
#ifdef AHTX0
1376+
// #define AHTX0_I2CADDR_DEFAULT 0x38 ///< AHT default i2c address
1377+
// #define AHTX0_I2CADDR_ALTERNATE 0x39 ///< AHT alternate i2c address
13581378
#include <Adafruit_AHTX0.h>
13591379
Adafruit_AHTX0 aht;
13601380

0 commit comments

Comments
 (0)