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

Raspberry 4 Support #29

Closed iperniaf closed 3 years ago

iperniaf commented 3 years ago

Hi, I'm using your lib with a rpbi 4 and it needs some fixes. ¿Can I contribute to the community fixing them?

UedaTakeyuki commented 3 years ago

Would you please tell me which problem and fixing? I've not heard of any problem with RRi4.

iperniaf commented 3 years ago

On mh_z19.py script, line 39, you select serial port using strict Rpi model. Rpi4 model is not listed, so it tries to use ttyAMA0 port, and the correct one is ttyS0

UedaTakeyuki commented 3 years ago

Weird, line 29 can't be passed because Raspberry Pi OS must have /dev/serial0 as a symbolic link. Do you use other OS?

iperniaf commented 3 years ago

yes, i'm using a raspberry image on a docker container running on balena etcher OS

UedaTakeyuki commented 3 years ago

I see!

So, the necessary fix might be as following 2.

  1. Add RPi4 definition to https://github.com/UedaTakeyuki/getrpimodel
  2. Add "4 Model B" to line 31

right?

UedaTakeyuki commented 3 years ago

Add RPi4 definition to https://github.com/UedaTakeyuki/getrpimodel

Sorry, this was my missunderstanding, now RPi4 is in getrpimodel. So, nesessary fix might be only #2.

I welcome your pull request!

iperniaf commented 3 years ago

I have no permision to push my changes on a new branch

UedaTakeyuki commented 3 years ago

Not push directory, instead, you can make pull request.

iperniaf commented 3 years ago

done! I have an extrage behavior. I'm running your script with serial_console_untouched=True and main program calls "read" every 10 seconds Sometimes the scripts runs ok, but other times it returns "None" image Can you imagine what's happening?

UedaTakeyuki commented 3 years ago

No idea, sorry.

UedaTakeyuki commented 3 years ago

Hi iperniaf,

I've marged issue #30 and updated it to version 3.0.2 both github and pypi. Would you please try it? thank you.

UedaTakeyuki commented 3 years ago

longtime no feedback