1-wire bus

This article illustrates how to interface and manage a Dallas/Maxim DS18B20 thermal sensor to an Arietta G25 board but the same concepts are applicable to all the Acme Systems Linux boards.

1-Wire is a device communications bus system designed by Dallas Semiconductor that provides low-speed data, signaling, and power over a single signal. 1-Wire is similar in concept to I2C, but with lower data rates and longer range. It is typically used to communicate with small inexpensive devices such as digital thermometers and weather instruments.

Dallas/Maxim DS18B20 thermal sensor

The DS18B20 digital thermometer provides 9-bit to 12-bit Celsius temperature measurements. It communicates over a 1-Wire bus that by definition requires only one data line (and ground) for communication with a central microprocessor.

It has an operating temperature range of -55°C to +125°C and is accurate to ±0.5°C over the range of °10°C to +85°C. (read more...).

Arietta G25 wirings

Following is an example on how to wire a Dallas 1-wire sensor to the Arietta G25 using the port PC2 (J4.35). It is possible to wire more sensors on the same lines. Don't forget to enable the 1-wire bus on the device tree file using this utility: Arietta pinout.

Read the temperature

The 1-wire driver automatically scans every 10 seconds if new sensors are plugged on the 1-wire bus.

For each 1-wire device detected a new directory is created on /sys/bus/w1/devices/w1 bus master.


debarm:~# cd "/sys/bus/w1/devices/w1 bus master"
debarm:/sys/bus/w1/devices/w1 bus master# ls
28-0000028f6667  w1_master_add              w1_master_remove
28-0000028fa89c  w1_master_attempts         w1_master_search
driver           w1_master_max_slave_count  w1_master_slave_count
power            w1_master_name             w1_master_slaves
subsystem        w1_master_pointer          w1_master_timeout
uevent           w1_master_pullup

The two directories 28-xxxx indicate that two thermal sensors are probed on the bus (28 is the family ID) and their unique IDs are 0000028f6667 and 0000028fa89c.

The file w1_master_slaves contains an updated list:

debarm:/sys/bus/w1/devices/w1 bus master# ls
debarm:/sys/bus/w1/devices/w1 bus master# cat w1_master_slaves

To read the temperature for each sensor type:

debarm:/sys/bus/w1/devices/w1 bus master# cat 28-0000028f6667/w1_slave
49 01 4b 46 7f ff 07 10 f6 : crc=f6 YES
49 01 4b 46 7f ff 07 10 f6 t=20562
t=20562 indicates that the temperature read is 20.562 °C 

Reading the temperature in Python

These simple programs in Python scan the 1-wire bus to detect the thermal sensors available:


Download this example from playground then launch it by typing:

debarm:/# debarm:~/playground/python/1wire# python scan1w.py
Scan for the available thermal sensors
Sensor ID = 0000028fa89c

This other example reads the temperature from a specific sensor.


Change the sensor ID in the source and try it:

debarm:/# debarm:~/playground/python/1wire# python read.py
Temp=20.38 C


EUR 5.00

1-wire Dallas DS18B20 thermal sensor

The Dallas/Maxim DS18B20 is a 1-wire digital thermometer:

  • Measures Temperatures from -55°C to +125°C (-67°F to +257°F)
  • ±0.5°C Accuracy from -10°C to +85°C
  • Programmable Resolution from 9 Bits to 12 Bits
  • Each Device Has a Unique 64-Bit Serial Code Stored in On-Board ROM

| How to use with the Acme boards | Product description |

EUR 25.00

ARM9 Linux Embedded Module (128MB)

Arietta G25 is a small and low-cost multi-chip module that integrates:

  • a ARM9 @ 400Mhz CPU Atmel AT91SAM9G25
  • a 128MB of DDR2 RAM
  • up to 3 USB 2.0 host ports
  • 20x2 pads for strip pitch 2.54mm (100mil)

Basic Version with no strips mounted. If you need to have any strip mounted take a look to the Welding services

| Product description |