CO2 sensor MH-Z19B at /dev/ttyUSB0 connected keeps reverting to: /dev/ttyAMA0

I’m trying to get my MHZ19B CO2 sensor connected but when adding it in inputs I cannot change the UART device location; as soon as I confirm /dev/ttyUSB0 I Press enter and it activates on /dev/ttyAMA0

I desoldered a couple times the TX/RX to get a reading but I think it’s trying to read from AMA0…

How can I get this to work?

LOGS:

pi@raspberrypi:~ $ udevadm info --name=/dev/ttyUSB0 --attribute-walk

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

looking at device ‘/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.1/1-1.1:1.0/ttyUSB0/tty/ttyUSB0’:
KERNEL==“ttyUSB0”
SUBSYSTEM==“tty”
DRIVER==""

looking at parent device ‘/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.1/1-1.1:1.0/ttyUSB0’:
KERNELS==“ttyUSB0”
SUBSYSTEMS==“usb-serial”
DRIVERS==“cp210x”
ATTRS{port_number}==“0”

looking at parent device ‘/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.1/1-1.1:1.0’:
KERNELS==“1-1.1:1.0”
SUBSYSTEMS==“usb”
DRIVERS==“cp210x”
ATTRS{bInterfaceProtocol}==“00”
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceSubClass}==“00”
ATTRS{bInterfaceClass}==“ff”
ATTRS{authorized}==“1”
ATTRS{bNumEndpoints}==“02”
ATTRS{supports_autosuspend}==“1”
ATTRS{interface}==“CP2102 USB to UART Bridge Controller”
ATTRS{bInterfaceNumber}==“00”

looking at parent device ‘/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.1’:
KERNELS==“1-1.1”
SUBSYSTEMS==“usb”
DRIVERS==“usb”
ATTRS{tx_lanes}==“1”
ATTRS{bcdDevice}==“0100”
ATTRS{bmAttributes}==“80”
ATTRS{bDeviceSubClass}==“00”
ATTRS{removable}==“unknown”
ATTRS{authorized}==“1”
ATTRS{devpath}==“1.1”
ATTRS{devspec}=="(null)"
ATTRS{idVendor}==“10c4”
ATTRS{bConfigurationValue}==“1”
ATTRS{urbnum}==“15”
ATTRS{ltm_capable}==“no”
ATTRS{maxchild}==“0”
ATTRS{bMaxPacketSize0}==“64”
ATTRS{bDeviceProtocol}==“00”
ATTRS{quirks}==“0x0”
ATTRS{manufacturer}==“Silicon Labs”
ATTRS{bMaxPower}==“100mA”
ATTRS{configuration}==""
ATTRS{serial}==“0001”
ATTRS{bDeviceClass}==“00”
ATTRS{busnum}==“1”
ATTRS{version}==" 1.10"
ATTRS{rx_lanes}==“1”
ATTRS{speed}==“12”
ATTRS{product}==“CP2102 USB to UART Bridge Controller”
ATTRS{devnum}==“4”
ATTRS{idProduct}==“ea60”
ATTRS{bNumConfigurations}==“1”
ATTRS{bNumInterfaces}==" 1"
ATTRS{avoid_reset_quirk}==“0”

looking at parent device ‘/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1’:
KERNELS==“1-1”
SUBSYSTEMS==“usb”
DRIVERS==“usb”
ATTRS{removable}==“unknown”
ATTRS{bDeviceSubClass}==“00”
ATTRS{devnum}==“2”
ATTRS{version}==" 2.10"
ATTRS{bMaxPower}==“100mA”
ATTRS{rx_lanes}==“1”
ATTRS{ltm_capable}==“no”
ATTRS{configuration}==""
ATTRS{bNumConfigurations}==“1”
ATTRS{avoid_reset_quirk}==“0”
ATTRS{bMaxPacketSize0}==“64”
ATTRS{quirks}==“0x0”
ATTRS{idVendor}==“2109”
ATTRS{bDeviceProtocol}==“01”
ATTRS{maxchild}==“4”
ATTRS{product}==“USB2.0 Hub”
ATTRS{bcdDevice}==“0421”
ATTRS{devpath}==“1”
ATTRS{speed}==“480”
ATTRS{devspec}=="(null)"
ATTRS{urbnum}==“56”
ATTRS{idProduct}==“3431”
ATTRS{bConfigurationValue}==“1”
ATTRS{bmAttributes}==“e0”
ATTRS{bDeviceClass}==“09”
ATTRS{bNumInterfaces}==" 1"
ATTRS{busnum}==“1”
ATTRS{tx_lanes}==“1”
ATTRS{authorized}==“1”

