Skip to content

Commit f15f8b8

Browse files
committed
2 parents dffa793 + 41f6887 commit f15f8b8

File tree

3 files changed

+106
-27
lines changed

3 files changed

+106
-27
lines changed

‎include_sensor_libraries.h‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include<Average.h>// https:github.com/MajenkoLibraries/Average
2+
3+
4+
#include<log.h>
5+
#include<Syslog.h>//https://github.com/arcao/Syslog.git
6+
#include<log_syslog.h>
7+
#include<StreamUtils.h>// https://github.com/bblanchon/ArduinoStreamUtils.git
8+
9+
10+
#include<Genv_asset.h>
11+
12+
#include<Wire.h>
13+
14+
#include<OneWire.h>// https://github.com/
15+
#include<DallasTemperature.h>// https://github.com/
16+
#include<SoftwareSerial.h>// https://github.com/
17+
#include<PMserial.h>// https://github.com/avaldebe/PMserial
18+
#include<Adafruit_VEML6070.h>// https://github.com/adafruit/Adafruit_VEML6070
19+
#include<Adafruit_PCF8591.h>// https://github.com/adafruit/Adafruit_PCF8591
20+
#include<Adafruit_INA219.h>// https://github.com/adafruit/Adafruit_INA219
21+
#include<Adafruit_MPU6050.h>// https://github.com/adafruit/Adafruit_MPU6050
22+
#include<Adafruit_Sensor.h>// https://github.com/adafruit/Adafruit_Sensor
23+
#include<Adafruit_APDS9960.h>// https://github.com/adafruit/Adafruit_APDS9960
24+
#include<Adafruit_SHT31.h>// https://github.com/adafruit/Adafruit_SHT31
25+
#include<Adafruit_BMP280.h>// https://github.com/adafruit/Adafruit_BMP280
26+
#include<Adafruit_CCS811.h>// https://github.com/adafruit/Adafruit_CCS811
27+
#include<Adafruit_BMP085.h.h>// https://github.com/adafruit/Adafruit_BMP085
28+
#include<BH1750.h>// https://github.com/claws/BH1750
29+
#include<GP2YDustSensor.h>// https://github.com/
30+
#include<LM75A.h>// https://github.com/QuentinCG/Arduino-LM75A-Temperature-Sensor-Library
31+
#include<HTU21D.h>// https://github.com/adafruit/Adafruit_HTU21DF_Library
32+
#include<SensirionI2CScd4x.h>// https://github.com/
33+
34+
// #include <hp_BH1750.h> //inlude the library
35+
//
36+
//
37+
[env:esp32doit-devkit-v1]
38+
platform=espressif32
39+
board=esp32doit-devkit-v1
40+
framework=arduino
41+
lib_deps=
42+
avaldebe/PMSerial@^1.2.0
43+
https://github.com/adafruit/Adafruit_INA219
44+
https://github.com/adafruit/Adafruit_MPU6050
45+
https://github.com/avaldebe/PMserial
46+
https://github.com/adafruit/Adafruit_VEML6070
47+
https://github.com/adafruit/Adafruit_PCF8591
48+
https://github.com/adafruit/Adafruit_INA219
49+
https://github.com/adafruit/Adafruit_Sensor
50+
https://github.com/adafruit/Adafruit_APDS9960
51+
https://github.com/adafruit/Adafruit_SHT31
52+
https://github.com/adafruit/Adafruit_BMP280
53+
https://github.com/adafruit/Adafruit_CCS811
54+
; https://github.com/adafruit/Adafruit_HTU21DF_Library
55+
; https://github.com/RobTillaart/SHT2x
56+
https://github.com/enjoyneering/HTU21D
57+
https://github.com/claws/BH1750
58+
lib_extra_dirs= /Users/alverson/projects/microcontrollers/dev/libraries

‎oled_i2c.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include<Adafruit_SSD1306.h>
99

