Closed 2ZZ closed 2 months ago
Hi 2ZZ,
Inferred from the random response you've got, most possible causes are:
Would you please tell me what is happening when you try again with the option --serial_device /dev/serial1
, --serial_device /dev/ttyAMA0
or --serial_device /dev/ttyS0
, also try without dtoverlay=disable-bt
in your/boot/config.txt
, thank you.
Hi @UedaTakeyuki,
I don't think it's a preheat issue as I've left it powered on for many hours.
Re-enabling BT and rebooting changed the response from those alternative serial devices, the output is below with some extra debug lines added.
BT disabled
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 380, in _reconfigure_port
orig_attr = termios.tcgetattr(self.fd)
termios.error: (5, 'Input/output error')
BT enabled
ser.read(9): b''
ser.read(9): b''
ser.read(9): b''
ser.read(9): b''
ser.read(9): b''
{}
BT disabled
ser.read(9): b'BM\x0c\x8c\t\xac\x02\xce\x01'
ser.read(9): b'*\x00\x00\xe2\x00\x06\xbfBM'
ser.read(9): b'\x0c\x8c\t\xac\x02\xce\x01*\x00'
ser.read(9): b'\x00\xe2\x00\x06\xbfBM\x0c\x8c'
ser.read(9): b'\t\xac\x02\xce\x01*\x00\x00\xe2'
{}
BT enabled
ser.read(9): b''
ser.read(9): b''
ser.read(9): b''
ser.read(9): b''
ser.read(9): b''
{}
BT disabled
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 380, in _reconfigure_port
orig_attr = termios.tcgetattr(self.fd)
termios.error: (5, 'Input/output error')
BT enabled
ser.read(9): b'BM\x0c{\t\xa5\x03/\x01'
ser.read(9): b'*\x00\x00\xe2\x00\x06\tBM'
ser.read(9): b'\x0c{\t\xa5\x03/\x01*\x00'
ser.read(9): b'\x00\xe2\x00\x06\tBM\x0c{'
ser.read(9): b'\t\xa5\x030\x01*\x00\x00\xe2'
{}
I will put an order in for a replacement sensor to rule that out.
It seems as follows:
The response from the sensor module (possibly) seems to repeat the following sequence:
Do you have any idea about the sequence above?
I really have no idea on that sequence. I have a spare Pi 2 B here so I tried it on there and the issue is the same. Once the new sensor arrives I will try again.
If you don't mind its rough resolution and re-cabling, PWM interface is also available.
PWM is working nicely :raised_hands:
root@raspberrypi:~# while :; do python -m mh_z19 --pwm; done
{'co2': 480.0}
{'co2': 480.0}
{'co2': 480.0}
{'co2': 480.0}
{'co2': 480.0}
{'co2': 480.0}
{'co2': 475.0}
{'co2': 475.0}
{'co2': 475.0}
{'co2': 470.0}
{'co2': 470.0}
{'co2': 470.0}
{'co2': 470.0}
{'co2': 465.0}
{'co2': 460.0}
{'co2': 460.0}
{'co2': 460.0}
{'co2': 460.0}
{'co2': 460.0}
I will still try GPIO again as I already ordered the new sensor.
The new sensor arrived and works straight away. This is the one I bought: https://www.aliexpress.com/item/1005002038004611
python3 -m mh_z19
{"co2": 796}
Thanks for the assistance @UedaTakeyuki
Hello @2ZZ , I have exactly the same problem as you. PWM works fine but the readings from UART are as yours. They do not pass this check.
What was the problem eventually with your case? Do you think I have a faulty sensor?
Hello @2ZZ , I have exactly the same problem as you. PWM works fine but the readings from UART are as yours. They do not pass this check.
What was the problem eventually with your case? Do you think I have a faulty sensor?
Possibly, which variety of sensor do you have? You may find PWM mode works even if UART doesn't.
Hello @2ZZ , I have exactly the same problem as you. PWM works fine but the readings from UART are as yours. They do not pass this check. What was the problem eventually with your case? Do you think I have a faulty sensor?
Possibly, which variety of sensor do you have? You may find PWM mode works even if UART doesn't.
I've got the MH-Z19B variety. I have now given up :(
Hi all,
I have an Mh-z19c connected to a Pi Zero W with TxD and RxD cross connected to pins 8 (GPIO 14) and 10 (GPIO 15) as per the repo readme and I see an orange light flashing inside indicating power.
The problem is the output from mh_z19 always
{}
.I found the serial output is not passing this check:
Instead I see values like these examples:
I've followed the advice of all the existing issues I can find:
enable_uart=1
is in/boot/config.txt
core_freq=250
in/boot/config.txt
dtoverlay=disable-bt
in/boot/config.txt
to disable BluetoothIf anyone has any suggestions they would be highly appreicated!
This is the variant of sensor I have:![image](https://github.com/UedaTakeyuki/mh-z19/assets/5006129/6e3f5f31-2e53-4f86-9989-3ea52487d0f4)