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
182 stars 37 forks source link

function abc_off() work fine but function read() not work #33

Closed temycor closed 2 years ago

temycor commented 2 years ago

Hello everyone, I come to comment on a positive and a negative result. I have raspberry pi 3 b +. I have tested the abc_off () function for 7 days continuously and it works fine. On the other hand, when I print(mh_z19.read_from_pwm ()) everything goes well and I get the correct reading, but when I print (mh_z19.read()) I get an error. I attach an image with the error that I get. I have previously made the configuration included in this link but I keep getting the error of the attached image. Somebody could help me?

Thank you

image

UedaTakeyuki commented 2 years ago

Hi temycor

How can I read your attached error?

What does the first line ``{'co2': 345.0} mean? You issued a series of mh_z19.read() then the first one was succeeded and 2nd, 3rd one was faulted?

temycor commented 2 years ago

Hi UedaTakeyuki, I have a script in which I read ppm via pwm and serial port (uart). The first line is the result of the pwm read. When reading through the serial port (uart) the error 13 occurs (attached image) and the response is None. I thought the problem was the serial port configuration, but I have configured the serial port as indicated in its github profile but it also gives error. I hope I have clarified your doubts and can help me solve the error.

UedaTakeyuki commented 2 years ago

I see.

Do you read /dev/serial0 with root permission or other appropriate?

temycor commented 2 years ago

I am running this script in python 3.7.3:

import mh_z19

print(mh_z19.read_from_pwm())
print(mh_z19.read())
UedaTakeyuki commented 2 years ago

Did you run the script with sudo? In general, a serial port requires root permission.

sudo python3 YOUR-SCRIPT

temycor commented 2 years ago

This is the result. I think my mhz-19 is broken. I used it with my arduino and when I did the reading through a serial connection, the sensor did not return any value either. The sensor only returned the concentration value to me when I did the reading via PWM. Is there a way to run my script like sudo outside of the console?

Sin título

temycor commented 2 years ago

How can I configure raspberry pi 3b + to be able to read the concentration value from my mhz-19 sensor via serial connection from my python script?

UedaTakeyuki commented 2 years ago

refer https://github.com/UedaTakeyuki/mh-z19#in-case-you-cant-get-the-value

UedaTakeyuki commented 2 years ago

use without sudo https://github.com/UedaTakeyuki/mh-z19/wiki/How-to-use-without-root-permission.

temycor commented 2 years ago

Thank you. Tomorrow I will implement your suggestions.

UedaTakeyuki commented 2 years ago

No feedback for 5 days.

temycor commented 2 years ago

Excuse the delay. For work reasons, I have not yet been able to carry out the last two recommendations. I will try to carry them out as soon as possible to send you an answer. Thank you.