icon

Temperature Monitoring on W55MH32L-EVB

Monitor temperature with DHT22, display on TM1650, and control motor + LED above threshold.

Temperature Monitoring on W55MH32L-EVB
HARDWARE LIST
1 DFRobot DHT22 Temperature and Humidity Sensor
1 W55MH32L-EVB
1 TM1650
1 Motor Module
1 LED Module
1 Jumper wires (generic)

Story

The W55MH32L-EVB is a powerful Ethernet-enabled microcontroller evaluation board featuring the W55MH32L chip. At its heart is a 32-bit Arm® Cortex®-M3 core running at up to 216MHz, with 1024KB of flash memory, 96KB of SRAM, and a fully integrated hardware TCP/IP offload engine (TOE).

In this project, we'll build a temperature monitoring system that:

  • • Reads temperature data from a DHT22 sensor
  • • Displays the temperature on a TM1650 4‑digit 7‑segment display
  • • Automatically turns on a motor and an LED when the temperature exceeds 23°C
  • • Provides clear console feedback for debugging

This is a perfect starting point for environmental monitoring, smart home automation, or any project that requires conditional actuation based on sensor input.

Pin Connections

CODE
Component	Pin	    W55MH32L-EVB Pin
DHT22	        VCC	    3.3V
	        GND	    GND
	        DATA	    PC6

TM1650	        CLK	    PB10
	        DIO	    PB11
	        VCC	    3.3V
	        GND	    GND

Motor Module	INA	    PG8
	        INB	    PG7
	        VCC	    5V
	        GND	    GND

LED Module	VCC	    3.3V
	        GND	    GND
	        Signal	    PC7

Setup

Installing Required Libraries

The DHT22 and TM1650 drivers are needed:

  • • DHT22 – The DHT module is included in standard MicroPython. Use from dht import DHT22.
  • • TM1650 – Download the TM1650 MicroPython driver from the W55MH32 GitHub repository.

Upload both main.py and tm1650.py to your board's root directory.

Code Explanation

1. Imports and Pin Definitions
CODE
from machine import Pin, I2C
from dht import DHT22
from tm1650 import TM1650

We import the necessary modules:

  • • machine.Pin for GPIO control
  • • machine.I2C for I2C communication with the TM1650
  • • dht.DHT22 for reading the DHT22 sensor
  • • tm1650.TM1650 for the 4‑digit display driver

2. Hardware Initialisation
CODE
# ===== Pin definitions =====
# DHT22
DHT_PIN = "PC6"
sensor = DHT22(DHT_PIN)

# Motor 
MOTOR_INA = Pin("PG8", Pin.OUT)
MOTOR_INB = Pin("PG7", Pin.OUT)

# LED
LED_PIN = Pin("PC7", Pin.OUT)

# TM1650 display (CLK = PB10, DIO = PB11)
i2c = I2C(1)
display = TM1650(i2c)
display.set_brightness(5)

The DHT22 is connected to pin PC6, and the TM1650 is initialised on I2C bus 1 with brightness level 5.

3. Helper Functions
  • motor_on() / motor_off() – Control the motor driver by setting INA and INB pins
  • led_on() / led_off() – Control the LED on PC7
  • display_temp() – Formats the temperature for the 4‑digit display
4. Display Formatting
CODE
def display_temp(temp):
    val = int(round(temp * 10, 0))
    d1 = (val // 100) % 10
    d2 = (val // 10) % 10
    d3 = val % 10
    display.write_digit(1, d1, dp=False)
    display.write_digit(2, d2, dp=True)
    display.write_digit(3, d3, dp=False)

The temperature is displayed with one decimal place. For example, 23.6°C becomes "23.6" with the decimal point on the second digit.

5. Main Loop
CODE
while True:
    sensor.measure()
    temp = sensor.temperature()
    if temp >= 23.0:
        motor_on()
        led_on()
    else:
        motor_off()
        led_off()

Every 2 seconds, the code:

• Measures temperature and humidity from the DHT22
• Updates the display
• Checks if the temperature exceeds 23°C
• Activates the motor and LED if above the threshold, or deactivates them if below

Demo

Conclusion

This project demonstrates how easily you can combine sensor input, display output, and actuator control on the W55MH32L-EVB using MicroPython. With the hardware TCP/IP offload engine, you can later extend this system with Ethernet connectivity, MQTT, or a web interface – all without sacrificing performance.

CODE
# main.py – DHT22 temperature monitor with motor + LED control
from machine import Pin, I2C
import time, gc
from dht import DHT22
from tm1650 import TM1650

# ===== Pin definitions =====
DHT_PIN = "PC6"

# Motor (L9110S: INA, INB)
MOTOR_INA = Pin("PG8", Pin.OUT)
MOTOR_INB = Pin("PG7", Pin.OUT)

# LED
LED_PIN = Pin("PC7", Pin.OUT)

# TM1650 display (CLK = PB10, DIO = PB11)
i2c = I2C(1)
display = TM1650(i2c)

# ===== Helper functions =====
def motor_on():
    MOTOR_INA.value(1)
    MOTOR_INB.value(0)
    print("Motor: ON")

def motor_off():
    MOTOR_INA.value(0)
    MOTOR_INB.value(0)
    print("Motor: OFF")

def led_on():
    LED_PIN.value(1)
    print("LED: ON")

def led_off():
    LED_PIN.value(0)
    print("LED: OFF")

def display_temp(temp):
    # Convert to integer with 1 decimal place (23.6 -> 236)
    val = int(round(temp * 10, 0))

    # Extract digits (4 digits: thousands, hundreds, tens, ones)
    d0 = val // 1000
    d1 = (val // 100) % 10
    d2 = (val // 10) % 10
    d3 = val % 10
    
    display.write_digit(1, d1, dp=False)   
    display.write_digit(2, d2, dp=True)
    display.write_digit(3, d3, dp=False)


# ===== Initialise sensor =====
sensor = DHT22(DHT_PIN)
display.set_brightness(5)

print("DHT22 Temperature Monitor")
print("Threshold: >25°C → Motor + LED ON")
print("Press Ctrl+C to stop\n")

# ===== Main loop =====
while True:
    try:
        sensor.measure()
        temp = sensor.temperature()
        hum = sensor.humidity()

        # Display temperature with decimal point
        display_temp(temp)

        print(f"Temp: {temp:.1f}°C  Hum: {hum:.1f}%")

        # Control motor and LED based on temperature
        if temp >= 23.0:
            motor_on()
            led_on()
        else:
            motor_off()
            led_off()

    except Exception as e:
        print("Sensor error:", e)

    time.sleep(2)
    gc.collect()
License
All Rights
Reserved
licensBg
0