pi1wire is a library for the Raspberry PI 1Wire sensor.
Here is a simple usecase.
from pi1wire import Pi1Wire, Resolution
for s in Pi1Wire().find_all_sensors():
print(f'{s.mac_address} = {s.get_temperature():.3f}')
s.change_resolution(Resolution.X0_5)
print(f'{s.mac_address} = {s.get_temperature():.3f}')
(For Raspbian OS) Enable 1wire in raspi-config.
$ sudo raspi-config nonint do_onewire 0
This is a class that looks for sensors.
Get a list of OneWire instances.
Get a OneWire instance of the specified MAC address.
Change the resolution of all sensors found and get them as a list of OneWire instances.
The executing user must be able to use sudo.
If the executing user has root privileges and does not need sudo, set the use_sudo
option to False.
This class controls the sensors.
The MAC address property of the sensor.
Get the temperature.
Change the resolution of the temperature sensor.
Depending on the Resolution
definition, change to a resolution equivalent to increments of 0.5°C, 0.25°C, 0.125°C, or 0.0625°C.
The executing user must be able to use sudo.
If the executing user has root privileges and does not need sudo, set the use_sudo
option to False.
An enumeration that defines the resolution setting values.
Resolution is set at 0.5°C.
Resolution is set at 0.25°C.
Resolution is set at 0.125°C.
Resolution is set at 0.0625°C.
- Added function to change resolution.
- Fixed so that the order of sensor detection does not change depending on the file system.
- Added check for PowerOnResetValue.
- Initial release.
MIT