Skip to main content

GreenPonik DS198B20 One Wire read temperature

Project description

Quality Gate Status Maintainability Rating

Lines of Code Duplicated Lines (%)

Reliability Rating Security Rating Vulnerabilities

GreenPonik_OneWire_DS18B20.py Library for Raspberry pi


This is the sample code for read temperature with DS18B20 sensor on One Wire bus.

The script auto-detect the 1W file and parse it to find the temperature value.

Table of Contents

Installation

> git clone https://github.com/GreenPonik/GreenPonik_OneWire_DS18B20.git
from GreenPonik_OneWire_DS18B20.GreenPonik_OneWire_DS18B20 import read_temps

Methods

"""
Get temperatues in celcius and fahrenheit
"""
def read_temps():

Example

import time
from GreenPonik_OneWire_DS18B20.GreenPonik_OneWire_DS18B20 import read_temps

if __name__ == "__main__":
    while True:
        # read both celcius and fahrenheit temperatures
        temperatures = read_temps()
        print("celcius temp %.3f" % temperatures[0])
        print("fahrenheit temp %.3f" % temperatures[1])
        time.sleep(1)
    pass

Credits

Write by Mickael Lehoux, from GreenPonik, 2019

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

greenponik-onewire-ds18b20-0.0.1.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page