diff --git a/ampel-firmware/co2_sensor.cpp b/ampel-firmware/co2_sensor.cpp index 3264980b2739a5bebe55a8c3c71e3cdb3ba56d8a..c947ca55bc3592d1b945c64eae4fc46cc3cf46fd 100644 --- a/ampel-firmware/co2_sensor.cpp +++ b/ampel-firmware/co2_sensor.cpp @@ -12,6 +12,29 @@ #include "s8_uart.h" // Not used yet +#if (defined USE_SOFTWARE_SERIAL || defined ARDUINO_ARCH_RP2040) + #define S8_RX_PIN 5 // Rx pin which the S8 Tx pin is attached to (change if it is needed) + #define S8_TX_PIN 4 // Tx pin which the S8 Rx pin is attached to (change if it is needed) +#else + #define S8_UART_PORT 1 // Change UART port if it is needed +#endif +/* END CONFIGURATION */ + +S8_UART *sensor_S8; +S8_sensor sensor2; + + +#ifdef USE_SOFTWARE_SERIAL + SoftwareSerial S8_serial(S8_RX_PIN, S8_TX_PIN); +#else + #if defined(ARDUINO_ARCH_RP2040) + REDIRECT_STDOUT_TO(Serial) // to use printf (Serial.printf not supported) + UART S8_serial(S8_TX_PIN, S8_RX_PIN, NC, NC); + #else + HardwareSerial S8_serial(S8_UART_PORT); + #endif +#endif + namespace config { const uint16_t measurement_timestep_bootup = 5; // [s] Measurement timestep during acclimatization. const uint8_t max_deviation_during_bootup = 20; // [%]