User manual
NanoESP/MyMQTTiD/climate/light
NanoESP/MyMQTTiD/climate/hum
As always, replace MyMQTTiD with your personal ID. You now see in the browser how the data arrive in quick succession. Next subscribe to the
following topic:
NanoESP/MyMQTTiD/climate/status
You ought to receive the message "online." Now disconnect the board from the power. Logically, you should now no longer receive any new
temperature data. However, after approx. 10 seconds, the status changes from "online" to "offline." How is that possible if the board can't send
any messages at all anymore?
The trick lies in the last will message that was defined upon connection to the broker. This message is sent when the connection is suddenly
broken. But it takes a while for the broker to notice the interruption of the connection. How long it takes is likewise defined when the connection
is established, with the keep-alive time. If no message is sent from the board to the broker within the time given there, the broker assumes that
the connection was broken. This time is defined in the library as standard at 120 seconds. For today's test, however, it is 10 seconds. So that the
connection is not cut off only because the NanoESP currently has nothing to report, there is the stayConnected command. Here, if not stated
otherwise, a ping is sent to the broker after half of the keep-alive time as a sign that the connection is still active.
Day 24: Gift box
With the last test in this Advent, we get really Christmasy. We're building a reusable gift box with which you can delight your relatives. Every time
someone opens the present, the contents are lit up in an individual colour, and a Christmas sound plays.
Behind today's door is a retro-reflective sensor. This is actually two components, an IR transmitter diode and a phototransistor. It's not very easy
to see which way the elements have to be connected in terms of polarity. For this reason, it's best if you connect the photoelectric sensor with
the connection cables according to the example shown. Then you won't be able to switch the polarity as easily.
This is how to connect the retro-reflective sensor.
Today's layout contains many components, so it all looks a bit confusing at first glance. In addition to the retro-reflective sensor, which serves as
a sensor to detect the opening of the package, the RGB LED and the piezo sound transducer are used.
The last layout of the Advent calendar
After you have loaded today's programme on the controller, go once more to the
http://www.hivemq.com/try-out/ site and connect to the broker broker.fkainka.de. Once you're there, you can now begin to dedicate one topic
each to the persons to whom you want to give gifts according to the following model:
NanoESP/MyMQTTiD/present/person/color
NanoESP/MyMQTTiD/present/person/song
where you replace "MyMQTTiD" with your personal ID and "person" with the person to whom you want to give the present. In the topic "color,"
publish a colour according to the pattern you already know, rgb(X,X,X), and in the topic "song" publish a number between 0 and 5, which stands
for a predefined song. Both messages must be equipped with the Retain flag. For three persons, for example, it would look like this:
Topic Value Retain
NanoESP/MyMQTTiD/present/mother/color rgb(255,255,0) X
NanoESP/MyMQTTiD/present/mother/song 2 X
NanoESP/MyMQTTiD/present/father/color rgb(0,0,255) X
NanoESP/MyMQTTiD/present/father/song 1 X
NanoESP/MyMQTTiD/present/sister/color rgb(255,0,255) X
NanoESP/MyMQTTiD/present/sister/song 4 X










