Category Archives: Electronics

Setting up the Raspberry pi for 1-wire access

The entry describes various info on the Raspberry Pi’s 1-Wire interface.

To enable the 1-Wire module (defaults to GPIO4 on the Raspberry http://words.mikek.systems/wp-admin/post.php?post=1&action=editPi) run the following from the terminal:

$ sudo modprobe w1-gpio
$ sudo modprobe w1-therm

I guess the first line enables the 1-Wire interface, and the second the automatic reading of the DS18B20 temperature sensor.

As an alternative (if you don’t want to manually enter these every time – which would be very inconvenient in a system that is running unsupervised) you can load these two kernel modules automatically by editing /etc/modules, e.g. “sudo nano /etc/modules” (To save with the Nano editor press Ctrl+O and then press enter to confirm the filename, to quit press Ctrl+x. if you are unable to save, then maybe you forgot the “sudo” at the beginning of the line).

Add/ensure the following two lines can be found in /etc/modules:

w1-gpio
w1-therm

Save and close the file, after next reboot the kernel modules will be loaded without intervention.

^__^
Mike

Sources for the information in this post:

https://learn.adafruit.com/downloads/pdf/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing.pdf

http://nwazet.com/code/loading-i2c-spi-and-1-wire-drivers-on-the-raspberry-pi-under-raspbian-wheezy