kike-canaries / canairio_sensorlib

Particle sensor manager for multiple sensors: Honeywell, Plantower, Panasonic, Sensirion, etc. This is sensors layer of CanAirIO project too.
https://canair.io/docs/sensorlib.html
GNU General Public License v3.0
37 stars 12 forks source link

Enhancing Compatibility: Proposing EspSoftwareSerial for Improved Flexibility on ESP32 LILYGO® LoRa32 V2.1_1.6 #191

Open NatanaelJose opened 8 months ago

NatanaelJose commented 8 months ago

Summary

Hello,

I'm reaching out as a user of ESP32 LILYGO® LoRa32 V2.1_1.6, and I've observed limitations with the Softwareserial and HardwareSerial libraries. The Canairio library mandates the use of either software or hardware serial, rendering it impractical for use on these boards.

I propose considering the implementation of the EspSoftwareSerial library as a valuable alternative. This would offer users a more flexible and comprehensive solution, allowing for enhanced compatibility and ease of use.

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 in the case of Sense Air S8:

    
    #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);
    }
    Thank you for your attention to this matter.

Best regards, Natanael José

hpsaturn commented 8 months ago

Thanks for your comment, and sorry for the delay. Well, I think with the last version of CanAirIO Firmware or only using CanAirIO SensorLib is possible to use a different UART or secondary UART passing the pins via the constructor of the la library, like is mentioned in the examples and documentation. How many UARTs do you need for sensors?