Example Code for Arduino-Serial Passive (Temperature Read)
Last revision 2026/01/22
Learn how to read temperature data using Arduino's serial passive mode by wiring TX & RX with the MCU, enabling access to sensors like ultrasonic distance and temperature measurements.
Hardware Preparation
- Arduino board: Quantity1
- URM37 V5.0 ultrasonic sensor (SKU:SEN0001): Quantity1
- Jumper wires: Quantity several
Software Preparation
- Arduino IDE: Download from Arduino official website
Wiring Diagram
Follow the wiring method described in the test on software section (connect TX/RX,5V,GND).
Other Preparation Work
- Ensure the sensor's serial level is set to TTL mode (default) using the button method described in Getting Started section.
- Connect the hardware as per the wiring instructions.
Sample Code
// # Editor : roker
// # Date : 05.03.2018
// # Product name: URM V5.0 ultrasonic sensor
// # Product SKU : SEN0001
// # Version : 1.0
// # Description:
// # The sketch for using the URM37 Serial mode from DFRobot
// # and writes the values to the serialport
// # Connection:
// # Vcc (Arduino) -> Pin 1 VCC (URM V5.0)
// # GND (Arduino) -> Pin 2 GND (URM V5.0)
// # Pin TX1 (Arduino) -> Pin 8 RXD (URM V5.0)
// # Pin RX0 (Arduino) -> Pin 9 TXD (URM V5.0)
// # Working Mode: Serial Mode.
uint8_t EnTempCmd[4] = {0x11, 0x00, 0x00, 0x11}; // temperature measure command
uint8_t TempData[4];
unsigned int TempValue = 0;
void setup()
{
Serial.begin(9600);
delay(100);
Serial.println("Init the sensor");
}
void loop()
{
SerialCmd();
delay(200);
}
void SerialCmd()
{
int i;
for (i = 0; i < 4; i++) {
Serial.write(EnTempCmd[i]);
}
while (Serial.available() > 0) // if received data
{
for (i = 0; i < 4; i++) {
TempData[i] = Serial.read();
}
TempValue = TempData[1] << 8;
TempValue = TempValue + TempData[2];
Serial.print("temperature : ");
Serial.print(TempValue, DEC);
Serial.println(" oC");
}
}
Result
This temperature was magnified10 times, in the test, actual tempreture is28.1 degrees Celsius.

Was this article helpful?