looking at parent device ‘/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1’:
KERNELS==“usb1”
SUBSYSTEMS==“usb”
DRIVERS==“usb”
ATTRS{bDeviceProtocol}==“01”
ATTRS{manufacturer}==“Linux 5.10.17-v7l+ xhci-hcd”
ATTRS{idProduct}==“0002”
ATTRS{rx_lanes}==“1”
ATTRS{bDeviceClass}==“09”
ATTRS{urbnum}==“30”
ATTRS{bMaxPacketSize0}==“64”
ATTRS{authorized}==“1”
ATTRS{bNumInterfaces}==" 1"
ATTRS{bMaxPower}==“0mA”
ATTRS{bNumConfigurations}==“1”
ATTRS{tx_lanes}==“1”
ATTRS{removable}==“unknown”
ATTRS{serial}==“0000:01:00.0”
ATTRS{version}==" 2.00"
ATTRS{interface_authorized_default}==“1”
ATTRS{configuration}==""
ATTRS{idVendor}==“1d6b”
ATTRS{bDeviceSubClass}==“00”
ATTRS{speed}==“480”
ATTRS{bcdDevice}==“0510”
ATTRS{bmAttributes}==“e0”
ATTRS{devnum}==“1”
ATTRS{quirks}==“0x0”
ATTRS{ltm_capable}==“no”
ATTRS{avoid_reset_quirk}==“0”
ATTRS{busnum}==“1”
ATTRS{bConfigurationValue}==“1”
ATTRS{authorized_default}==“1”
ATTRS{maxchild}==“1”
ATTRS{product}==“xHCI Host Controller”
ATTRS{devpath}==“0”

looking at parent device ‘/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0’:
KERNELS==“0000:01:00.0”
SUBSYSTEMS==“pci”
DRIVERS==“xhci_hcd”
ATTRS{local_cpulist}==“0-3”
ATTRS{max_link_speed}==“5.0 GT/s PCIe”
ATTRS{current_link_speed}==“5.0 GT/s PCIe”
ATTRS{consistent_dma_mask_bits}==“64”
ATTRS{subsystem_vendor}==“0x1106”
ATTRS{msi_bus}==“1”
ATTRS{driver_override}=="(null)"
ATTRS{subsystem_device}==“0x3483”
ATTRS{local_cpus}==“f”
ATTRS{dma_mask_bits}==“64”
ATTRS{vendor}==“0x1106”
ATTRS{ari_enabled}==“0”
ATTRS{max_link_width}==“1”
ATTRS{class}==“0x0c0330”
ATTRS{irq}==“65”
ATTRS{device}==“0x3483”
ATTRS{broken_parity_status}==“0”
ATTRS{current_link_width}==“1”
ATTRS{enable}==“1”
ATTRS{revision}==“0x01”

looking at parent device ‘/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0’:
KERNELS==“0000:00:00.0”
SUBSYSTEMS==“pci”
DRIVERS==“pcieport”
ATTRS{dma_mask_bits}==“32”
ATTRS{subsystem_vendor}==“0x0000”
ATTRS{broken_parity_status}==“0”
ATTRS{consistent_dma_mask_bits}==“32”
ATTRS{revision}==“0x10”
ATTRS{local_cpus}==“f”
ATTRS{ari_enabled}==“0”
ATTRS{device}==“0x2711”
ATTRS{secondary_bus_number}==“1”
ATTRS{max_link_width}==“1”
ATTRS{enable}==“1”
ATTRS{driver_override}=="(null)"
ATTRS{local_cpulist}==“0-3”
ATTRS{vendor}==“0x14e4”
ATTRS{current_link_width}==“1”
ATTRS{max_link_speed}==“5.0 GT/s PCIe”
ATTRS{irq}==“64”
ATTRS{current_link_speed}==“5.0 GT/s PCIe”
ATTRS{class}==“0x060400”
ATTRS{subsystem_device}==“0x0000”
ATTRS{subordinate_bus_number}==“1”
ATTRS{msi_bus}==“1”

