User manual
. The plus thereby always replaces only one topic level. The # replaces all at once. With the topic
MyHome/#
you thus receive all messages that are published in all subtopics of MyHome. The data that are published to a topic can be virtually anything,
from pure texts to measurement values or simple 1/0 commands for switching a light.
Behind today's door is a button. In the test, we primarily want to make a couple of dry runs on the subject of MQTT. So load today's programme
to the board and open the serial monitor. After a short time, you'll see more or less the following messages:
The messages on the serial monitor
The board has thus connected first to the WLAN and then to the online broker. So that the many different users don't fall into the queue, a special
structure must be maintained. You can therefore write only in subtopics of the form NanoESP/MyMQTTiD/... , where you have to replace MyMQTTiD
with the ID that you receive from the board, displayed on the serial monitor. For today, that means that everything is written to the individually adapted
topic NanoESP/MyMQTTiD/test.
So that you can also see what you're writing in a topic, we use an online tool from the company HiveMQ on the computer. With this tool, you can
likewise connect to the broker and subscribe to your personal topics or write to them. Now go to the page
www.hivemq.com/try-out/ and click there on “Try the websocket client”. Now you first have to establish a connection to the broker by entering the
address
broker.fkainka.de in the menu option "Connection" under "Host." The port and the ClientID can remain the same, and the other parameters are also
correct. Click "Connect." If everything worked, the text "connected" appears next to a green dot at the top right and you have the option in other
areas to publish in a topic or to subscribe to a topic.
First click on “Add New Topic Subscription” and enter NanoESP/MyMQTTiD/test in the topic field, where you replace MyMQTTiD with the ID
from the serial monitor. Now reset the NanoESP by pressing the Reset button on the board. After a short time, you should receive the message
“Hello from my NanoESP” in the browser under the "Messages" item. You can also send a message to the board by going into the topic field
NanoESP/MyMQTTiD/test under "Publish" and entering any message you choose, like “Hello from my Browser,” under "Message". Now you
receive the message displayed on the serial monitor. So the communication is up.
Day 21: House automation
In today's test, we'll illuminate the characteristics and possibilities of MQTT in more detail by creating a practical scenario. In the example, there
is a building with two rooms, each of which has a light switch, a light and an alarm sensor. The light switch switches the light of the respective
room on or off. The alarm sensors activate a building-wide alarm.
Normally, seven different devices would be used here, which are all connected to each other through an MQTT broker. But since we probably
have only one NanoESP, this will simulate all devices. For this reason, today's layout looks somewhat complicated. The LED D3 is used today as
the second light. Therefore, today it won't show you whether you're connected to the WLAN. The tilt sensors are used on the extension cables as
alarm sensors. A person could, for example, attach them to doors or windows so that they trigger an alarm if the entry opens. Behind today's
door is the second sensor.
The layout for Day 21 with a 1-kohm resistor
The programme now subscribes to the following topics, where MyMQTTiD is replaced with your ID:
NanoESP/MyMQTTiD/room1/light
NanoESP/MyMQTTiD/room2/light
NanoESP/MyMQTTiD/+/alarm
You can now use the buttons to activate the light in the respective room. If you tip a tilt sensor, the alarm is triggered. It is deactivated either after
20 seconds or if you send a 0 to the alarm topic, e.g. through the http://www.hivemq.com/try-out/ webpage. You are also informed of all
changes through the serial monitor.
Day 22: MQTT Cheerlights
Today's trial is about MQTT and a global project that was presented last year: the Cheerlights Project by Hans Schaaler. For everyone who doesn't










