Table Of Contents

Previous topic

ShiftRegisterSwitch

Next topic

gadgets.sockets

This Page

gadgets.sensors

Thermometer

class gadgets.sensors.thermometer.Thermometer(location, name, addresses, uid, timeout=5)[source]

When you install Ubuntu or Angstom on a Beaglebone you have access to a sysfs interface for dallas 1-wire devices. Connect a DS18B20+ temperature sensor to the beaglebone like this:

+---------+
|         |
|  front  |
|         |
|         |
|         |
+-+--+--+-+
  |  |  |
  |  |  |
  |  |  |
  |  |  |
  |  |  |
  1  2  3

Where:

1 = ground (port 9, pin 1 or 2)
2 = data   (port 8, pin 6)
3 = Vcc    (port 9, pin 3 or 4)

Once you have it connected you can read the temperature from the following file:

$ cat /sys/bus/w1/devices/<unique id>/w1_slave
b8 01 4b 46 7f ff 08 10 8a : crc=8a YES
b8 01 4b 46 7f ff 08 10 8a t=27500

Where <unique id> is the embedded uid of the sensor. Thermometer parses the w1_slave file and reports the temperature to the gadgets system.

To use Thermometer give it a dictionary that maps the location of the sensor to its unique id:

>>> from gadgets import get_gadgets
>>> from gadgets.pins.beaglebone import pins
>>> arguments = {
...     'locations': {
...         'living room': {
...             'temperature': {
...                 'type': 'thermometer',
...                 'uid': 'uid': '28-0000025f0aba',
...              }
...          }
...      }
>>> gadgets = get_gadgets(arguments)
>>> gadgets.start()

Now the thermometer will start and report its temperature to the gadgets system.

event_received(event, message)[source]

event recieved is triggered because of the timeout