ESP32 UDP broadcaster to send information to other devices

As I want to have the basic data from my weather station available on other devices as well, the data is sent periodically as UDP broadcasts on the local WiFi network.

As the status data of all my devices are “standardized” the broadcast message has to be in JSON object format like

where

  • “de” is the device name, “wei” stands for weather internal
  • “te” is the temperature
  • “hu” is the humidity
  • “hi” is the heat index
  • “dp” is the dew point
  • “cr” is the comfort ratio of temperature and humidity
  • “pe” is the human perception of temperature and humidity

The status data is prepared inside the routine that reads the measurements from the DHT sensor and stored in the global string tempMsg.

The string is then broadcasted by a timer every 1 minute from another task

The function udpSendMessage starts an udpServer on the given port and sends a message to the given IP address. If the IP address is a broadcast address (indicated by the 255 of 192.168.0.255) the package is send as a broadcast.

 

Loading...
Facebooktwittergoogle_plusredditpinterestlinkedintumblrmail

Leave a Reply

Your email address will not be published. Required fields are marked *

Free Link Directory