Skip to content

Commit

Permalink
Merge pull request #163 from kike-canaries/arduino_cli
Browse files Browse the repository at this point in the history
Arduino cli
  • Loading branch information
hpsaturn authored Feb 12, 2023
2 parents 1d95688 + de81c21 commit 8d5b1cf
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 42 deletions.
45 changes: 45 additions & 0 deletions arduino-cli-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# arduino-cli installation on ~/bin:
# curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
# test repo:
# https://github.com/kike-canaries/canairio_sensorlib/

arduino-cli config init

# github libraries support
arduino-cli config set library.enable_unsafe_install true
# dependencies
arduino-cli lib install "Adafruit Unified [email protected]"
arduino-cli lib install "Adafruit BME280 [email protected]"
arduino-cli lib install "Adafruit BMP280 [email protected]"
arduino-cli lib install "Adafruit BME680 [email protected]"
arduino-cli lib install "Adafruit SHT31 [email protected]"
arduino-cli lib install "Adafruit [email protected]"
arduino-cli lib install "Adafruit [email protected]"
arduino-cli lib install "Sensirion [email protected]"
arduino-cli lib install "[email protected]"
arduino-cli lib install "[email protected]"
arduino-cli lib install "[email protected]"
arduino-cli lib install "Sensirion I2C [email protected]"
arduino-cli lib install --git-url https://github.com/paulvha/sps30.git
arduino-cli lib install --git-url https://github.com/enjoyneering/AHTxx.git
arduino-cli lib install --git-url https://github.com/hpsaturn/DHT_nonblocking.git
arduino-cli lib install --git-url https://github.com/jcomas/CM1106_UART.git
arduino-cli lib install --git-url https://github.com/paulvha/SN-GCJA5.git
# target tag:
arduino-cli lib install --git-url https://github.com/kike-canaries/canairio_sensorlib.git#v0.6.4

arduino-cli config set board_manager.additional_urls\
https://arduino.esp8266.com/stable/package_esp8266com_index.json\
https://dl.espressif.com/dl/package_esp32_index.json

arduino-cli core update-index

# esp8266 test
arduino-cli core install esp8266:esp8266
arduino-cli compile --fqbn esp8266:esp8266:nodemcuv2 --build-property "build.extra_flags=-DCORE_DEBUG_LEVEL=0" examples/basic

# esp32 test
#arduino-cli core install esp32:esp32
#arduino-cli compile --fqbn esp32:esp32:ttgo-t7-v14-mini32 --build-property "build.extra_flags=-DCORE_DEBUG_LEVEL=0" examples/basic

