Wiznet makers

jondurrant

Published January 15, 2022 ©

0 UCC

0 VAR

2 Contests

0 Followers

0 Following

MQTT Controlled Cooling Fan for home server cabinets

MQTT Controlled Cooling Fan for home server cabinets

COMPONENTS Hardware components

- Jon Durrant

x 1


- Jon Durrant

x 1

H/w schematic, software, 3d models are in repository.

Software Apps and online services

- Jon Durrant

x 1

C++ software for device


- Jon Durrant

x 1

TwinManager - IoT management software


EMQX - EMQX

x 1

MQTT Hub


- MYSQL

x 1

MySQL


PROJECT DESCRIPTION

Project Overview

To build an IoT managed cooling fan system for my home server cabinet. This gets warm as the PoE (Power Over Ethernet) switch generates a lot of heat. This is therefore an ideal solution for a microcontroller with Ethernet onboard. So a good project to test out the W5100-EVB-Pico.

Fan controllers can be managed locally with RGB Led status on the PCB, OLED screen and Rotary Encoder in front of the fans to allow setting of preset temperature and speed. The state of the device is also broadcast on change via an MQTT hub to any authorized listeners. By design this includes a digital twin service which maintains a copy of the device’s state. The digital twin is the only persistent copy of the device's state. On device start up the state is reloaded from the digital twin (data not firmware).

Requirements Met

    • Control speed of two PWM 12V fans
    • Set speed based on temperature read from DS18B20
    • Hold three preset temperatures and associate speeds
    • Allow an override of fan speed for a set period. 10 minutes to 10 days
    • Operate RTC synced to NTP for GMT
    • Operate a maximum speed for night time operation to reduce fan noise
    • Allow local modification of presets, maximum night speed, and fan speed override
    • Update a digital twin with state changes based using MQTT
    • Support get and set operations in support of digital twin protocol over MQTT
    • Connect to MQTT Hub, EMQX
 
Hardware

Electronics:

  • W5100-EVB-Pico
  • OLED SSD1306 128x64 display
  • Common Cathode RGB LED
  • 3 x Resistor 92 Ohms: for LED
  • Rotary Encoder
  • 2x 10nF Capacitors: to tame noisy Rotary Encoder
  • DS18B20 - Temperature sensor
  • Resistor 4.7K Ohms for DS18B20
  • 12V 90mm PCM Controlled fans
  • Buck Converter - to step down 12V to 5V for the Pico Board
  • 12V power supply

Schematic is included in the repository in KiCad format and jpg image. No PCB design is present as this was built as a one off on a prototype board.


 
Casing:

3d Models were used to print guards for the fans with housing for OLED screen and Rotary Encoder.? Also guard on the back of the fans and bracket for holding the PCB. This allowed the whole unit to bolt to the door using 8 M4 80mm bolts (4 per fan).



 
Fan Controller Software

Fan controller operates on a single core of the RP2040. Built from WizNet’s ioLibrary Driver and examples. FreeRTOS is used to provide concurrent task management and implement MQTT protocol. This allows me to upgrade to MQTT over TLS for security purposes.

I adapted my RP2040 IOT Twin framework (https://github.com/jondurrant/twinThingPicoESP)? to support the W5100-EVB-Pico board. This provides a framework to define a state object which will hold all of the attributes of the device (temperature, preset, current speed, etc). It managed updates to and from the MQTT Hub along with notification of changes that we can link into are hardware control. This library (https://github.com/jondurrant/twinThingRP2040W5x00) is reusable for other IoT projects using the WizNet board, and simpler to use that the ESP-01S approach I have used on my Saber Light project to provide WIFI (https://github.com/jondurrant/LSaber1).

A fan control task can then operate from the state attributes to change PWM settings on GP1 and drive the PWM fans.

Local interface management was another separate task managing the oled display, and taking input from the rotary encoder. To allow a sampling strategy for the rotary encoder, this also needs to be a separate task sampling at 2 ms intervals.

A number of libraries are used by the project including:

  • FreeRTOS-Kernel: Task management
  • FreeRTOS-CoreMQTT-Agent: MQTT Library
  • ioLibary_Driver: Drivers for W5100s
  • twinThingRP2040W5x00
  • json-maker: JSON writing for comms
  • tiny-json: JSON parser
  • RP2040PIO-DS18B20: Sensor library
  • pico-ssd1306: Oled Driver
  • RtosComponents: Watchdog module


The DS18B20 was added in after having issues with the onboard temperature sensor. Unlike a Raspberry PI Pico? the W5100-EVB-Pico sensor seems to be being warmed from the circuit board itself. The DS18B20 allowed a true environment temperature to be read.

System Software

I use EMQX as my MQTT hub with MySQL server authentication. The Fan Controller connects to this and authenticates.

Also connected to the MQTT hub is Twin Manager, a python service which listens to device connections and manages a twin copy of the state of the devices. This state is also stored in MySQL. The Twin Manager operates across multiple devices and provides some more complex services. For the Fan Controller functionality though it is simply state preservation.
Documents
  • Jon Durrant

  • Jon Durrant

    Blog on the project

  • Jon Durrant

    Video

  • Jon Durrant

    Back of installed Unit

  • Jon Durrant

    Front of installed Unit

  • Jon Durrant

    PCB

  • Jon Durrant

    Breadboard version

  • Jon Durrant

    3D Printing Model of Guards and Backet

Comments Write