1010
// #define SH1106_128_64
11-
#defineSCREEN_WIDTH64 // OLED display width, in pixels
12-
#defineSCREEN_HEIGHT48 // OLED display height, in pixels
11+
#defineSCREEN_WIDTH32 // OLED display width, in pixels
12+
#defineSCREEN_HEIGHT128 // OLED display height, in pixels
1313

1414
#defineOLED_RESET -1
1515
// Adafruit_SSD1306 lcd(OLED_RESET);

‎sense_env.h‎

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,44 +1237,65 @@ float getVoltage(){
12371237
SensirionI2CScd4x scd4x;
12381238
// CO2 0x62
12391239
voidinit_scd4x(){
1240-
bool ret = false;
1241-
Wire.begin();
1240+
uint16_t error;
1241+
char errorMessage[256];
1242+
Wire.begin();
12421243
scd4x.begin(Wire);
12431244

12441245
// stop potentially previously started measurement
1245-
ret != scd4x.stopPeriodicMeasurement();
1246-
// if (ret){
1247-
// Serial.print("Error trying to execute stopPeriodicMeasurement(): ");
1248-
// errorToString(error, errorMessage, 256);
1249-
// Serial.println(errorMessage);
1250-
// } else ret = true;
1251-
1252-
ret != scd4x.startPeriodicMeasurement();
1253-
1254-
if(!ret){
1246+
error = scd4x.stopPeriodicMeasurement();
1247+
if (error){
1248+
Serial.print("Error trying to execute stopPeriodicMeasurement(): ");
1249+
errorToString(error, errorMessage, 256);
1250+
Serial.println(errorMessage);
1251+
} else error = true;
1252+
1253+
error = scd4x.startPeriodicMeasurement();
1254+
1255+
if(error){
1256+
Serial.print("Error trying to execute startPeriodicMeasurement(): ");
1257+
errorToString(error, errorMessage, 256);
1258+
Serial.println(errorMessage);
12551259
Logger.println("[ERROR] SCD4X init FAILED");
12561260
}
12571261
else Logger.println("[ENV] SCD4X is ACTIVE");
12581262
// return ret;
12591263
}
12601264

1261-
voidprint_scd4x(){
1265+
floatget_scd4x(uint8_t channel = 0,bool update=true){
1266+
staticuint16_t scd4x_co2;
1267+
staticfloat scd4x_temperature;
1268+
staticfloat scd4x_humidity;
1269+
staticuint16_t scd4x_error = 0;
1270+
if(update){
1271+
char errorMessage[256];
1272+
scd4x_error = scd4x.readMeasurement(scd4x_co2, scd4x_temperature, scd4x_humidity);
1273+
if(scd4x_error){
1274+
Serial.print("Error trying to execute readMeasurement(): ");
1275+
errorToString(scd4x_error, errorMessage, 256);
1276+
Serial.println(errorMessage);
1277+
}
1278+
}
1279+
if(channel == 0) return scd4x_co2;
1280+
if(channel == 1) return scd4x_temperature;
1281+
if(channel == 2) return scd4x_humidity;
1282+
if(channel == 3) return scd4x_error;
1283+
return0;
12621284
}
12631285

1264-
floatget_scd4x(uint8_t channel = 0){
1265-
uint16_t co2;
1266-
float temperature;
1267-
float humidity;
1268-
uint16_t error;
1269-
1270-
error = scd4x.readMeasurement(co2, temperature, humidity);
1286+
voidprint_scd4x(){
12711287

1272-
// print_env();
1273-
if(channel == 0) return co2;
1274-
if(channel == 1) return temperature;
1275-
if(channel == 2) return humidity;
1276-
return0;
1288+
Serial.print(__FUNCTION__);
1289+
Serial.print(" co2: ");
1290+
Serial.print(get_scd4x(0));
1291+
Serial.print(" temp: ");
1292+
Serial.print(get_scd4x(1,false));
1293+
Serial.print(" humidity: ");
1294+
Serial.print(get_scd4x(2,false));
1295+
Serial.print(" error: ");
1296+
Serial.println();
12771297
}
1298+
12781299
#endif
12791300

12801301

0 commit comments

Comments
(0)