tobiasschuerg / MH-Z-CO2-Sensors

Arduino imeplementation for CO2 sensors of the MH-Z series (Intelligent Infrared CO2 Module)
MIT License
77 stars 40 forks source link

Added support of generic streams instead of hardcoded software serial. #8

Closed vladkozlov69 closed 5 years ago

vladkozlov69 commented 5 years ago

Hello Tobias,

I've refactored your code a bit to make it working with any Stream& and not only SoftwareSerial (tested using STM32 HardwareSerial and SC16IS750 I2C-to-UART board). Decided to share my changes with you.

tobiasschuerg commented 5 years ago

Thanks a lot. I'll test with my setup once got time an merge. 👍

vladkozlov69 commented 5 years ago

Just in case here is a snippet from my sketch:

`#include

include

include

define MHZ_PWM_PIN PC13

SC16IS750 i2cuart = SC16IS750(SC16IS750_PROTOCOL_I2C, SC16IS750_ADDRESS_AA); MHZ co2(&i2cuart, MHZ_PWM_PIN, MHZ19B);

void setup() { Wire.begin(); i2cuart.begin(9600); }`