Exercises for session 3: MQTT and Cayenne

Exercise 1:

Install mosquitto on your machine. On Ubuntu Linux this can very easily be accomplished with apt. On Windows it is almost as easy. For details see


Try the mosquitto communication:

  • Start the mosquitto broker

  • Start mosquitto_sub subscribing to the “AFNOG19” topic

  • Start mosquitto_pub publishing some message to the topic “AFNOG19”

  • observe the message being seen in mosquitto_sub

Exercise 2:

Write you own MQTT client in Python publishing a message to “AFNOG19” every 2 s.

Have a look at the umqtt.simple class to see how to accomplish this. Write the program and start it with thonny. You must know the IP address of the machine on which your mosquitto broker is running. Use ifconfig to find out.

Subscribe to the “AFNOG19” topic with mosquitto_sub and observer that the messages are arriving.

Write an MQTT client that subscribes to the “AFNOG19” topic and that prints messages coming in.

Write a program controlling a LED as we did during the lectures.

Exercise 3:

Register a user on https://mydevices.com/cayenne/signup.

Watch the introductory film and have a look at the documentation pages.

Add a device by clicking on “Bring Your Own Thing”. Have a look at your Cayenne credentials.

Exercise 4:

Write a program connecting to Cayenne. Observe that the dashboard is coming up.

Exercise 5:

Write a program that sends a dummy voltage value to Cayenne on channel 0. The voltage values should range from 0 to 3300 mV (the voltages on the ESP8266). Wait for 2 s minimum between each value.

Observe the widget coming up on the dashboard.

Fix the widget on the dashboard and change the widget parameters (e.g. the name).

Exercise 6:

Add a gauge widget with ranges 0 .. 1V, 1V .. 2V, 2V .. 3.3V. Run your program sending the dummy voltages and observe how the dashboard displays them.

Exercise 7:

Add a dummy measurement on atmospheric pressure to your program. The normal air pressure is around 950 hPa (hecto Pascal).

Exercises 8:

Create a slider and a push button on your dashboard.

-- Uli Raich - 2019-05-15


This topic: AFNOG > WebHome > AFNOGWorkshop2019 > AFNOG-2019Slides > WorkshopExercises > Session3
Topic revision: r1 - 2019-05-15 - UliRaich
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback