Olenand / MH_Z19B

C++ interface for MH-Z19B CO2 NDIR sensor
MIT License
2 stars 0 forks source link

Multiple SoftwareSerial's problem #1

Open almln opened 5 years ago

almln commented 5 years ago

If i want to use several software serial ports (i.e. BT module), then your implementation blocks software serial, because more than one opened ports can't work together at the same time on the chip (i.e. see https://forum.arduino.cc/index.php?topic=442387.0). Solution may be in the way of create-open-close procedure inside each method of the class SensorMH_Z19B, if needed. This may result in performance issues, but can solve the problem.

abrahamMLG commented 5 years ago

Hi, i Had same problem, use AlsoftSerial and solved. Only have a look to TX & RX pins... for NANO are 8 & 9.

include // Bluetooth

include // MH-Z19

define RX_PIN 10 // Rx pin which the MHZ19 Tx pin is attached to

define TX_PIN 11 // Tx pin which the MHZ19 Rx pin is attached to

define BAUDRATE 9600

MHZ19 myMHZ19; // Constructor for MH-Z19 class SoftwareSerial mySerial(RX_PIN, TX_PIN); AltSoftSerial BT1(8,9);

void setup() { // Configuro puertos mySerial.begin(BAUDRATE); BT1.begin(9600); delay(1000);

myMHZ19.begin(mySerial);

And continue with rest of code............

Regards