jcomas / s8_uart Goto Github PK
View Code? Open in Web Editor NEWSenseAir S8 CO2 sensor library for serial communication (UART)
License: MIT License
SenseAir S8 CO2 sensor library for serial communication (UART)
License: MIT License
Hello,
I hope everything is going well. I'm a user of Sense air S8 sensor, and I have a suggestion that could benefit many users facing challenges with serial communication on boards that don't have direct support for Softwareserial or HardwareSerial.
Suggestion: Implementation of EspSoftwareSerial for Boards Without Support
Currently, some users of boards, such as ESP32 LILYGO®LoRa32 V2.1_1.6, may encounter limitations with Softwareserial or HardwareSerial libraries. A valuable alternative would be the implementation of the EspSoftwareSerial library to provide a more flexible and comprehensive solution.
Implementation Suggestion:
Add support for the EspSoftwareSerial library in the installation instructions or in the project's README. Additionally, provide a usage example to guide users in implementing EspSoftwareSerial in their projects.
Usage Example:
#include "s8_uart.h"
#include <SoftwareSerial.h> //EspSoftwareSerial include
EspSoftwareSerial::UART S8_serial;
S8_UART *sensor_S8;
S8_sensor sensor;
void setup() {
Serial.begin(9600);
while (!Serial) {
}
// Initialize S8 sensor
S8_serial.begin(S8_BAUDRATE, EspSoftwareSerial::SWSERIAL_8N1, 21, 22);
sensor_S8 = new S8_UART(S8_serial);
}
void loop() {
sensor.co2 = sensor_S8->get_co2();
Serial.print("CO2 value = ");
Serial.print(sensor.co2);
Serial.println(" ppm");
delay(1000);
}
Contribution to the Community:
The inclusion of EspSoftwareSerial can provide a broader solution for users of various boards, improving usability and accessibility in projects that require serial communication.
Thank you for your attention and consideration. I am available to provide more information or clarify any doubts.
Best regards,
Natanael José
Hello,
I'm using your lib, and I'd like to add it to the Arduino library repository.
To do so, it need to have a tag with the version matching what you set in the library.properties file.
Testing the library over old Arduino shield, I have the next compiling issue:
Indexing .pio/build/arduino/lib007/libSensirion Core.a
Compiling .pio/build/arduino/lib30a/S8_UART/modbus_crc.cpp.o
Compiling .pio/build/arduino/lib30a/S8_UART/s8_uart.cpp.o
.pio/libdeps/arduino/S8_UART/src/modbus_crc.cpp:45:1: error: narrowing conversion of '192' from 'int' to 'char' inside { } [-Wnarrowing]
};
^
.pio/libdeps/arduino/S8_UART/src/modbus_crc.cpp:45:1: error: narrowing conversion of '193' from 'int' to 'char' inside { } [-Wnarrowing]
.pio/libdeps/arduino/S8_UART/src/modbus_crc.cpp:45:1: error: narrowing conversion of '195' from 'int' to 'char' inside { } [-Wnarrowing]
.pio/libdeps/arduino/S8_UART/src/modbus_crc.cpp:45:1: error: narrowing conversion of '194' from 'int' to 'char' inside { } [-Wnarrowing]
With the next PlatformIO config:
[arduino_avr]
platform = atmelavr
board = pro16MHzatmega328
framework = arduino
monitor_speed = ${env.monitor_speed}
build_flags =
${env.build_flags}
lib_deps =
${env.lib_deps}
Tested in the next branch of CanAirIO Sensorslib
In https://github.com/jcomas/S8_UART/blob/main/examples/co2/co2.cpp
, if Senseair S8 isn't connected, the example code is supposed to display Serial.println("SenseAir S8 CO2 sensor not found!");
.
On a ESP8266, it often doesn't. The microcontroller crashes instead, because the while loop in S8_UART::serial_read_bytes
blocks during 5 seconds, and the watchdog resets the ESP.
Adding a short delay (e.g. delay(50)
) in the loop, before end_t = millis();
seems to fix the problem.
Other than that, the library seems to work well, on both ESP32 and ESP8266.
On ESP8266, I replaced SoftwareSerial with https://github.com/CrazyRobMiles/Esp8266EdgeSoftwareSerial, which uses much less memory.
Thanks for the good work!
If I understand correctly,
LOG_DEBUG_ERROR("Error starting manual calibration!");
at
https://github.com/jcomas/S8_UART/blob/main/src/s8_uart.cpp#L216
can never be reached, because result
isn't updated.
Is a line missing?
The current version in Pio registry is outdated and has a issue regarding the debug level 5. The current master branch is working ok. Please pump this version.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.