Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8b0bb2e
now task for master stimawifi
pat1 Sep 3, 2026
8f7104e
strange Uart definition for HardwareSerial for stm32
pat1 Sep 3, 2026
5941983
added satellite thread to stimawifi
pat1 Sep 4, 2026
0806844
test esp32_now_satellite
pat1 Sep 4, 2026
26da928
fix to old stm32 platform
pat1 Sep 5, 2026
a309fac
working on board slug management on stimawifi
pat1 Sep 5, 2026
290faea
added espnow transport
pat1 Sep 14, 2026
a4dc109
added espnow transport
pat1 Sep 14, 2026
2608480
stimawifi dequeue before sleep
pat1 Sep 16, 2026
56833d6
stimawifi sync radio transmission with measure
pat1 Sep 16, 2026
158c2bf
new station template and bugs
pat1 Sep 17, 2026
2a198c3
stimawifi espnow bugs
pat1 Sep 18, 2026
879c1e8
disable stimawifi gelolocalization by browser
pat1 Sep 18, 2026
f92f0ad
changed airquality-now station template
pat1 Sep 21, 2026
b00808a
working on stimawifi now
pat1 Sep 21, 2026
d162d3f
working on stimawifi now
pat1 Sep 23, 2026
6185569
working on stimawifi now
pat1 Sep 23, 2026
2a56483
stimawifi better memory diagnostic
pat1 Sep 24, 2026
0dea449
stimawifi bug on channel setting
pat1 Sep 25, 2026
4574576
updated SCD30 driver and SensorDriver library
pat1 Sep 28, 2026
2c32e97
updated SCD30 SensorDriverb library
pat1 Sep 28, 2026
c216b91
working on stimawifi now
pat1 Sep 28, 2026
1b12f4d
scd30 cannot work one shot
pat1 Sep 28, 2026
d93ea54
working on stimawifi wit wsp-now
pat1 Sep 29, 2026
7595118
added type in now transport for stimawifi
pat1 Sep 30, 2026
82645ba
reordered fixture
pat1 Sep 30, 2026
1491233
added field in modify esp-now form
pat1 Sep 30, 2026
0b5070d
dballe issue is not solved for levels in summary
pat1 Sep 30, 2026
dd3724f
working on stimawifi now
pat1 Sep 30, 2026
77f649c
stimawifi try to better manage pixels
pat1 Oct 1, 2026
1883cf1
stimawifi now inline documentation
pat1 Oct 1, 2026
8e40dec
minors
pat1 Oct 1, 2026
e4b7a09
new RMAP and stimawifi release
pat1 Oct 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 79 additions & 57 deletions platformio/libraries/SensorDriver/SensorDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4607,7 +4607,7 @@ void SensorDriverSps::prepare(bool is_test) {
SensorDriver::printInfo();

*_is_prepared =_sps30.start();
if (*_is_prepared){
if (*_is_setted){
_error_count = 0;
LOGT(F("SPS prepare... [ %s ]"), OK_STRING);
}else{
Expand Down Expand Up @@ -4940,46 +4940,58 @@ void SensorDriverScd::resetPrepared(bool is_test) {
void SensorDriverScd::setup() {
SensorDriver::printInfo();

_delay_ms = 0;
if (!*_is_setted) {
_scd30.begin(_address); //This will cause readings to occur every two seconds

/*
Maximal I2C speed is 100 kHz and the master has to support clock
stretching. Clock stretching period in write- and read- frames is 12
ms, however, due to internal calibration processes a maximal clock
stretching of 150 ms may occur once per day. For detailed information
to the I2C protocol, refer to NXP I2C-bus specification 1 . SCD30 does
not support repeated start condition. Clock stretching is necessary to
start the microcontroller and might occur before every ACK. I2C master
clock stretching needs to be implemented according to the NXP
specification. The boot-up time is < 2 s.
/*
Maximal I2C speed is 100 kHz and the master has to support clock
stretching. Clock stretching period in write- and read- frames is 12
ms, however, due to internal calibration processes a maximal clock
stretching of 150 ms may occur once per day. For detailed information
to the I2C protocol, refer to NXP I2C-bus specification 1 . SCD30 does
not support repeated start condition. Clock stretching is necessary to
start the microcontroller and might occur before every ACK. I2C master
clock stretching needs to be implemented according to the NXP
specification. The boot-up time is < 2 s.
*/
_scd30.sendCommand(COMMAND_SOFT_RESET);
delay(50); // ??? not explained in documentation
if(!_scd30.beginMeasuring()) { //Start continuous measurements
_error_count++;
LOGE(F("SCD beginMeasuring error"));
//LOGE(F("SCD setup... [ %s ]"), ERROR_STRING);
return;
}
if(!_scd30.setMeasurementInterval(2)) { //2 seconds between measurements
_error_count++;
LOGE(F("SCD setMeasurementInterval error"));
//LOGE(F("SCD setup... [ %s ]"), ERROR_STRING);
return;
}
if (!_scd30.setAutoSelfCalibration(false)) { //Enable auto-self-calibration
_error_count++;
LOGE(F("SCD setAutoSelfCalibration error"));
//LOGE(F("SCD setup... [ %s ]"), ERROR_STRING);
return;
}

*_is_setted = true;
_error_count = 0;
LOGT(F("SCD setup... [ %s ]"), YES_STRING);
}
if (_address != SCD30_ADDRESS){
LOGE(F("SCD address error"));
return;
}

_scd30.begin(Wire,false,false); // begin(TwoWire &wirePort, bool autoCalibrate, bool measBegin)

_scd30.reset(); // this make the first measure not releable
delay(50); // ??? not explained in documentation

if (!_scd30.isConnected()){
_error_count++;
LOGE(F("SCD setup error"));
return;
}

if (!_scd30.setAutoSelfCalibration(false)) { //Force disable auto-self-calibration
_error_count++;
LOGE(F("SCD setAutoSelfCalibration error"));
//LOGE(F("SCD setup... [ %s ]"), ERROR_STRING);
return;
}

if(!_scd30.setMeasurementInterval(2)) { //2 seconds between measurements
_error_count++;
LOGE(F("SCD setMeasurementInterval error"));
//LOGE(F("SCD setup... [ %s ]"), ERROR_STRING);
return;
}

if(!_scd30.beginMeasuring()) { //Start continuous measurements
_error_count++;
LOGE(F("SCD beginMeasuring error"));
//LOGE(F("SCD setup... [ %s ]"), ERROR_STRING);
return;
}

*_is_setted = true;
_error_count = 0;
LOGT(F("SCD setup... [ %s ]"), YES_STRING);
}

bool SensorDriverScd::setForcedRecalibrationFactor(uint16_t value) {
Expand All @@ -4988,26 +5000,16 @@ bool SensorDriverScd::setForcedRecalibrationFactor(uint16_t value) {

void SensorDriverScd::prepare(bool is_test) {
SensorDriver::printInfo();

// clear previous measurements
_scd30.getCO2();
_scd30.getTemperature();
_scd30.getHumidity();
//_scd30.getTemperature();
//_scd30.getHumidity();


//_scd30->beginMeasuring();
*_is_prepared =true;
_error_count = 0;
LOGT(F("SCD prepare... [ %s ]"), OK_STRING);

/*
if (*_is_prepared){
_error_count = 0;
LOGT(F("SCD prepare... [ %s ]"), OK_STRING);
}else{
_error_count++;
LOGE(F("SCD prepare... [ %s ]"), FAIL_STRING);
}
*/

_delay_ms = 2500ul;
_start_time_ms = millis();
Expand Down Expand Up @@ -5051,20 +5053,30 @@ void SensorDriverScd::get(int32_t *values, uint8_t length, bool is_test) {
// 1,800009 coefficiente di conversione ppm-> mg/m3 (riferito a 25°C e 760 mm Hg)
// quindi assumioamo 0-0.020 Kg/m3 con risoluzione 0.000002 circa
// in interi fattore di scala in tabella B 10**6 quindi mg/m3

values[0] = _scd30.getCO2()* 1.8;

uint16_t co2=_scd30.getCO2();
if (co2 != 0){ // 0 is missing value in library
values[0] = co2 * 1.8;
}
}

/* // do not use temperature and humidity from this sensor

// get temperature
uint16_t temp=_scd30.getTemperature();

if (length >= 2) {
values[1] = _scd30.getTemperature()*100+27315 ;
if (temp != 0){
values[1] = temp * 100 + 27315 ;
}
}

// get humidity
if (length >= 3) {
values[2] = _scd30.getHumidity() ;
uint16_t humid = _scd30.getHumidity();
if (humid != 0){
values[2] = humid ;
}
}
*/

Expand All @@ -5079,6 +5091,16 @@ void SensorDriverScd::get(int32_t *values, uint8_t length, bool is_test) {
_is_success = false;
_get_state = END;
}

/*
if(!_scd30.StopMeasurement()) { //Stop continuous measurements
_error_count++;
LOGE(F("SCD StopMeasurement error"));
//LOGE(F("SCD get... [ %s ]"), ERROR_STRING);
return;
}
*/

_delay_ms = 0;
_start_time_ms = millis();
break;
Expand Down
2 changes: 1 addition & 1 deletion platformio/libraries/SensorDriverb/SensorDriverb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5479,7 +5479,7 @@ int SensorDriverSCDoneshot::setup(const char* driver, const int address, const i
clock stretching needs to be implemented according to the NXP
specification. The boot-up time is < 2 s.
*/
_scd->sendCommand(COMMAND_SOFT_RESET);
_scd->reset();
delay(50); // ??? not explained in documentation
if(_scd->beginMeasuring()) { //Start continuous measurements
IF_SDSDEBUG(SDDBGSERIAL.println(F("# scd beginMeasuring ok")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Code

The MIT License (MIT)

Copyright (c) 2016 SparkFun Electronics
Copyright (c) 2020 SparkFun Electronics

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 13 additions & 9 deletions platformio/libraries/SparkFun_SCD30_Arduino_Library/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
SparkFun SCD30 CO2 Sensor Library
SparkFun SCD30 CO₂ Sensor Library
===========================================================

![SparkFun SCD30 CO2 Sensor](https://cdn.sparkfun.com//assets/parts/1/2/9/8/4/SparkFun_Sensirion_SCD30.jpg)
![SparkFun SCD30 CO₂ Sensor](https://cdn.sparkfun.com//assets/parts/1/2/9/8/4/SparkFun_Sensirion_SCD30.jpg)

[*SparkX CO₂ Humidity and Temperature Sensor - SCD30 (SPX-14751)*](https://www.sparkfun.com/products/14751)

The SCD30 from Sensirion is a high quality [NDIR](https://en.wikipedia.org/wiki/Nondispersive_infrared_sensor) based CO₂ sensor capable of detecting 400 to 10000ppm with an accuracy of ±(30ppm+3%). In order to improve accuracy the SCD30 has temperature and humidity sensing built-in, as well as commands to set the current altitude.
The SCD30 from Sensirion is a high quality [NDIR](https://en.wikipedia.org/wiki/Nondispersive_infrared_sensor) based CO₂ sensor capable of detecting 400 to 10000ppm with an accuracy of ±(30ppm+3%). In order to improve accuracy the SCD30 has temperature and humidity sensing built-in, as well as commands to compensate for altitude.

We've written an Arduino library to make reading the CO₂, humidity, and temperature very easy. It can be downloaded through the Arduino Library manager: search for 'SparkFun SCD30'. We recommend using a [Qwiic Breadboard Cable](https://www.sparkfun.com/products/14425) to connect the SCD30 to a Qwiic compatible board. The Ye*LL*ow wire goes in the SC*L* pin. The SCD30 also supports a serial interface but we haven't worked with it.

Expand All @@ -19,14 +19,20 @@ Thanks to!

* [jobr97](https://github.com/jobr97) for adding the getTemperatureOffset() method
* [bobobo1618](https://github.com/bobobo1618) for writing a CRC check and improving the return values of the library
* [labeneator](https://github.com/labeneator) for adding method to disable calibrate at begin
* [AndreasExner](https://github.com/AndreasExner) for adding [reset and getAutoSelfCalibration methods](https://github.com/sparkfun/SparkFun_SCD30_Arduino_Library/pull/17)
* [awatterott](https://github.com/awatterott) for adding [getAltitudeCompensation()](https://github.com/sparkfun/SparkFun_SCD30_Arduino_Library/pull/18)
* [jogi-k](https://github.com/jogi-k) for adding [teensy i2clib](https://github.com/sparkfun/SparkFun_SCD30_Arduino_Library/pull/19) support
* [paulvha](https://github.com/paulvha) for the suggestions and corrections in [his version of the library](https://github.com/paulvha/scd30)
* [yamamaya](https://github.com/yamamaya) for the [3ms delay](https://github.com/sparkfun/SparkFun_SCD30_Arduino_Library/pull/24)

Repository Contents
-------------------

* **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE.
* **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE.
* **/src** - Source files for the library (.cpp, .h).
* **keywords.txt** - Keywords from this library that will be highlighted in the Arduino IDE.
* **library.properties** - General library properties for the Arduino package manager.
* **keywords.txt** - Keywords from this library that will be highlighted in the Arduino IDE.
* **library.properties** - General library properties for the Arduino package manager.

Documentation
--------------
Expand All @@ -36,9 +42,7 @@ Documentation
License Information
-------------------

This product is _**open source**_!

Various bits of the code have different licenses applied. Anything SparkFun wrote is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round!
This product is _**open source**_!

Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,34 @@ void setup()
;
}

airSensor.setMeasurementInterval(4); //Change number of seconds between measurements: 2 to 1800 (30 minutes)
airSensor.setMeasurementInterval(16); //Change number of seconds between measurements: 2 to 1800 (30 minutes), stored in non-volatile memory of SCD30

//While the setting is recorded, it is not immediately available to be read.
delay(200);

int interval = airSensor.getMeasurementInterval();
Serial.print("Measurement Interval: ");
Serial.println(interval);

//My desk is ~1600m above sealevel
airSensor.setAltitudeCompensation(1600); //Set altitude of the sensor in m
airSensor.setAltitudeCompensation(1600); //Set altitude of the sensor in m, stored in non-volatile memory of SCD30

//Read altitude compensation value
unsigned int altitude = airSensor.getAltitudeCompensation();
Serial.print("Current altitude: ");
Serial.print(altitude);
Serial.println("m");

//Pressure in Boulder, CO is 24.65inHg or 834.74mBar
airSensor.setAmbientPressure(835); //Current ambient pressure in mBar: 700 to 1200
airSensor.setAmbientPressure(835); //Current ambient pressure in mBar: 700 to 1200, will overwrite altitude compensation

airSensor.setTemperatureOffset(5); //Optionally we can set temperature offset to 5°C, stored in non-volatile memory of SCD30

//Read temperature offset
float offset = airSensor.getTemperatureOffset();
Serial.print("Current temp offset: ");
Serial.print(offset, 2);
Serial.println("C");

//airSensor.setTemperatureOffset(5); //Optionally we can set temperature offset to 5°C
}

void loop()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
Reading CO2, humidity and temperature from the SCD30
By: Nathan Seidle
SparkFun Electronics
Date: May 22nd, 2018
License: MIT. See license file for more information but you can
basically do whatever you want with this code.

Feel like supporting open source hardware?
Buy a board from SparkFun! https://www.sparkfun.com/products/15112

This example turns on the auto-calibrate function during .begin()
Please see section 1.3.6 of the SCD30 datasheet:

"When activated for the first time a
period of minimum 7 days is needed so that the algorithm can find its initial parameter set for ASC. The sensor has to be exposed
to fresh air for at least 1 hour every day. Also during that period, the sensor may not be disconnected from the power supply,
otherwise the procedure to find calibration parameters is aborted and has to be restarted from the beginning. The successfully
calculated parameters are stored in non-volatile memory of the SCD30 having the effect that after a restart the previously found
parameters for ASC are still present. "

Hardware Connections:
Attach RedBoard to computer using a USB cable.
Connect SCD30 to RedBoard using Qwiic cable.
Open Serial Monitor at 115200 baud.
*/

#include <Wire.h>

#include "SparkFun_SCD30_Arduino_Library.h" //Click here to get the library: http://librarymanager/All#SparkFun_SCD30
SCD30 airSensor;

void setup()
{
Serial.begin(115200);
Serial.println("SCD30 Example");
Wire.begin();

//Start sensor using the Wire port and enable the auto-calibration (ASC)
if (airSensor.begin(Wire, true) == false)
{
Serial.println("Air sensor not detected. Please check wiring. Freezing...");
while (1)
;
}

Serial.print("Auto calibration set to ");
if (airSensor.getAutoSelfCalibration() == true)
Serial.println("true");
else
Serial.println("false");

//The SCD30 has data ready every two seconds
}

void loop()
{
if (airSensor.dataAvailable())
{
Serial.print("co2(ppm):");
Serial.print(airSensor.getCO2());

Serial.print(" temp(C):");
Serial.print(airSensor.getTemperature(), 1);

Serial.print(" humidity(%):");
Serial.print(airSensor.getHumidity(), 1);

Serial.println();
}
else
Serial.println("Waiting for new data");

delay(500);
}
Loading
Loading