UedaTakeyuki / mh-z19

Read CO2 concentration from mh-z19 sensor on the Raspberry Pi & handle it. Detect Raspberry Pi model automatically and read the value from an appropriate serial device.
MIT License
185 stars 37 forks source link

--serial_device not working #21

Closed idegre closed 4 years ago

idegre commented 4 years ago

when attempting to use the --serial_device parameter it always returns an error. sorry I don't have the exact error as I changed the code on my pi and didn't get any screenshots or the exact error. I found this when trying to use a usb->serial interface on my pi3 so i wouldn't need to deal with the onboard serial luckily its an easy fix, but i cant create a PR to save you the trouble https://github.com/UedaTakeyuki/mh-z19/blob/master/pypi/mh_z19/__main__.py#L56 here it should be mh_z19.set_serialdevice(args.serial_device)

Describe the bug when attempting to use the --serial_device parameter it always returns an error. sorry I don't have the exact error as I changed the code on my pi and didn't get any screenshots

To Reproduce

  1. call sudo python3 -m mh_z19 --serial_device /dev/ttyUSB0
  2. see set_serialdevice(args.serial_device) is undefined error

Expected behavior the command should work

Screenshots If applicable, add screenshots to help explain your problem.

UedaTakeyuki commented 4 years ago

Hi, idegre!

I really appreciated your issue report. The reported issue is reproduced on my side, so I think I can fix it soon.

UedaTakeyuki commented 4 years ago

Hi, idegre!

I've fixed it, now it works as follows:

pi@raspberrypi:~ $ sudo python -m mh_z19 --serial_device /dev/serial0
{"co2": 535}
pi@raspberrypi:~ $ sudo python -m mh_z19 --version
0.6.3

Please update your mh_z19 module and tell me the result, thx!

UedaTakeyuki commented 4 years ago

No feedback.