looking at parent device ‘/devices/platform/scb/fd500000.pcie/pci0000:00’:
KERNELS==“pci0000:00”
SUBSYSTEMS==""
DRIVERS==""

looking at parent device ‘/devices/platform/scb/fd500000.pcie’:
KERNELS==“fd500000.pcie”
SUBSYSTEMS==“platform”
DRIVERS==“brcm-pcie”
ATTRS{driver_override}=="(null)"

looking at parent device ‘/devices/platform/scb’:
KERNELS==“scb”
SUBSYSTEMS==“platform”
DRIVERS==""
ATTRS{driver_override}=="(null)"

looking at parent device ‘/devices/platform’:
KERNELS==“platform”
SUBSYSTEMS==""
DRIVERS==""


Daemon log:

2021-07-09 14:25:38,078 - INFO - mycodo.controllers.controller_input_2ce87ed6 - Deactivated in 40.9 ms
2021-07-09 14:25:51,832 - ERROR - mycodo.controllers.controller_input_2ce87ed6 - initialize_variables() Exception: Write timeout
Traceback (most recent call last):
File “/var/mycodo-root/mycodo/controllers/base_controller.py”, line 74, in run
self.initialize_variables()
File “/var/mycodo-root/mycodo/controllers/controller_input.py”, line 317, in initialize_variables
self.measure_input = input_loaded.InputModule(self.input_dev)
File “/home/pi/Mycodo/mycodo/inputs/mh_z19b.py”, line 130, in init
self.initialize_input()
File “/home/pi/Mycodo/mycodo/inputs/mh_z19b.py”, line 151, in initialize_input
self.abcoff()
File “/home/pi/Mycodo/mycodo/inputs/mh_z19b.py”, line 199, in abcoff
self.ser.write(bytearray([0xff, 0x01, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86]))
File “/var/mycodo-root/env/lib/python3.7/site-packages/serial/serialposix.py”, line 636, in write
raise SerialTimeoutException(‘Write timeout’)
serial.serialutil.SerialTimeoutException: Write timeout
2021-07-09 14:25:51,833 - INFO - mycodo.controllers.controller_input_2ce87ed6 - Activated in 5160.6 ms
2021-07-09 14:25:51,835 - ERROR - mycodo.controllers.controller_input_2ce87ed6 - 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.
2021-07-09 14:25:57,964 - INFO - mycodo.controllers.controller_input_2ce87ed6 - Deactivated in 67.6 ms

You need to press Save for settings to be saved, before activating.

Yup,

save gives:

  • Success: Modify Measurement

activation afterward responds:

  • Success: Input Activate (SQL)
  • Success: Input controller with ID 1e707d9b-68a5-4b54-b474-a74de253188d activated.
  • Success: Activate Input

but when I reopen by pressing [+] it says AMA0 again…

What version Mycodo are you running?

its 8.11.0 ,

I did find however another save button just below the [+] I was scrolling past… it looks like that button is saving the config! I will have to hook up the co2 sensor again but I don’t think soldering drunk is a great idea! I’ll check back in when I gotten to it!

1 Like

the soldering was a great idea! I pressed the save button on the bottom of the page instead on top… I seem to think clearer now then during the day! thanks again!

This can be rather confusing, having more than one save button on an options page. I’ve been meaning to refactor how options are saved and had the initiative tonight to make some changes. There is now only one Save button for all options. Thanks for the feedback and glad it’s working for you.

1 Like