-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #208 from kike-canaries/m5AirQS3
M5AirQ S3 Support
- Loading branch information
Showing
4 changed files
with
167 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter | ||
; Upload options: custom upload port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; Advanced options: extra scripting | ||
; | ||
; Please visit documentation for the other options and examples | ||
; https://docs.platformio.org/page/projectconf.html | ||
|
||
[platformio] | ||
src_dir = . | ||
lib_dir = ../.. | ||
extra_configs = ../../unified-lib-deps.ini | ||
|
||
[env] | ||
framework = arduino | ||
upload_speed = 1500000 | ||
monitor_speed = 115200 | ||
build_flags = | ||
-D CORE_DEBUG_LEVEL=0 | ||
-D ARDUINO_USB_CDC_ON_BOOT=1 | ||
-D ARDUINO_ESP32_DEV=1 | ||
-D M5AIRQ=1 ; in your implementation you NEED it (it will improved in the future) | ||
lib_deps = | ||
${commonlibs.lib_deps} | ||
|
||
[env:m5airq] | ||
extends = env | ||
platform = espressif32 | ||
board = esp32-s3-devkitc-1 | ||
board_build.filesystem = littlefs ; compatibility with original demo firmware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/** | ||
* @file main.cpp | ||
* @author Antonio Vanegas @hpsaturn | ||
* @date June 2018 - 2024 | ||
* @brief CanAirIO M5AirQ test | ||
* @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 documentation: | ||
* https://canair.io/docs | ||
*/ | ||
|
||
#include <Arduino.h> | ||
|
||
#include <Sensors.hpp> | ||
|
||
#define POWER_HOLD 46 // M5AirQ main board | ||
#define SEN55_POWER_EN 10 | ||
|
||
#define GROVE_SDA 13 | ||
#define GROVE_SCL 15 | ||
|
||
#define I2C1_SDA_PIN 11 | ||
#define I2C1_SCL_PIN 12 | ||
|
||
void printSensorsDetected() { | ||
uint16_t sensors_count = sensors.getSensorsRegisteredCount(); | ||
uint16_t units_count = sensors.getUnitsRegisteredCount(); | ||
Serial.println("-->[MAIN] Sensors detected \t: " + String(sensors_count)); | ||
Serial.println("-->[MAIN] Sensors units count\t: " + String(units_count)); | ||
Serial.print("-->[MAIN] Sensors devices names\t: "); | ||
int i = 0; | ||
while (sensors.getSensorsRegistered()[i++] != 0) { | ||
Serial.print(sensors.getSensorName((SENSORS)sensors.getSensorsRegistered()[i - 1])); | ||
Serial.print(","); | ||
} | ||
Serial.println(); | ||
} | ||
|
||
void printSensorsValues() { | ||
Serial.println("-->[MAIN] Preview sensor values :"); | ||
UNIT unit = sensors.getNextUnit(); | ||
while (unit != UNIT::NUNIT) { | ||
String uName = sensors.getUnitName(unit); | ||
float uValue = sensors.getUnitValue(unit); | ||
String uSymb = sensors.getUnitSymbol(unit); | ||
Serial.printf("-->[MAIN] %6s:\t%02.1f\t%s\n", uName.c_str(), uValue, uSymb.c_str()); | ||
unit = sensors.getNextUnit(); | ||
} | ||
} | ||
|
||
void onSensorDataOk() { | ||
Serial.println("======= E X A M P L E T E S T ========="); | ||
printSensorsDetected(); | ||
printSensorsValues(); | ||
} | ||
|
||
void onSensorDataError(const char* msg) {} | ||
/****************************************************************************** | ||
* M A I N | ||
******************************************************************************/ | ||
|
||
void powerEnableSensors() { | ||
Serial.println("-->[POWR] == enable sensors =="); | ||
pinMode(POWER_HOLD, OUTPUT); | ||
digitalWrite(POWER_HOLD, HIGH); | ||
pinMode(SEN55_POWER_EN, OUTPUT); | ||
digitalWrite(SEN55_POWER_EN, LOW); | ||
} | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
delay(2000); // Only for debugging | ||
powerEnableSensors(); // M5AirQ enable sensors | ||
|
||
delay(100); | ||
Serial.println("\n== Sensor test setup ==\n"); | ||
Serial.println("-->[SETUP] Detecting sensors.."); | ||
|
||
sensors.setSampleTime(10); // config sensors sample time interval | ||
sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback | ||
sensors.setDebugMode(false); // [optional] debug mode | ||
sensors.detectI2COnly(true); // not force to only i2c sensors | ||
sensors.setTemperatureUnit(TEMPUNIT::CELSIUS); // comment for Celsius or set Fahrenheit | ||
sensors.init(); // Auto detection (UART and i2c sensors) | ||
delay(1000); | ||
} | ||
|
||
void loop() { | ||
sensors.loop(); // read sensor data and showed it | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters