Skip to content

Commit

Permalink
Merge pull request #72 from kike-canaries/sps30i2c
Browse files Browse the repository at this point in the history
added SPS30 via i2c support
  • Loading branch information
hpsaturn authored Jun 7, 2021
2 parents d12d2d7 + 4155f06 commit 510da5e
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 75 deletions.
67 changes: 67 additions & 0 deletions examples/sps30i2c/sps30i2c.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* @file main.cpp
* @author Antonio Vanegas @hpsaturn
* @date June 2018 - 2021
* @brief Particle meter sensor tests
* @license GPL3
*
* Full documentation:
* https://github.com/kike-canaries/canairio_sensorlib#canairio-air-quality-sensors-library
*
* Full implementation for WiFi and Bluetooth Air Quality fixed and mobile station:
* https://github.com/kike-canaries/canairio_firmware#canairio-firmware
*
* CanAirIO project:
* https://canair.io
*
* CanAirIO Docs:
* https://canair.io/docs
*
*/

#include <Arduino.h>
#include <Sensors.hpp>

void onSensorDataOk() {
Serial.print ("-->[MAIN] PM1.0: "+sensors.getStringPM1());
Serial.print (" PM2.5: " + sensors.getStringPM25());
Serial.print (" PM10: " + sensors.getStringPM10());
Serial.println (" PM1: " + sensors.getStringPM1());
}

void onSensorDataError(const char * msg){
Serial.println(msg);
}

/******************************************************************************
* M A I N
******************************************************************************/

void setup() {
Serial.begin(115200);
delay(1000);

Serial.println("\n== Sensor test setup ==\n");
Serial.println("-->[SETUP] Detecting sensors..");

sensors.setSampleTime(5); // config sensors sample time interval
sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback
sensors.setOnErrorCallBack(&onSensorDataError); // [optional] error callback
sensors.setDebugMode(false); // [optional] debug mode
sensors.detectI2COnly(true); // [optional] skip UART detection

sensors.init();

if(sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());

delay(500);
}

uint64_t counter = 0;

void loop() {

sensors.loop(); // read sensor data and showed it

}
8 changes: 4 additions & 4 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CanAirIO Air Quality Sensors Library",
"version": "0.2.1",
"version": "0.2.2",
"homepage":"https://canair.io",
"keywords":
[
Expand Down Expand Up @@ -68,14 +68,14 @@
{"name":"Adafruit Unified Sensor", "owner":"adafruit", "version":"1.1.4"},
{"name":"Adafruit AM2320 sensor library", "owner":"adafruit", "version":"1.1.4"},
{"name":"sps30", "owner":"paulvha","version":"1.4.9"},
{"name":"Adafruit BME280 Library", "owner":"adafruit","version":"2.1.2"},
{"name":"Adafruit BME280 Library", "owner":"adafruit","version":"2.1.4"},
{"name":"AHT10", "owner":"enjoyneering","version":"1.1.0"},
{"name":"Adafruit BusIO", "owner":"adafruit","version":"1.6.0"},
{"name":"Adafruit BusIO", "owner":"adafruit","version":"1.7.3"},
{"name":"Adafruit SHT31 Library", "owner":"adafruit","version":"2.0.0"},
{"name":"DHT_nonblocking", "version":"https://github.com/hpsaturn/DHT_nonblocking/archive/master.zip"},
{"name":"MH-Z19", "owner":"wifwaf", "version":"1.5.3"},
{"name":"SparkFun SCD30 Arduino Library","owner":"sparkfun","version":"1.0.10"},
{"name":"CM1106_UART", "version":"https://github.com/hpsaturn/CM1106_UART.git"},
{"name":"Adafruit BME680 Library","owner":"adafruit","version":"1.0.7"}
{"name":"Adafruit BME680 Library","owner":"adafruit","version":"2.0.0"}
]
}
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.2.1
version=0.2.2
author=@hpsaturn, CanAirIO project <[email protected]>
maintainer=Antonio Vanegas <[email protected]>
url=https://github.com/kike-canaries/canairio_sensorlib
Expand Down
12 changes: 9 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ upload_speed = 1500000
monitor_speed = 115200
monitor_filters = time
build_flags =
-D SRC_REV=273
-D SRC_REV=301
-D CORE_DEBUG_LEVEL=0
lib_deps =
adafruit/Adafruit Unified Sensor @ 1.1.4
adafruit/Adafruit AM2320 sensor library @ 1.1.4
adafruit/Adafruit BME280 Library @ 2.1.2
adafruit/Adafruit BME280 Library @ 2.1.4
adafruit/Adafruit BME680 [email protected]
adafruit/Adafruit BusIO @ 1.6.0
adafruit/Adafruit BusIO @ 1.7.3
adafruit/Adafruit SHT31 Library @ 2.0.0
enjoyneering/AHT10 @ ^1.1.0
https://github.com/hpsaturn/DHT_nonblocking.git
Expand Down Expand Up @@ -58,3 +58,9 @@ src_filter = -<*> +<platformio/>
[env:esp8266]
extends = esp8266_common
src_filter = -<*> +<platformio/>

[env:esp32sps30i2c]
extends = esp32_common
src_filter = -<*> +<sps30i2c/>


Loading

0 comments on commit 510da5e

Please sign in to comment.