Exercise: Raspberry Pi, read measurements

In this exercise you must use Raspberry Pi to

The measurements must be broadcasted using UDP

Connect the DAC+ (Digital Analog Converter) to the Raspberry Pi

The DAC+ is a digital-to-analog (and vice versa) converter. More interestingly is has a few sensors onboard:

All the sensors returns simple bytes (numbers), not temperatures according to the Celsius scale or light according to the Lumen scale.
Temperature sensor is very "lively" - values chanes very frequently

DAC wiring

Wiring (according to the pin-out)

Read measurements

Make a small Python program to read measurements from the sensors. Examples for your inspiration.

The DAC+ has 4 "channels". Before you read from any channel you must specify which channel you want to read from.

bus.write_byte(0x48, 0x01)

Next read will be from channel 1 (0x01)

reading = bus.read_byte(0x48)

Reads a byte from the current channel.

Make a loop. In the loop read from one channel, change channel, make another read: Read all relevant channels - then you take a sleep before taking another turn in the loop.

Print the measurements to the screen.

Broadcast simple data

Before you start broadcasting the measurements you should do some simple broadcasting, like this example.

Run an UDP broadcast receiver on your laptop (the computer connected to the Raspberry Pi): Your laptop firewall must allow outfoing UDP trafic on the port number you broadcast from


You may have programmed an UDP broadcast receiver in the TEK course - otherwise here is an UDP broadcast receiver (check that the port numbers match and that your firewall allows ingoing UDP trafic on the port number).

Broadcast measurements using UDP

Now it is time to combine: Read measurements + broadcast the measurements.

Before you start broadcasting you must define a simple message format: How do you want to format the measurements?

Chose a format the is easy to read.

Run the UDP broadcast receiver to catch som broadcasts ...