Skip to content

Temperature and Humidity Sensor

Sonbus SM7820B Temperature and Humidity Sensor

Preparation

  • Rhino Pi A1
  • Sonbus SM7820B temperature and humidity sensor
  • Additional cables
  • External 5V power supply

Hardware Connection

  1. The sensor requires at least 5V power. Since the Rhino Pi A1 5V pin and GND pin are still under development, this example uses an external power supply for the sensor.

  2. Connect the sensor RS485 A/B signals to the Rhino Pi A1 RS485 A/B interface.

alt text

Test

The Sonbus temperature and humidity sensor requires a manual measurement command to return results. Each command produces one result.

  1. Because minicom cannot easily send raw hexadecimal input, create a script to convert hexadecimal text to binary and send it to the serial port. Example script:
shell
#!/bin/bash
# Check parameter count
if [ "$#" -ne 2 ]; then
    echo "Usage: $0 [serial port] [hex data]"
    exit 1
fi

SERIAL_PORT=$1
HEX_DATA=$2

printf "$HEX_DATA" | xxd -r -p > $SERIAL_PORT
  1. Send the measurement command using the script:
shell
./send_hex.sh /dev/ttyHS1 '010300000002C40B'

/dev/ttyHS1 is the RS485 device node on Rhino Pi A1.

010300000002C40B reads temperature and humidity measurement data. Other commands, such as baud rate configuration, are available in the Sonbus product manual.

  1. Use minicom on AidLux to receive data. If it is not installed, install it with:
shell
sudo apt update
sudo apt install minicom

Open the serial port:

shell
sudo minicom -D /dev/ttyHS1 -b 9600 -H

-b 9600 sets the baud rate to 9600 (the sensor default).

-H enables hexadecimal display.

alt text

Result Analysis

After sending the request frame, the sensor returns a response frame, for example:

01 03 04 0a e4 17 65 76 07

The response format is shown below:

alt text

Data field 1 is temperature, and data field 2 is humidity. For example, convert 0a e4 to decimal: 2788.

The scale factor is 100, so the actual temperature is 2788 / 100 = 27.88°C, indicating the current room temperature is 27.88°C.