w1thermsensor


Namew1thermsensor JSON
Version 2.3.0 PyPI version JSON
download
home_pagehttp://github.com/timofurrer/w1thermsensor
SummaryA Python package and CLI tool to work with w1 temperature sensors like DS1822, DS18S20 & DS18B20 on the Raspberry Pi, Beagle Bone and other devices.
upload_time2023-09-27 11:44:11
maintainerTimo Furrer
docs_urlNone
authorTimo Furrer
requires_python>=3.7
licenseMIT
keywords w1 w1-therm therm sensor raspberry raspberry pi gpio ds
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # W1ThermSensor

[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/timofurrer/w1thermsensor?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
> Get the temperature from your w1 therm sensor in a single line of code!<br>
> It's designed to be used with the Rasperry Pi hardware but also works on a Beagle Bone and others.

***

![CI](https://github.com/timofurrer/w1thermsensor/workflows/CI/badge.svg)
[![PyPI version](https://badge.fury.io/py/w1thermsensor.svg)](https://badge.fury.io/py/w1thermsensor)
[![codecov.io](http://codecov.io/github/timofurrer/w1thermsensor/coverage.svg?branch=master)](http://codecov.io/github/timofurrer/w1thermsensor?branch=master)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

**Raspberry Pi:** this package is available in Raspbian as `python-w1thermsensor` and `python3-w1thermsensor`.

**Python 2 drop**: all w1thermsensor releases from 2.0 are Python 3.5+

## Supported devices

The following w1 therm sensor devices are supported:

* DS18S20
* DS1822
* DS18B20
* DS28EA00
* DS1825/MAX31850K

## Setup

The following hardware is needed:

* w1 therm compatible sensor (some of them can be bought here: [Adafruit: DS18B20](https://www.adafruit.com/search?q=DS18B20))
* wires to connect the sensor to your board (you might need a breadboard, too)
* a board like the Raspberry Pi or the Beagle Bone

On the Raspberry Pi, you will need to add `dtoverlay=w1-gpio` (for regular connection) or `dtoverlay=w1-gpio,pullup="y"` (for parasitic connection) to your /boot/config.txt. The default data pin is GPIO4 (RaspPi connector pin 7), but that can be changed from 4 to `x` with `dtoverlay=w1-gpio,gpiopin=x`.

After that, don't forget to reboot.

### Hardware-connection


    Raspi VCC (3V3) Pin 1 -----------------------------   VCC    DS18B20
                                                   |
                                                   |
                                                   R1 = 4k7 ...10k
                                                   |
                                                   |
    Raspi GPIO 4    Pin 7 -----------------------------   Data   DS18B20
           (BCM)    (BOARD)

    Raspi GND       Pin 6 -----------------------------   GND    DS18B20

### Soft-pull-up

Alternatively to the hardware pull-up made by a physical resistor, or to the above mentioned software configuration `dtoverlay=w1-gpio,pullup="y"` in /boot/config.txt, the following soft pull-up can be used:

```python
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.IN, pull_up_down=GPIO.PUD_UP)
```

When using this software pull-up, 1-Wire devices will be visible to the kernel only while the program pulls the GPIO pin up.

### Hw device connection verification

Run the following command:

```bash
ls -l /sys/bus/w1/devices
```

You should check the availability of one or more filenames starting with "28-".

Filenames starting with "00-" possibly mean that the pull-up resistor is missing.

1-Wire devices can be plugged in dynamically and are visible to the kernel driver just after their hw connection.

To test reading the temperature, issue the following command:

```bash
for i in /sys/bus/w1/devices/28-*; do cat $i/w1_slave; done
```

## Installation

### From PIP

This possibility is supported on all distributions:

    pip install w1thermsensor

*Note: maybe root privileges are required*

Use the `async` extra to add support for asyncio and `AsyncW1ThermSensor`:

    pip install w1thermsensor[async]

### On Raspbian using `apt-get`

If you are using the `w1thermsensor` module on a Rasperry Pi running Raspbian you can install it from the official repository:

```bash
sudo apt-get install python3-w1thermsensor
```

**Note:** For older versions of this package you might get the following error: `ImportError: No module named 'pkg_resources'` which indicates that you need to install `python-setuptools` or `python3-setuptools` respectively.

### Manually build and install the debian package

    debuild -us -uc
    dpkg -i ../python3-w1thermsensor_*.deb

## Usage as python package

The usage is very simple and the interface clean..
All examples are with the `DS18B20` sensor - It works the same way for the other supported devices.

### Basic usage with one sensor (implicit)

```python
from w1thermsensor import W1ThermSensor, Unit

sensor = W1ThermSensor()
temperature_in_celsius = sensor.get_temperature()
temperature_in_fahrenheit = sensor.get_temperature(Unit.DEGREES_F)
temperature_in_all_units = sensor.get_temperatures([
    Unit.DEGREES_C,
    Unit.DEGREES_F,
    Unit.KELVIN])
```

The need kernel modules will be automatically loaded in the constructor of the `W1ThermSensor` class. <br>
If something went wrong an exception is raised.

*The first found sensor will be taken*

### Basic usage with one sensor (explicit)

The DS18B20 sensor with the ID `00000588806a` will be taken.

```python
from w1thermsensor import W1ThermSensor, Sensor

sensor = W1ThermSensor(sensor_type=Sensor.DS18B20, sensor_id="00000588806a")
temperature_in_celsius = sensor.get_temperature()
```

### Multiple sensors

With the `get_available_sensors` class-method you can get the ids of all available sensors.

```python
from w1thermsensor import W1ThermSensor

for sensor in W1ThermSensor.get_available_sensors():
    print("Sensor %s has temperature %.2f" % (sensor.id, sensor.get_temperature()))
```

Only sensors of a specific therm sensor type:

```python
from w1thermsensor import W1ThermSensor, Sensor

for sensor in W1ThermSensor.get_available_sensors([Sensor.DS18B20]):
    print("Sensor %s has temperature %.2f" % (sensor.id, sensor.get_temperature()))
```

### Set sensor resolution

Some w1 therm sensors support changing the resolution for the temperature reads.
`w1thermsensor` enables to do so with the `W1ThermSensor.set_resolution()` method:

```python
sensor = W1ThermSensor(sensor_type=Sensor.DS18B20, sensor_id="00000588806a")
sensor.set_resolution(9)
```

If the ``persist`` argument is set to ``False`` this value
is "only" stored in the volatile SRAM, so it is reset when
the sensor gets power-cycled.

If the ``persist`` argument is set to ``True`` the current set
resolution is stored into the EEPROM. Since the EEPROM has a limited
amount of writes (>50k), this command should be used wisely.

```python
sensor = W1ThermSensor(sensor_type=Sensor.DS18B20, sensor_id="00000588806a")
sensor.set_resolution(9, persist=True)
```

**Note**: this is supported since Linux Kernel 4.7<br>
**Note**: this requires `root` privileges

### Disable kernel module auto loading

Upon import of the `w1thermsensor` package the `w1-therm` and `w1-gpio` kernel modules get loaded automatically.
This requires the python process to run as root. Sometimes that's not what you want, thus you can disable the auto loading
and load the kernel module yourself prior to talk to your sensors with `w1thermsensor`.

You can disable the auto loading feature by setting the `W1THERMSENSOR_NO_KERNEL_MODULE` environment variable to `1`:

```bash
# set it globally for your shell so that sub-processes will inherit it.
export W1THERMSENSOR_NO_KERNEL_MODULE=1

# set it just for your Python process
W1THERMSENSOR_NO_KERNEL_MODULE=1 python my_awesome_thermsensor_script.py
```

Every other values assigned to `W1THERMSENSOR_NO_KERNEL_MODULE` will case `w1thermsensor` to load the kernel modules.

*Note: the examples above also apply for the CLI tool usage. See below.*

### Correcting Temperatures / Sensor Calibration
Calibrating the temperature sensor relies on obtaining a measured high and measured low value that
have known reference values that can be used for correcting the sensor's readings.  The simplest
way to do this is to measure the melting point and boiling point of water since those values are
known.  This method will only work with waterproof sensors - you will need a different mechanism
for obtaining measured values if you are not using a waterproof sensor.

In order to obtain the `measured_low_point`, fill a container to 80% with ice and add water to the
ice until the ice is floating and water is at the surface.  Submerse your sensor in the ice water,
ensuring it does not touch the container.  Wait 5 minutes for the temperature to stabilize in the
container and then once the sensor readings have stabilized for approximately 30 seconds (readings
remain consistent), record the value as the `measured_low_point`

In order to obtain the `measured_high_point`, bring a pot of water to a rapid boil.  Place your
sensor in the boiling water, ensuring that it does not touch the pot.  Allow the sensor to come up
to temperature and once it has stabilized for approximately 30 seconds (readings remain
consistent), record the value as the `measured_high_point`

Generally speaking, the `reference_low_point` should be left at 0.0 unless you have some special
situation that changes the melting point of water.  Because melting does not involve a gaseous
phase change, the effects of air pressure and altitude on the melting point are minimal.

The `reference_high_point` on the other hand is greatly impacted by air pressure (and thus
altitude).  For example, the boiling point of water is 100.0C at sea level, and is approximately
72C at the summit of Mount Everest (8848m above sea level).  While air pressure is what actually
dictates boiling point, generally speaking altitude is a close enough approximation for most use
cases.  [Engineering Toolbox](https://www.engineeringtoolbox.com/boiling-points-water-altitude-d_1344.html)
has a page that gives you the boiling point of water at different altitudes.

This method is derived from [this Instructable](https://www.instructables.com/Calibration-of-DS18B20-Sensor-With-Arduino-UNO/).

```python
from w1thermsensor.calibration_data import CalibrationData
from w1thermsensor import W1ThermSensor, Unit

calibration_data = CalibrationData(
        measured_high_point=measured_high_point,
        measured_low_point=measured_low_point,
        reference_high_point=reference_high_point,
        reference_low_point=reference_low_point, # optional, defaults to 0.0
    )
sensor = W1ThermSensor(calibration_data=calibration_data)

corrected_temperature_in_celsius = sensor.get_corrected_temperature()
corrected_temperature_in_fahrenheit = sensor.get_corrected_temperature(Unit.DEGREES_F)
corrected_temperature_in_all_units = sensor.get_corrected_temperatures([
    Unit.DEGREES_C,
    Unit.DEGREES_F,
    Unit.KELVIN])
```

### Async Interface

The `w1thermsensor` package implements an async interface `AsyncW1ThermSensor` for asyncio.

The following methods are supported:

* `get_temperature()`
* `get_temperatures()`
* `get_resolution()`

For example:

```python
from w1thermsensor import AsyncW1ThermSensor, Unit

sensor = AsyncW1ThermSensor()
temperature_in_celsius = await sensor.get_temperature()
temperature_in_fahrenheit = await sensor.get_temperature(Unit.DEGREES_F)
temperature_in_all_units = await sensor.get_temperatures([
    Unit.DEGREES_C,
    Unit.DEGREES_F,
    Unit.KELVIN])
```


## Usage as CLI tool

The w1thermsensor module can be used as CLI tool since version `0.3.0`. <br>
*Please note that the CLI tool will only get installed with the Raspbian Python 3 package* (`sudo apt-get install python3-w1thermsensor`)

### List sensors

List all available sensors:

```
$ w1thermsensor ls
$ w1thermsensor ls --json  # show results in JSON format
```

List only sensors of a specific type:

```
$ w1thermsensor ls --type DS1822
$ w1thermsensor ls --type DS1822 --type MAX31850K  # specify multiple sensor types
$ w1thermsensor ls --type DS1822 --json  # show results in JSON format
```

### Show temperatures

Show temperature of all available sensors: (Same synopsis as `ls`)

```
$ w1thermsensor all --type DS1822
$ w1thermsensor all --type DS1822 --type MAX31850K  # specify multiple sensor types
$ w1thermsensor all --type DS1822 --json  # show results in JSON format
```

Show temperature of a single sensor:

```
$ w1thermsensor get 1  # 1 is the id obtained by the ls command
$ w1thermsensor get --hwid 00000588806a --type DS18B20
$ w1thermsensor get 1  # show results in JSON format
```

Show temperature of a single sensor in the given resolution

```
$ w1thermsensor get 1 --resolution 10
$ w1thermsensor get --hwid 00000588806a --type DS18B20 --resolution 11
```

### Change temperature read resolution and write to EEPROM

```
# w1thermsensor resolution 10 1
# w1thermsensor resolution --hwid 00000588806a --type DS18B20 11
```

**Note**: this requires `root` privileges

## Contribution

I'm happy about all types of contributions to this project! :beers:

***

*<p align="center">This project is published under [MIT](LICENSE).<br>A [Timo Furrer](https://tuxtimo.me) project.<br>- :tada: -</p>*

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/timofurrer/w1thermsensor",
    "name": "w1thermsensor",
    "maintainer": "Timo Furrer",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "tuxtimo@gmail.com",
    "keywords": "w1,w1-therm,therm,sensor,raspberry,raspberry pi,gpio,ds",
    "author": "Timo Furrer",
    "author_email": "tuxtimo@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/dd/60/e2dbb207a2b6ed7813aeb976bfb69ef084b3586d5378597e5e5eb225582a/w1thermsensor-2.3.0.tar.gz",
    "platform": "Linux",
    "description": "# W1ThermSensor\n\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/timofurrer/w1thermsensor?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n> Get the temperature from your w1 therm sensor in a single line of code!<br>\n> It's designed to be used with the Rasperry Pi hardware but also works on a Beagle Bone and others.\n\n***\n\n![CI](https://github.com/timofurrer/w1thermsensor/workflows/CI/badge.svg)\n[![PyPI version](https://badge.fury.io/py/w1thermsensor.svg)](https://badge.fury.io/py/w1thermsensor)\n[![codecov.io](http://codecov.io/github/timofurrer/w1thermsensor/coverage.svg?branch=master)](http://codecov.io/github/timofurrer/w1thermsensor?branch=master)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n\n**Raspberry Pi:** this package is available in Raspbian as `python-w1thermsensor` and `python3-w1thermsensor`.\n\n**Python 2 drop**: all w1thermsensor releases from 2.0 are Python 3.5+\n\n## Supported devices\n\nThe following w1 therm sensor devices are supported:\n\n* DS18S20\n* DS1822\n* DS18B20\n* DS28EA00\n* DS1825/MAX31850K\n\n## Setup\n\nThe following hardware is needed:\n\n* w1 therm compatible sensor (some of them can be bought here: [Adafruit: DS18B20](https://www.adafruit.com/search?q=DS18B20))\n* wires to connect the sensor to your board (you might need a breadboard, too)\n* a board like the Raspberry Pi or the Beagle Bone\n\nOn the Raspberry Pi, you will need to add `dtoverlay=w1-gpio` (for regular connection) or `dtoverlay=w1-gpio,pullup=\"y\"` (for parasitic connection) to your /boot/config.txt. The default data pin is GPIO4 (RaspPi connector pin 7), but that can be changed from 4 to `x` with `dtoverlay=w1-gpio,gpiopin=x`.\n\nAfter that, don't forget to reboot.\n\n### Hardware-connection\n\n\n    Raspi VCC (3V3) Pin 1 -----------------------------   VCC    DS18B20\n                                                   |\n                                                   |\n                                                   R1 = 4k7 ...10k\n                                                   |\n                                                   |\n    Raspi GPIO 4    Pin 7 -----------------------------   Data   DS18B20\n           (BCM)    (BOARD)\n\n    Raspi GND       Pin 6 -----------------------------   GND    DS18B20\n\n### Soft-pull-up\n\nAlternatively to the hardware pull-up made by a physical resistor, or to the above mentioned software configuration `dtoverlay=w1-gpio,pullup=\"y\"` in /boot/config.txt, the following soft pull-up can be used:\n\n```python\nimport RPi.GPIO as GPIO\nGPIO.setmode(GPIO.BCM)\nGPIO.setup(4, GPIO.IN, pull_up_down=GPIO.PUD_UP)\n```\n\nWhen using this software pull-up, 1-Wire devices will be visible to the kernel only while the program pulls the GPIO pin up.\n\n### Hw device connection verification\n\nRun the following command:\n\n```bash\nls -l /sys/bus/w1/devices\n```\n\nYou should check the availability of one or more filenames starting with \"28-\".\n\nFilenames starting with \"00-\" possibly mean that the pull-up resistor is missing.\n\n1-Wire devices can be plugged in dynamically and are visible to the kernel driver just after their hw connection.\n\nTo test reading the temperature, issue the following command:\n\n```bash\nfor i in /sys/bus/w1/devices/28-*; do cat $i/w1_slave; done\n```\n\n## Installation\n\n### From PIP\n\nThis possibility is supported on all distributions:\n\n    pip install w1thermsensor\n\n*Note: maybe root privileges are required*\n\nUse the `async` extra to add support for asyncio and `AsyncW1ThermSensor`:\n\n    pip install w1thermsensor[async]\n\n### On Raspbian using `apt-get`\n\nIf you are using the `w1thermsensor` module on a Rasperry Pi running Raspbian you can install it from the official repository:\n\n```bash\nsudo apt-get install python3-w1thermsensor\n```\n\n**Note:** For older versions of this package you might get the following error: `ImportError: No module named 'pkg_resources'` which indicates that you need to install `python-setuptools` or `python3-setuptools` respectively.\n\n### Manually build and install the debian package\n\n    debuild -us -uc\n    dpkg -i ../python3-w1thermsensor_*.deb\n\n## Usage as python package\n\nThe usage is very simple and the interface clean..\nAll examples are with the `DS18B20` sensor - It works the same way for the other supported devices.\n\n### Basic usage with one sensor (implicit)\n\n```python\nfrom w1thermsensor import W1ThermSensor, Unit\n\nsensor = W1ThermSensor()\ntemperature_in_celsius = sensor.get_temperature()\ntemperature_in_fahrenheit = sensor.get_temperature(Unit.DEGREES_F)\ntemperature_in_all_units = sensor.get_temperatures([\n    Unit.DEGREES_C,\n    Unit.DEGREES_F,\n    Unit.KELVIN])\n```\n\nThe need kernel modules will be automatically loaded in the constructor of the `W1ThermSensor` class. <br>\nIf something went wrong an exception is raised.\n\n*The first found sensor will be taken*\n\n### Basic usage with one sensor (explicit)\n\nThe DS18B20 sensor with the ID `00000588806a` will be taken.\n\n```python\nfrom w1thermsensor import W1ThermSensor, Sensor\n\nsensor = W1ThermSensor(sensor_type=Sensor.DS18B20, sensor_id=\"00000588806a\")\ntemperature_in_celsius = sensor.get_temperature()\n```\n\n### Multiple sensors\n\nWith the `get_available_sensors` class-method you can get the ids of all available sensors.\n\n```python\nfrom w1thermsensor import W1ThermSensor\n\nfor sensor in W1ThermSensor.get_available_sensors():\n    print(\"Sensor %s has temperature %.2f\" % (sensor.id, sensor.get_temperature()))\n```\n\nOnly sensors of a specific therm sensor type:\n\n```python\nfrom w1thermsensor import W1ThermSensor, Sensor\n\nfor sensor in W1ThermSensor.get_available_sensors([Sensor.DS18B20]):\n    print(\"Sensor %s has temperature %.2f\" % (sensor.id, sensor.get_temperature()))\n```\n\n### Set sensor resolution\n\nSome w1 therm sensors support changing the resolution for the temperature reads.\n`w1thermsensor` enables to do so with the `W1ThermSensor.set_resolution()` method:\n\n```python\nsensor = W1ThermSensor(sensor_type=Sensor.DS18B20, sensor_id=\"00000588806a\")\nsensor.set_resolution(9)\n```\n\nIf the ``persist`` argument is set to ``False`` this value\nis \"only\" stored in the volatile SRAM, so it is reset when\nthe sensor gets power-cycled.\n\nIf the ``persist`` argument is set to ``True`` the current set\nresolution is stored into the EEPROM. Since the EEPROM has a limited\namount of writes (>50k), this command should be used wisely.\n\n```python\nsensor = W1ThermSensor(sensor_type=Sensor.DS18B20, sensor_id=\"00000588806a\")\nsensor.set_resolution(9, persist=True)\n```\n\n**Note**: this is supported since Linux Kernel 4.7<br>\n**Note**: this requires `root` privileges\n\n### Disable kernel module auto loading\n\nUpon import of the `w1thermsensor` package the `w1-therm` and `w1-gpio` kernel modules get loaded automatically.\nThis requires the python process to run as root. Sometimes that's not what you want, thus you can disable the auto loading\nand load the kernel module yourself prior to talk to your sensors with `w1thermsensor`.\n\nYou can disable the auto loading feature by setting the `W1THERMSENSOR_NO_KERNEL_MODULE` environment variable to `1`:\n\n```bash\n# set it globally for your shell so that sub-processes will inherit it.\nexport W1THERMSENSOR_NO_KERNEL_MODULE=1\n\n# set it just for your Python process\nW1THERMSENSOR_NO_KERNEL_MODULE=1 python my_awesome_thermsensor_script.py\n```\n\nEvery other values assigned to `W1THERMSENSOR_NO_KERNEL_MODULE` will case `w1thermsensor` to load the kernel modules.\n\n*Note: the examples above also apply for the CLI tool usage. See below.*\n\n### Correcting Temperatures / Sensor Calibration\nCalibrating the temperature sensor relies on obtaining a measured high and measured low value that\nhave known reference values that can be used for correcting the sensor's readings.  The simplest\nway to do this is to measure the melting point and boiling point of water since those values are\nknown.  This method will only work with waterproof sensors - you will need a different mechanism\nfor obtaining measured values if you are not using a waterproof sensor.\n\nIn order to obtain the `measured_low_point`, fill a container to 80% with ice and add water to the\nice until the ice is floating and water is at the surface.  Submerse your sensor in the ice water,\nensuring it does not touch the container.  Wait 5 minutes for the temperature to stabilize in the\ncontainer and then once the sensor readings have stabilized for approximately 30 seconds (readings\nremain consistent), record the value as the `measured_low_point`\n\nIn order to obtain the `measured_high_point`, bring a pot of water to a rapid boil.  Place your\nsensor in the boiling water, ensuring that it does not touch the pot.  Allow the sensor to come up\nto temperature and once it has stabilized for approximately 30 seconds (readings remain\nconsistent), record the value as the `measured_high_point`\n\nGenerally speaking, the `reference_low_point` should be left at 0.0 unless you have some special\nsituation that changes the melting point of water.  Because melting does not involve a gaseous\nphase change, the effects of air pressure and altitude on the melting point are minimal.\n\nThe `reference_high_point` on the other hand is greatly impacted by air pressure (and thus\naltitude).  For example, the boiling point of water is 100.0C at sea level, and is approximately\n72C at the summit of Mount Everest (8848m above sea level).  While air pressure is what actually\ndictates boiling point, generally speaking altitude is a close enough approximation for most use\ncases.  [Engineering Toolbox](https://www.engineeringtoolbox.com/boiling-points-water-altitude-d_1344.html)\nhas a page that gives you the boiling point of water at different altitudes.\n\nThis method is derived from [this Instructable](https://www.instructables.com/Calibration-of-DS18B20-Sensor-With-Arduino-UNO/).\n\n```python\nfrom w1thermsensor.calibration_data import CalibrationData\nfrom w1thermsensor import W1ThermSensor, Unit\n\ncalibration_data = CalibrationData(\n        measured_high_point=measured_high_point,\n        measured_low_point=measured_low_point,\n        reference_high_point=reference_high_point,\n        reference_low_point=reference_low_point, # optional, defaults to 0.0\n    )\nsensor = W1ThermSensor(calibration_data=calibration_data)\n\ncorrected_temperature_in_celsius = sensor.get_corrected_temperature()\ncorrected_temperature_in_fahrenheit = sensor.get_corrected_temperature(Unit.DEGREES_F)\ncorrected_temperature_in_all_units = sensor.get_corrected_temperatures([\n    Unit.DEGREES_C,\n    Unit.DEGREES_F,\n    Unit.KELVIN])\n```\n\n### Async Interface\n\nThe `w1thermsensor` package implements an async interface `AsyncW1ThermSensor` for asyncio.\n\nThe following methods are supported:\n\n* `get_temperature()`\n* `get_temperatures()`\n* `get_resolution()`\n\nFor example:\n\n```python\nfrom w1thermsensor import AsyncW1ThermSensor, Unit\n\nsensor = AsyncW1ThermSensor()\ntemperature_in_celsius = await sensor.get_temperature()\ntemperature_in_fahrenheit = await sensor.get_temperature(Unit.DEGREES_F)\ntemperature_in_all_units = await sensor.get_temperatures([\n    Unit.DEGREES_C,\n    Unit.DEGREES_F,\n    Unit.KELVIN])\n```\n\n\n## Usage as CLI tool\n\nThe w1thermsensor module can be used as CLI tool since version `0.3.0`. <br>\n*Please note that the CLI tool will only get installed with the Raspbian Python 3 package* (`sudo apt-get install python3-w1thermsensor`)\n\n### List sensors\n\nList all available sensors:\n\n```\n$ w1thermsensor ls\n$ w1thermsensor ls --json  # show results in JSON format\n```\n\nList only sensors of a specific type:\n\n```\n$ w1thermsensor ls --type DS1822\n$ w1thermsensor ls --type DS1822 --type MAX31850K  # specify multiple sensor types\n$ w1thermsensor ls --type DS1822 --json  # show results in JSON format\n```\n\n### Show temperatures\n\nShow temperature of all available sensors: (Same synopsis as `ls`)\n\n```\n$ w1thermsensor all --type DS1822\n$ w1thermsensor all --type DS1822 --type MAX31850K  # specify multiple sensor types\n$ w1thermsensor all --type DS1822 --json  # show results in JSON format\n```\n\nShow temperature of a single sensor:\n\n```\n$ w1thermsensor get 1  # 1 is the id obtained by the ls command\n$ w1thermsensor get --hwid 00000588806a --type DS18B20\n$ w1thermsensor get 1  # show results in JSON format\n```\n\nShow temperature of a single sensor in the given resolution\n\n```\n$ w1thermsensor get 1 --resolution 10\n$ w1thermsensor get --hwid 00000588806a --type DS18B20 --resolution 11\n```\n\n### Change temperature read resolution and write to EEPROM\n\n```\n# w1thermsensor resolution 10 1\n# w1thermsensor resolution --hwid 00000588806a --type DS18B20 11\n```\n\n**Note**: this requires `root` privileges\n\n## Contribution\n\nI'm happy about all types of contributions to this project! :beers:\n\n***\n\n*<p align=\"center\">This project is published under [MIT](LICENSE).<br>A [Timo Furrer](https://tuxtimo.me) project.<br>- :tada: -</p>*\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python package and CLI tool to work with w1 temperature sensors like DS1822, DS18S20 & DS18B20 on the Raspberry Pi, Beagle Bone and other devices.",
    "version": "2.3.0",
    "project_urls": {
        "Download": "http://github.com/timofurrer/w1thermsensor",
        "Homepage": "http://github.com/timofurrer/w1thermsensor"
    },
    "split_keywords": [
        "w1",
        "w1-therm",
        "therm",
        "sensor",
        "raspberry",
        "raspberry pi",
        "gpio",
        "ds"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b3d9bbb28eaa1e87eeb5292996b1ec1e9295b73e146551731a5021e1103d312c",
                "md5": "0107e9794e705484d28e5485a112f7ee",
                "sha256": "16f3236d401be809fe46aa4166c4441cc962b398a561aa60659e1fbe553aac94"
            },
            "downloads": -1,
            "filename": "w1thermsensor-2.3.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0107e9794e705484d28e5485a112f7ee",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 22120,
            "upload_time": "2023-09-27T11:44:09",
            "upload_time_iso_8601": "2023-09-27T11:44:09.196718Z",
            "url": "https://files.pythonhosted.org/packages/b3/d9/bbb28eaa1e87eeb5292996b1ec1e9295b73e146551731a5021e1103d312c/w1thermsensor-2.3.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dd60e2dbb207a2b6ed7813aeb976bfb69ef084b3586d5378597e5e5eb225582a",
                "md5": "c54462b028565445fdad0f943d759068",
                "sha256": "9fbc0ae0dd66cd9b54c6d62ed7bab2b88e148c987fe7d5060f476f90e81c2270"
            },
            "downloads": -1,
            "filename": "w1thermsensor-2.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c54462b028565445fdad0f943d759068",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 36880,
            "upload_time": "2023-09-27T11:44:11",
            "upload_time_iso_8601": "2023-09-27T11:44:11.040441Z",
            "url": "https://files.pythonhosted.org/packages/dd/60/e2dbb207a2b6ed7813aeb976bfb69ef084b3586d5378597e5e5eb225582a/w1thermsensor-2.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-27 11:44:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "timofurrer",
    "github_project": "w1thermsensor",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "w1thermsensor"
}
        
Elapsed time: 0.14917s