strange-v / MHZ19

Arduino library for MH-Z19/MH-Z19B CO2 sensor
GNU General Public License v3.0
57 stars 12 forks source link

HardwareSerial1 in Arduino Leonardo #1

Closed khseal closed 6 years ago

khseal commented 6 years ago

Hi want to use the second port in arduino leonardo. His name is serial1. I do not understand how to initialize it correctly.

strange-v commented 6 years ago

Use MHZ19 mhz(&Serial1);

I've added "sw_get_values" example.

khseal commented 6 years ago

I tried this option. After that, arduino became an unknown device .. =) I had to catch the bootloader at the reset to restore arduino.

strange-v commented 6 years ago

It's quite weird. Unfortunately I don't have Arduino Leonardo, but I've used this lib with hardware serial on Arduino Mega without any issues. Probably you could check Serial1 with FTDI adapter to be sure that it works.

khseal commented 6 years ago

It works exactly with the other code, and with your library this is the problem = (

strange-v commented 6 years ago

Please provide the complete sketch/code which you use to reproduce the problem.

khseal commented 6 years ago

image You can see the message that the device is unknown.

strange-v commented 6 years ago

There was a typo in the data reading, fixed. Also interfaces was updated to be less confusing (see examples).