1-wire
All Pigeon computers feature a single-channel 1-Wire master interface utilizing the DS2482S-100+ chip. An external MOSFET is incorporated to supply additional power to the 1-Wire line, enabling support for 1-Wire devices that may require higher current temporarily for operation.
By default, the OWFS (1-Wire File System) is installed and configured.
For instance, let's demonstrate how to read the temperature from the 1-Wire digital thermometer DS18B20. The following table outlines the connections between the Pigeon and the DS18B20.
Table 1. Connections
1-WIRE | DS18B20 | TO-92 |
---|---|---|
GND | GND | 1 |
DQ | DQ | 2 |
+5V | VDD | 3 |
Note: While the VDD connection is optional, it is recommended for longer cable lengths.
List devices on the 1-Wire bus:
ls /mnt/1wire/
28.06D63C020000 alarm bus.1 simultaneous structure uncached
28.D3E93C020000 bus.0 settings statistics system
There are two devices detected on the 1-Wire bus, and both of them are DS18B20 thermometers.
Read the temperature of the first DS18B20 thermometer:
cat /mnt/1wire/28.06D63C020000/temperature
27.6875
The data from the 1-Wire devices can be viewed through the owfs server. Open a web browser on a computer other than the Pigeon, and navigate to the Pigeon's IP address followed by port 2121. For example:
http://192.168.1.14:2121/
Python
The following example demonstrates how to read the temperature of a DS18B20 thermometer using Python - ds18b20.py
wget https://raw.githubusercontent.com/kristech/pigeon-rb-examples/master/Python/ds18b20.py
nano ds18b20.py
#change id variable to id of your DS18B20
chmod u+x ds18b20.py
./ds18b20.py