ESP32-Paxcounter
ESP32-Paxcounter copied to clipboard
Add C02 Sensor as sensor 2 (C02 Ampel) // how to include a custom sensor
As an example of "how to include a custom sensor" I will use an scd30 C02 sensor https://github.com/sparkfun/SparkFun_SCD30_Arduino_Library https://www.sensirion.com/de/umweltsensoren/kohlendioxidsensor/kohlendioxidsensoren-scd30/ https://www.sparkfun.com/products/15112
sensor is in parallel to the dispaly on i2c bus with address 0x61
-
in sensor.cpp
- include scd30-master lib from sparkFun
- in function void sensor_init(void) put one time inti code
- in function uint8_t *sensor_read(uint8_t sensor) -> case 2: read our sensor
-
in payload.cpp -include sensor.h
-
in paxcounter.conf (define are still in use in some other parts of the code)
- #define HAS_SENSOR_1 1
- #define HAS_SENSOR_2 1
- #define HAS_SENSOR_3 0
-
change js parser
- I use payload encoder: 2=Packed
if (port === 11) {
// scd30 sensor data
return decode(bytes, [uint16, ufloat, ufloat], ['C02', 'temp', 'humidity']); } return decoded; */
- I use payload encoder: 2=Packed
if (port === 11) {
// scd30 sensor data