TOAST and MQTT

TOAST is using MQTT to send messages and updates to clients on the MQTT bus. Most Home automation software e.g. like OpenHAB can receive and use MQTT messages.
TOAST can also receive configuration updates via MQTT e.g. change queue names or report intervals.

I am using mosquitto on Linux as MQTT server. It also comes with client commands that let you send messages to the TOAST.
To watch or send MQTT messages you could e.g. use MQTT Spy

Information sent by TOAST

There are two types of messages: periodic messages and event driven messages

Announce (periodic)

On startup and every „announce_interval“ (default: 600) seconds the TOAST sends a status message:

Message queue JSON message
/All_ESP8266/status {„id„:“ESP8266_18:FE:34:A5:C8:78″,“Version„:“1.2.20160704V2″,“Nickname„:““,“Value_Q„:“/1floor/kitchen“,“SSID„:“MySSID“,“IP„:“172.16.0.157″,“Vbatt„:3.19,“WiFi reconnects„:11,“MQTT reconnects„:23,“Interval„:600,“Announce„:7200,“sensors„:[„DHT22″,“Digital Watch“]}

Message:

  • id
    The id is calculated automatically. It is always ESP8266_<MAC-address>
    e.g. „ESP8266_18:FE:34:A5:C8:78“
  • Version
    The sketch version as defined the header file
    e.g. „1.2.20160704V2“
  • Nickname
    There is no default. Set it to any string you like. This is good for identification.
    e.g. „garage node“, weather node“
  • Value_Q
    The mqtt queue the TOAST will send it’s sensor status messages to. This is also the prefix for the digital lines. Having a good name e.g. the location makes the OpenHAB configuration easier.
    e.g. „/1floor/kitchen“ this is the TOAST that is located in the kitchen on the first floor. The smoke detector, connected to a digital line, may report to e.g. „/1floor/kitchen/smoke“ see below
  • SSID
    The WiFi SSID the TOAST is currently connected to. You can have more than one possible SSID’s in your sketch. But this is the one it is connected to
    e.g. „MySSID“
  • IP
    The IP address it received from the network. Note: you will need a DHCP server on the net. This IP will show up in the Arduino IDE for OTA updates
    e.g. „172.16.0.157“
  • Vbatt
    The voltage of the power supply. You can run the TOAST on batteries, but WiFi is very power consuming, so the battery would not last very long.
    e.g. 3.19 Volt
  • WiFi reconnects
    Number of reconnects to WiFi access points
  • MQTT reconnects
    Number of reconnects to MQTT server
  • Interval
    Number of seconds between two reports of sensor status
    e.g. 600 seconds, reports sensor status every 10 minutes
  • Announce
    Number of seconds between 2 announce messages
    e.g. 7200 seconds, the TOAST will send this message every 2 hours (default: 600 seconds)
  • sensors
    List of sensors the TOAST has on board
    e.g. [„DHT22″,“OneWire“, „Digital Watch“] DigitalWatch means the digital pins are input e.g. motion sensor or smoke detectors

Sensor status (periodic)

Every „Interval“ seconds the TOAST sends a message to mqtt containing the values of all connected sensors. The queue name will be taken from „Value_Q“

Message queue JSON message
 /1floor/kitchen  {„id„:“ESP8266_18:FE:34:A5:C8:78″,“t„:1180324,“DHT„:{„Temperature“:24.30,“Humidity“:18.50},“OneWire„:{„28cc3bb1600c7“:30.62}}
  • id
    The TOAST’s id, in case several TOAST are using the same value queue
    e.g. ESP8266_18:FE:34:A5:C8:78
  • t
    the uptime of the TOAST in seconds. Note: this is millis()/1000 and miilis will roll over from time to time
    e.g. 1180324
  • DHT
    The temperature and humidity the DHT22 is reporting
    e.g. {„Temperature“:24.30,“Humidity“:18.50}
  • OneWire
    a list of one wire addresses and the temperature the DS18 are reporting
    e.g. {„28cc3bb1600c7“:30.62} this TOAST has one DS18 „one wire“ temperature sensor with address „28cc3bb1600c7“ giving 30.62 degrees celcius

Digital pin change (event driven)

If one of the digital pins, observed by the sketch, changes the TOAST will send a message immediately
The message queue is „Value_Q“ as prefix followed by a string that can be set either in the sketch or later by a configuration message.

Message queue JSON message
/1floor/kitchen/smoke {„id„:“ESP8266_18:FE:34:A5:C8:78″,“t„:1178916,“pin„:0}
  • id
    The TOAST’s id, in case several TOAST are using the same value queue
    e.g. ESP8266_18:FE:34:A5:C8:78
  • t
    the uptime of the TOAST in seconds. Note: this is millis()/1000 and miilis will roll over from time to time
    e.g. 1178916
  • pin
    the status of the pin. 0=low, 1=high

Configuration received by TOAST