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

Still return {} after using pull-up resistor and change freq = 250 and enable_uart = 1 #51

Closed EfraimManurung closed 5 months ago

EfraimManurung commented 6 months ago

Hallo Mr. Takeyuki and everyone,

I still have a problem with my MH-Z19C sensor, it is still always treturn {}, can someone help me? is it compatible for the MH-Z19C or only for B? I already read many blogs and github and I cannot solve my problem

I did my work on Raspberry Pi 5, and I also tried it on my 3+ but still not working. I already tried the pull-up resistor both for RX or TX pins.

WhatsApp Image 2024-04-06 at 2 18 09 AM

return {}

Thank you so much.

UedaTakeyuki commented 6 months ago

Hi Efraim,

There is a track record of operation with MH-Z19C. The MH-Z19 sensor module requires a few minutes preheat time. In case not preheated, you may get the value after preheated.

EfraimManurung commented 6 months ago

Thank you for your response Mr. Takeyuki. I tried again after pre-heating for more than 10 minutes, it is working using ESP32/Arduino Uno but it's not working for the Raspberry Pi. I already followed all your procedures Mr. Takeyuki. Are there other things that I can do?

and what do you mean by a track record of operation with MH-Z19C?

return {} 2
UedaTakeyuki commented 6 months ago

Ah, I mean I don't use this with type C, someone reported that this library worked well with type C. The return value {} without any error message means that the serial interface is connected normally. This library sent command to the sensor normally, and no response returned.

By the way, I don't know about the setting of UART freq = 250. How does this work? Also, this library use the Primary UART (/dev/serial0) as default. If you are using Secondary UART(/dev/serial1) also called Mini UART, please try again with --serial_device SERIAL_DEVICE option.

EfraimManurung commented 6 months ago

I already tried it using a different serial Dr. Takeyuki, do you have other solutions?

Oh so do you mean this library only intended for MH-Z19B not for series C?

return {} 3
UedaTakeyuki commented 5 months ago

Hi Efraim,

I don't mean it. I heard a lot of reports that this runs with type C. Indeed, the serial command and response to calibrate CO2 are NOT different between type B and C. Simply this is your problem it's not working with your environment.

What happens if you run it with /dev/serial1? Not with serial10.

EfraimManurung commented 5 months ago

Dear Dr. Takeyuki, thank you for your response

I believe it is working with serial0 because serial1 I cannot access it. Do you have another suggestion? I also reinstall the OS of Raspberry Pi 5 but still not working.

return {} 4
EfraimManurung commented 5 months ago

Dear Dr. Takeyuki, I solved it! finally, after I tried using Arduino Uno, I realised there is a different address for Raspberry Pi 5 and you're right. I searched different addresses and matched with /dev/tty/AMA0

return {} 6

return {} 5

Thank you so much for your time! I hope this thread will be helpful for someone too.

Efraim.

EfraimManurung commented 5 months ago

dear Dr. Takeyuki,

I have last question, for "sudo python3 -m mh_z19 --all --serial_device /dev/tty AMA0"

how do I set up the program? is there a parameter for it to setup the serial_dev?

the program like in the example "import mh_z19

mh_z19.read_all()"

UedaTakeyuki commented 5 months ago

I'm so glad to hear that your problem was resolved. I appreciate your patient cooperation in investigating and fixing this issue.

Also, thank you for your reporting that there is No documentation to change serial device. I've added it as set_serialdevice(device).

You can use this library in your program as follows:

import mh_z19

mh_z19.set_serialdevice("/dev/ttyAMA0")
mh_z19.read_all()
EfraimManurung commented 5 months ago

Dear dr. Takeyuki, it works! thank you very much for your help. I can continue working on my thesis project.

return {} 7
UedaTakeyuki commented 5 months ago

I hope your thesis project is going well. I would be pleased to see your great thesis once it is completed.