With the ESP8266 modules or an Arduino, it is very easy to build your own connected objects (DIY IoT) and integrate them into a home automation server with the MQTT protocol (with Mosquitto for example). Jeedom, the home automation server entirely in French, allows you to easily integrate your connected objects. In this article we will learn how to install the Mosquitto Broker to communicate on an existing Jeedom server and connect a first object to it and display it on the Dashboard.
Install the Mosquitto Broker on Jeedom
We will not go into the details of the operation of MQTT and Mosquitto. I refer you to this previous article which explains how to install and take over the Broker MQTT Mosquitto. Jeedom running on a classic Raspbian Linux distribution, it is very easy to install MQTT. I have a preference for Mosquitto but you can install others (see the article on a selection of Brokers online).
Open the Terminal add execute sudo apt-get install mosquitto
Then we install mosquitto-clients which allows to subscribe, publish and manage the users to secure your broker. It is optional but it can always be used to be able to verify that one receives many messages coming from the devices that have been developed.
sudo apt-get install mosquitto-clients
It is done. At the end of the installation, Mosquitto is operational.
If you have realized the temperature probe based on an ESP8266 Wemos D1 mini (presented here), plug it in and run the following command to check that you receive the temperature and humidity messages.
mosquitto_sub -h localhost -t sensor/# -v
Small translation of the order for those who discover MQTT. We subscribe (mosquitto_sub) to the broker (-h) localhost (or the ip address of the broker) to the topic (-t) sensor / # (# all sub-topic) -v the value).
Subscription is stopped with Ctrl + C
Add the MQTT plugin to Jeedom
Now that we receive data from the DHT22 temperature probe using the ESP8266, let’s see how to integrate the measurements into Jeedom.
Go to Plugins -> Manage plugins then Go to Market
Search the keyword MQTT or go to the section Home automation protocol
Open the plugin of the plugin -> Install stable
At the end of the installation, press OK.
Go back to the list of plugins and press Activate (green next to Action) to activate the plugin. It will take a few more minutes for Jeedom to finish installing the dependencies (or tap Relaunch to start the installation immediately). You can follow the installation process by pressing View log
Create new object
If you know Jeedom, you can skip this step.
Before you can display the values measured by the probe, you must already create an object to which the probe will be associated.
To create an object, go to Tools -> Objects and then Add
Give it the name of “kitchen” for example. You can give it a color, an icon (the names are in English). It is also possible to create an object tree by specifying a parent. If you’re new to Jeedom, there’s no parent available.
Combining the temperature sensor with the kitchen object
Go back to Plugins -> Home automation protocol -> MQTT
Jeedom is very powerful, it automatically detects the Topics available on Mosquito and automatically creates new equipment.
- Click on the sensor device to edit it.
- Give it a name, for example DHT22
- A parent object, Cooking in this example
- A category. Let’s say Heating for a temperature probe
- Activate and make visible
- In the Information block, choose the Temperature and Humidity category
- Save the equipment
Finally, change the topic names. It is possible to choose whether or not to display each topic. You can test the correct data reception.
History of measures
Another small refinement to own its own home automation server, one can record the measures and the past actions. Small bug (of the version used for the article certainly), the button historiser disappears after a backup of the equipment. It is enough to leave and return on the board of the latter to make it visible.
Turn on Histo to keep measurements.
To view the graphs, go to Analysis -> History
Choose the measurements to display on the graph.
View the Dashboard
Cool, more than just see what it looks like. Go to Home -> Dashboard
At the top of the screen is a category filter (the bottom of each Widget and colored in a different color, eg blue for heating).
Then we find our Kitchen item with the previously created DHT22 equipment.
Here, I hope this little tutorial will help you. The MQTT plugin is really very simple to use. Little regrets, however. It is not possible (in the version of 13/04/2016) to assign a unit to the Topic, nor to associate the equipment with a Widget to customize the display in the Dashboard.
- How to store data on a micro SD card. Arduino code compatible ESP32, ESP8266
- Getting started Arduino. Receive commands from the serial port (ESP32 ESP8266 compatible)
- C++ functions print•println•printf•sprintf for Arduino ESP32 ESP8266. Combine•format → serial port
- C++ String functions. concat•c_srt•indexOf•replace•subString… for Arduino, ESP32, ESP8266
- How to assign a fixed IP to an ESP32 ESP8266 or ESP01 project
- ESP01. Get started with the Arduino or PlatformIO IDE. Which module to choose? Pinout