2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CanAirIO Air Quality Sensors Library",
"version": "0.6.5",
"version": "0.6.6",
"homepage":"https://canair.io",
"keywords":
[
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=CanAirIO Air Quality Sensors Library
version=0.6.5
version=0.6.6
author=@hpsaturn, CanAirIO project <[email protected]>
maintainer=Antonio Vanegas <[email protected]>
url=https://github.com/kike-canaries/canairio_sensorlib
Expand Down
51 changes: 26 additions & 25 deletions src/Sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void Sensors::loop() {
}

void Sensors::printHumTemp() {
Serial.printf("-->[SLIB] sensorlib \t\t: T:%02.1f, H:%02.1f\n", humi, temp);
Serial.printf("-->[SLIB] sensorlib \t\t: T:%02.1f, H:%02.1f\r\n", humi, temp);
}

/**
Expand Down Expand Up @@ -102,14 +102,14 @@ void Sensors::init(u_int pms_type, int pms_rx, int pms_tx) {
if (CORE_DEBUG_LEVEL >= 3) devmode = true;
#endif
if (devmode) {
Serial.printf("-->[SLIB] CanAirIO SensorsLib\t: v%sr%d\n", CSL_VERSION, CSL_REVISION);
Serial.printf("-->[SLIB] sensorslib devmod\t: %s\n", devmode ? "true" : "false");
Serial.printf("-->[SLIB] CanAirIO SensorsLib\t: v%sr%d\r\n", CSL_VERSION, CSL_REVISION);
Serial.printf("-->[SLIB] sensorslib devmod\t: %s\r\n", devmode ? "true" : "false");
}

Serial.println("-->[SLIB] temperature offset\t: " + String(toffset));
Serial.println("-->[SLIB] altitude offset \t: " + String(altoffset));
Serial.println("-->[SLIB] sea level pressure\t: " + String(sealevel) + " hPa");
Serial.printf("-->[SLIB] only i2c sensors \t: %s\n", i2conly ? "true" : "false");
Serial.printf("-->[SLIB] only i2c sensors \t: %s\r\n", i2conly ? "true" : "false");

if (!i2conly && !sensorSerialInit(pms_type, pms_rx, pms_tx)) {
DEBUG("-->[SLIB] UART sensors detected\t:", "0");
Expand All @@ -136,7 +136,7 @@ void Sensors::init(u_int pms_type, int pms_rx, int pms_tx) {
/// set loop time interval for each sensor sample
void Sensors::setSampleTime(int seconds) {
sample_time = seconds;
Serial.println("-->[SLIB] new sample time\t: " + String(seconds));
if(devmode) Serial.println("-->[SLIB] new sample time\t: " + String(seconds));
if(isSensorRegistered(SENSORS::SSCD30)) {
scd30.setMeasurementInterval(seconds);
if (devmode) Serial.println("-->[SLIB] SCD30 interval time\t: " + String(seconds));
Expand Down Expand Up @@ -174,7 +174,7 @@ void Sensors::setCO2RecalibrationFactor(int ppmValue) {
scd4x.stopPeriodicMeasurement();
delay(510);
error = scd4x.performForcedRecalibration(ppmValue, frcCorrection);
if (error) Serial.printf("-->[SLIB] SCD4X recalibration\t: error frc:%d\n",frcCorrection);
if (error) Serial.printf("-->[SLIB] SCD4X recalibration\t: error frc:%d\r\n",frcCorrection);
delay(50);
scd4x.startPeriodicMeasurement();
}
Expand Down Expand Up @@ -563,7 +563,7 @@ void Sensors::printUnitsRegistered(bool debug) {
*/
void Sensors::printSensorsRegistered(bool debug) {
if (!debug) return;
Serial.printf("-->[SLIB] Sensors devices count\t: %i (", sensors_registered_count);
Serial.printf("-->[SLIB] Sensors i2c count \t: %i (", sensors_registered_count);
int i = 0;
while (sensors_registered[i++] != 0) {
Serial.print(sensors_device_names[sensors_registered[i-1]]);
Expand All @@ -575,7 +575,7 @@ void Sensors::printSensorsRegistered(bool debug) {
/// Print preview of the current variables detected by the sensors
void Sensors::printValues() {
if (!devmode) return;
Serial.print("-->[SLIB] Preview sensors values\t: ");
Serial.print("-->[SLIB] Sensors values \t: ");
for (u_int i = 0; i < UCOUNT; i++) {
if (units_registered[i] != 0) {
Serial.print(getUnitName((UNIT)units_registered[i]));
Expand All @@ -599,7 +599,7 @@ bool Sensors::pmGenericRead() {
String txtMsg = hwSerialRead(lenght_buffer);
if (txtMsg[0] == 66) {
if (txtMsg[1] == 77) {
DEBUG("-->[SLIB] UART PMGENERIC read \t\t: done!");
DEBUG("-->[SLIB] UART PMGENERIC read!\t: :D");
pm25 = txtMsg[6] * 256 + (char)(txtMsg[7]);
pm10 = txtMsg[8] * 256 + (char)(txtMsg[9]);

Expand Down Expand Up @@ -1224,21 +1224,21 @@ bool Sensors::senseAirS8Init() {

Serial.println("-->[SLIB] UART sensor detected \t: SenseAir S8");
if (devmode) {
Serial.printf("-->[SLIB] S8 Software version\t: %s\n", s8sensor.firm_version);
Serial.printf("-->[SLIB] S8 Sensor type\t: 0x%08x\n", s8->get_sensor_type_ID());
Serial.printf("-->[SLIB] S8 Sensor ID\t: %08x\n", s8->get_sensor_ID());
Serial.printf("-->[SLIB] S8 Memory ver\t: 0x%04x\n", s8->get_memory_map_version());
Serial.printf("-->[SLIB] S8 ABC period\t: %d hours\n", s8->get_ABC_period());
Serial.printf("-->[SLIB] S8 Software version\t: %s\r\n", s8sensor.firm_version);
Serial.printf("-->[SLIB] S8 Sensor type\t: 0x%08x\r\n", s8->get_sensor_type_ID());
Serial.printf("-->[SLIB] S8 Sensor ID\t: %08x\r\n", s8->get_sensor_ID());
Serial.printf("-->[SLIB] S8 Memory ver\t: 0x%04x\r\n", s8->get_memory_map_version());
Serial.printf("-->[SLIB] S8 ABC period\t: %d hours\r\n", s8->get_ABC_period());
}
DEBUG("-->[SLIB] S8 Disabling ABC period");
s8->set_ABC_period(0);
delay(100);
if (devmode) Serial.printf("-->[SLIB] S8 ABC period\t: %d hours\n", s8->get_ABC_period());
if (devmode) Serial.printf("-->[SLIB] S8 ABC period\t: %d hours\r\n", s8->get_ABC_period());

DEBUG("-->[SLIB] S8 ABC period \t: 180 hours");
s8->set_ABC_period(180);
delay(100);
if (devmode) Serial.printf("-->[SLIB] S8 ABC period\t: %d hours\n", s8->get_ABC_period());
if (devmode) Serial.printf("-->[SLIB] S8 ABC period\t: %d hours\r\n", s8->get_ABC_period());

s8->get_meter_status();
s8->get_alarm_status();
Expand Down Expand Up @@ -1289,7 +1289,7 @@ bool Sensors::sps30I2CInit() {
// start measurement
if (sps30.start()) {
DEBUG("-->[SLIB] SPS30 Measurement OK");
if (sps30.I2C_expect() == 4) DEBUG("[W][SLIB] SPS30 setup message\t: I2C buffersize only PM values \n");
if (sps30.I2C_expect() == 4) DEBUG("[W][SLIB] SPS30 setup message\t: I2C buffersize only PM values \r\n");
sensorRegister(SENSORS::SSPS30);
return true;
}
Expand Down Expand Up @@ -1570,7 +1570,7 @@ void Sensors::sensorAnnounce(SENSORS sensor) {

void Sensors::sensorRegister(SENSORS sensor) {
if (isSensorRegistered(sensor)) return;
Serial.printf("-->[SLIB] sensor registered\t: %s \t:D\n", getSensorName(sensor).c_str());
Serial.printf("-->[SLIB] sensor registered\t: %s \t:D\r\n", getSensorName(sensor).c_str());
sensors_registered[sensors_registered_count++] = sensor;
}

Expand Down Expand Up @@ -1650,7 +1650,7 @@ void Sensors::disableWire1() {
}

bool Sensors::serialInit(u_int pms_type, unsigned long speed_baud, int pms_rx, int pms_tx) {
if(devmode)Serial.printf("-->[SLIB] UART init with speed\t: %lu RX:%i TX:%i\n", speed_baud, pms_rx, pms_tx);
if(devmode)Serial.printf("-->[SLIB] UART init with speed\t: %lu TX:%i RX:%i\r\n", speed_baud, pms_tx, pms_rx);
switch (SENSOR_COMMS) {
case SERIALPORT:
Serial.begin(speed_baud);
Expand Down Expand Up @@ -1692,19 +1692,20 @@ bool Sensors::serialInit(u_int pms_type, unsigned long speed_baud, int pms_rx, i
Serial1.begin(speed_baud, SERIAL_8N1, pms_rx, pms_tx, false);
_serial = &Serial1;
break;
#ifdef Serial2
case SERIALPORT2:
#if SOC_UART_NUM > 2
DEBUG("-->[SLIB] UART COMM port \t: Serial2");
if (pms_type == SENSORS::SSPS30)
Serial2.begin(speed_baud);
else
Serial2.begin(speed_baud, SERIAL_8N1, pms_rx, pms_tx, false);
_serial = &Serial2;
break;
#else
DEBUG("-->[SLIB] UART COMM port \t: Undefined");
return false;
#endif // Serial2
#else
DEBUG("-->[SLIB] Force UART port \t: Serial1");
Serial1.begin(speed_baud, SERIAL_8N1, pms_rx, pms_tx);
_serial = &Serial1;
#endif
#endif
default:

Expand All @@ -1731,7 +1732,7 @@ bool Sensors::serialInit(u_int pms_type, unsigned long speed_baud, int pms_rx, i
swSerial.begin(speed_baud, SWSERIAL_8N1, pms_rx, pms_tx, false);
_serial = &swSerial;
#else
DEBUG("-->[SLIB] SoftWareSerial not enabled");
DEBUG("-->[SLIB] UART SoftwareSerial \t: disable");
return (false);
#endif //INCLUDE_SOFTWARE_SERIAL
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sensors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <dht_nonblocking.h>
#endif

#define CSL_VERSION "0.6.5"
#define CSL_VERSION "0.6.6"
#define CSL_REVISION 373

/***************************************************************
Expand Down
29 changes: 15 additions & 14 deletions unified-lib-deps.ini
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
[commonlibs]
lib_deps =
adafruit/Adafruit Unified Sensor @ 1.1.7
adafruit/Adafruit BME280 Library @ 2.2.2
adafruit/Adafruit BMP280 Library @ 2.6.6
adafruit/Adafruit BME680 Library @ 2.0.2
adafruit/Adafruit SHT31 Library @ 2.2.0
adafruit/Adafruit SCD30 @ 1.0.9
adafruit/Adafruit BusIO @ 1.14.1
robtillaart/AM232X @ 0.4.5
paulvha/sps30 @ 1.4.16
wifwaf/MH-Z19 @ 1.5.4
jcomas/S8_UART @ 1.0.1
sensirion/Sensirion Core @ 0.6.0
sensirion/Sensirion I2C SCD4x @ 0.3.1
adafruit/Adafruit Unified Sensor@1.1.7
adafruit/Adafruit BME280 Library@2.2.2
adafruit/Adafruit BMP280 Library@2.6.6
adafruit/Adafruit BME680 Library@2.0.2
adafruit/Adafruit SHT31 Library@2.2.0
adafruit/Adafruit SCD30@1.0.9
adafruit/Adafruit BusIO@1.14.1
robtillaart/AM232X@0.4.5
paulvha/sps30@1.4.16
wifwaf/MH-Z19@1.5.4
jcomas/S8_UART@1.0.1
sensirion/Sensirion Core@0.6.0
sensirion/Sensirion I2C SCD4x@0.3.1
https://github.com/enjoyneering/AHTxx.git#eb21571
https://github.com/hpsaturn/DHT_nonblocking.git#ec6e5b9
https://github.com/paulvha/SN-GCJA5.git#f261968
https://github.com/jcomas/CM1106_UART.git#da0eb4e
https://github.com/jcomas/CM1106_UART.git#da0eb4e

0 comments on commit 8d5b1cf

Please sign in to comment.