I tried multiple way to connect the MH-Z19B using Mycodo interface. First of all, using the mh-z19 3.1.1 project, I can easily retrieve data from the /dev/ttyS0 over a SSH connection to the pi with sudo python -m mh_z19 --all. That means, the sensor is working.
Now when I configure Mycodo mh-z19b input, there is nothing happening when trying to read the values. I had configured it to use /dev/ttyS0 and I also tried using a UART-USB converter instead of the TX-RX GPIO pins, not much success.
I don’t know what’s happening, but here is the log about the moment when mycodo tries to acquire data.
2022-01-29 10:40:31,407 - INFO - mycodo.controllers.controller_input_bd84bcbf - Activated in 403.7 ms
2022-01-29 10:40:31,407 - DEBUG - mycodo.daemon - Input controller with ID bd84bcbf-2890-45c0-bd69-9d9f0e392c39 activated.
2022-01-29 10:40:32,420 - DEBUG - mycodo.inputs.mh_z19b_bd84bcbf - No response
2022-01-29 10:40:32,456 - DEBUG - mycodo.controllers.controller_input_bd84bcbf - Adding measurements to InfluxDB with ID bd84bcbf-2890-45c0-bd69-9d9f0e392c39: {}
2022-01-29 10:40:37,407 - ERROR - mycodo.controllers.controller_input_670a2d3b - StopIteration raised 3 times. Possibly could not read input. Ensure it’s connected properly and detected.
2022-01-29 10:40:40,998 - ERROR - mycodo.controllers.controller_input_8a9cea18 - Mycodo is attempting to acquire measurement(s) from an Input that has already critically errored. Review the log lines following Input Activation to investigate why this happened.
Also, I did use a 5k resistor between my VCC and Tx, I really don’t know what to do from know since I can get reading through mh_z19.read() over ssh.
Providing just an error is not enough information to replicate your environment or diagnose the issue. You need to provide details about the physical connections as well as the software settings used to be able to investigate the issue.
Also, are you sure you have a MH-Z19B and not a MH-Z19? It looks like it’s failing on ABC, which is only present in the B version.
Physical connections of the hardware, any and all settings you configured in software… all of these are needed to diagnose an issue. None should be assumed.
Is /dev/ttyAMA0 the location of your serial device connected to the sensor?
i guess so. isn’t AMA0 the default location? because again, it was working via CLI - all set to default. only one UART device connected.
how would i found out if AMA0 was correct?
anyway; i now tried a cp210x usb converter with /dev/ttyUSB0 and was working directly
like many others, unfortunately I also have problems with the MH-Z19. Since many days I’ve tried everything that is on my mind, but unfortunately I do not know any further, so I would be very happy about your help.
I have the MH-Z19C-PC connected to the USB-Uart converter CP2102 as follows: CP2102 MHZ-19
RX TX
TX RX
GND GND
VCC VCC
As input in Mycodo I used the sensor MH-Z19 (without B). Uart Device was set to /dev/ttyUSB0.
I use a Raspberry 4b.
The red LED of the sensor, which is located behind the fleece, is blinking steadily.
2023-02-07 10:56:26,039 - ERROR - mycodo.inputs.mh_z19_2fb1f0f8 - Error 101: Device not set up. See https://kizniche.github.io/Mycodo/Error-Codes#error-101 for more info.
2023-02-07 10:56:26,040 - ERROR - mycodo.controllers.controller_input_2fb1f0f8 - StopIteration raised 3 times. Possibly could not read input. Ensure it's connected properly and detected.
2023-02-07 10:56:36,747 - DEBUG - mycodo.inputs.mh_z19_2fb1f0f8 - No response
2023-02-07 10:56:36,752 - DEBUG - mycodo.controllers.controller_input_2fb1f0f8 - Adding measurements to InfluxDB with ID 2fb1f0f8-2beb-4528-be35-2718dee92226: {}
2023-02-07 10:56:41,002 - ERROR - mycodo.inputs.mh_z19_2fb1f0f8 - Error 101: Device not set up. See https://kizniche.github.io/Mycodo/Error-Codes#error-101 for more info
Thank you for your fast response.
I checked as you said. But it doesn’t work either.
pi@raspberrypi:~ $ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 10c4:ea60 Silicon Labs CP210x UART Bridge
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@raspberrypi:~ $ dmesg | grep ttyUSB
[ 6.124111] usb 1-1.1: cp210x converter now attached to ttyUSB0
pi@raspberrypi:~ $
So the converter runs at USB0.
I configured this USB port already in Mycodo (see the screenshot from previous post).
Oh…I just checked your message.
You are using MH-Z19C
Only MH-Z19 and Mh-Z19B are supported in Mycodo. To use MH-Z19C you need to create custom input and if you find it difficult then replace the sensor with Mh-Z19 or 19B
Sorry for picking up an old thread, but I my MH-Z19C is on the way to me and I started to prepare the mycodo and probably will face same situation. Were you able to create a custom input for the C version of the sensor?