0

I got a new MH-Z19 Sensor, which i connected to my raspberry PI. The first time everything was okay, but later i connected the pins wrong by moving everything by one pin to the left. See the table

2 (power) 4 (Power) 6 (Ground) 8 (TX) 10 (RX)
Should be - V (power) V (ground) V (rx) V (tx)
I connected V (power) V (ground) V (rx) V (tx)

By looks of that I got Power into the ground of the sensor and ground into the rx.

The sensor got really hot and I immediately disconnected the PI from the power source.

The PI boots just fine, and when I connect the sensor to the right configuration, i cannot get any data from it, it still powers (as the orange light blinks), but becomes hot.

The power and ground pins on PI are fine - tried with fan

Is there any way to know

  • if i fried the sensor? Judging from the data sheet it should not get hot when working. If so, can it recover? Can i safely plug it back to raspberry
  • did i do damage to raspberry? Especially UART ports. I tried loopback but when i run this. I see the message i sent only 1 out of 4/5 times
import serial

# Define the serial port and baud rate
serial_port = '/dev/serial0'  # Replace with '/dev/ttyAMA0' for older Pi models
baud_rate = 115200

try:
    # Open the serial port
    ser = serial.Serial(serial_port, baud_rate)
    print(f"Serial port {serial_port} opened successfully.")
    ser.flushInput()
    # Write a message
    message = "Hello, UART loopback test!"
    print(f"Sending message: {message}")
    ser.write(message.encode())

    # Read the message echoed back
    received_data = ser.readline().decode().strip()
    print(f"Received: {received_data}")

    # Close the serial port
    ser.close()
    print("Serial port closed.")

except serial.SerialException as e:
    print(f"Serial port {serial_port} could not be opened: {e}")

1 Answer 1

0

You have destroyed the sensor. It will not recover.

As for the serial link you are not sending line feeds (ser.write) but are expecting to read lines terminated with line feeds (ser.readln).

Perhaps add line feeds to the strings you are writing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.