jcomas / S8_UART

SenseAir S8 CO2 sensor library for serial communication (UART)
MIT License
22 stars 4 forks source link

Suggestion to Enable Universal Serial Compatibility #5

Open NatanaelJose opened 5 months ago

NatanaelJose commented 5 months ago

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:

  1. 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.

  2. 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é

jcomas commented 5 months ago

Thanks for the example. I have "SoftwareSerial" in example https://github.com/jcomas/S8_UART/blob/main/examples/co2/co2.cpp but maybe not valid for ESP32. I'll review it for the next release.