Wiznet makers

elpasojeff

Published July 08, 2024 © GNU General Public License, version 3 or later (GPL3+)

0 UCC

0 VAR

1 Contests

0 Followers

0 Following

IOT Temperature sensor

I will attach a DHT22 temperature sensor to the gpio pins and run a MQTT client on the board to publish the results to a broker over TCP.

COMPONENTS Hardware components

WIZnet - W7500

x 1


adafruit - DHT22 temperature-humidity sensor

x 1

Software Apps and online services

microsoft - VS Code

x 1


Autodesk - Fusion 360

x 1

designing


UltiMaker - Cura

x 1

for printing


Home Assistant Core Team and Community - Home Assistant

x 1


PROJECT DESCRIPTION

Thank you for providing the Wiznet Surf5 board to me.  I thoroughly enjoyed learning about this board, it's capabilities, and it's shortcomings.  It's integrated TOE is a fantastic addition.

In my project, the Wiznet Surf5 has a DHT22 temperature/humidity sensor hardwired to the board using wires.  I used GPIO_Pin_14 which is very near the 3.3v(out) and GND pins.  This allowed me to solder 3 wires there and use the jumper wires provided with the purchase of the DHT22.  I highly suggest using flux paste when attempting to solder wires directly to the board.  Power is supplied from the wiznet board to the sensor.   The handshaking between the Wiznet board and the DHT is relatively simple.  The DHT responds supplying 40bits of data on GPIO_Pin_14.

I found that the ability for the wiznet board to check the Pin14 to be speedwise inadequate at it's current clock rate.  Therefore I changed the PLL level to 4 in software, basically overclocking the board by 4 times.  This allowed the wiznet board to sample about 10 times for each bit sent from the DHT.  Each bit is a 1 (3.3v), and a data=0 is represented by that 1 lasting for <30us, while a data=1 is that (3.3v) lasting for 50us.  So the result from overclocking showed that a data=0 was a sampling of 3-4 times at 1(3.3v) then 0, while a data=1 sampled 9 times at 1(3.3v) then 0.  The software parses these samples, and then calculates the real life values.

The wiznet board communicates as a client to an MQTT Broker (Mosquito) running on a home assistant (green) controller.  My software (main.c) is using (including) the libraries for MQTT designed by Kim & Bang of IBM in 2016.  These libraries were provided for use on the W5500 Wiznet board.  I successfully used them on the W6100 board and so I copied the same code and installed it in the libraries directory for the W7x00 Surf5 project. 

The wiznet board reads the data from the sensor at regular intervals and then creates an MQTT packet using settings configured in the header files - (TOPIC, Qos, etc.) - and inserts the temperature and humidity into the payload - in json/keys format.  Then the software gives this data packet to the MQTT code which sends the data to the MQTT Broker using a socket - (publishes to the topic). 

The MQTT Broker provides the information to any subscriber.  I created entries in my configuration.yaml so that Home Assistant can understand the devices, and that the information is coming from the MQTT topic.  Then I created automation entry to act on the data provided by the device.  This way I am able to control my air conditioning system from the Home Assistant hub in an elaborate fashion.  The hub also stores the data in an MQTT database (automatically setup) to be retrieved at any time.

I designed a 3d box and cover for the Wiznet Board (which actually fits the 5500, 6100, and now the 7500) using Fusion 360.  The box and cover provide protection for the wiznet board and allows the POE ethernet wire access to the rj45 onboard connector.  Also there is access to the micro-usb connector.  Lastly, the DHT22 can be mounted on to the cover by using the screw-holes extruded through it.  This allows the temperature sensor to be attached with an unobstructed sensing of the environment.  The jumper wires lead from the DHT and down through the cover in a larger square hole extruded in the cover.  I supplied the .stl file for printing the box and cover on a 3d printer.  I used regular PLA which is adequate.

The advantage that the W7500 with Surf5 is the POE allows me to drive the whole system with just the ethernet cable, whereas the W6100 required me to connect a POE Y-adapter to supply power to the board to the micro USB connector and then split the data to the ethernet port.

(I was able to prove a working prototype and had 11 separate samplings from the DHT and each of those published to the broker, and successfully viewed the data on the broker.  However, I am continually evaluating the software for continued stability.)

Documents
  • Main

    the main.c file

  • DHT Temperature Sensor

    The manual for the DHT Temperature Sensor

  • Wiznet Cover

    STL file for 3d printing the cover

  • Dual Timer code

  • CmakeLists.txt

    added the MQTT entry and the DEBUG_PRINT substitution.

  • UserSettings.h

Comments Write