In this lab, we learn how to send data between applications and use other services. In particular, we will use the Sense HAT on the Raspbery Pi, and continuously publish data to dweet.io. The data is the sensory data from the Sense HAT. Once data is sent to dweet.io, we will use Freeboard.io to build a dashboard that visualizes the data.

Dweet

Goal: You are able to store some data in a service like Dweet, using its API. Dweet is a service that buffers data from devices. It’s a bit like Twitter, but for devices. As long as the streams of data are public and not stored for a longer period, Dweet is free to use.

Hints:

  • You can work on your own laptop (with a good web browser). Use the Raspberry Pi only for the part where you use the Sense HAT.
  • You do not need to sign up or log into Dweet.

Dweet via Browser HTTP

Tasks:

  • Visit http://dweet.io
  • Select a unique name for your “thing”
  • Do the example described under Dweeting
  • Do the example described under Getting Dweets

For the Report:

  • Describe the examples above.
  • Copy the response you receive from Dweet.
  • Which communication pattern is used when you send data to dweet.io?
  • Show a sequence diagram to explain what is happening over time, including the Sense HAT, the Python program on the Raspberry Pi, and Dweet.io.

Dweet via Python

Tasks:

  • Use Python on the Raspberry Pi 3, with the Sense HAT mounted.
  • Figure out how to sent a HTTP request in Python
  • Send the URL you figured out above
  • Figure out how to get the response in Python, and print it out
  • Compare with the results from above

Now we want to create an application that sends all sensor data from the Sense HAT into Dweet.

Tasks:

  • Send the data periodically, every 30 seconds.
  • You may have to format a string so it corresponds to a JSON message, see json.org
  • As before, print the response you get for each request.
  • Check using your browser if Dweet stores the correct data.
  • Keep the program running, since we want to monitor the data in the next task

For the Report:

  • Document what you did, as always.
  • Show important parts of the code, and explain them.
  • Show responses from Dweet.
  • Illustrate all with a sequence diagram.

Freeboard

Goal: You are able to create a Freeboard visualization with the data sent from the Sense HAT via Dweet.

Freeboard is a web application that can create dashboards to visualize all kinds of data. It works together with Dweet, so that you can visualize data

Tasks:

  • Go to freeboard.io and sign up.
  • Create a new board.
  • Follow the freeboard tutorial
  • Build a board so that you visualize all data (or as much as possible) from the Sense HAT

For the Report:

  • Document what you did, as always.
  • Show relevant screenshots, and of course a nice screenshot of the final board with data from the Sense HAT.