Coder Social home page Coder Social logo

sht3x-dis_humidity_temperature_sensor's Introduction

Python (>3.6) API for Sensirion humidity and temperature sensor SHT3x-DIS which has I2C communication

Basic Usage

Instantiate sensor object:

import sht3xdis
sensor = sht3xdis.TempHumiditySensor(1, 0x44)

Set sensor acquisition mode:

sensor.set_mode("single-shot", acc="high", blocking=True)

Accuracy can be set to "low", "med" or "high", Blocking set to True waits for sensor reading to become available before proceeding

sensor.set_mode("periodic", rate=4, acc="high")

Sampling rate on-board sensor can be 0.5, 1, 4 or 10 Hz

Start sample acquisition on sensor:

# Single-shot mode (non-blocking)
sensor.init_read()
while True:
  if sensor.isready():
    data = get_sample(degf=True)
    temp = data[0]
    rh = data[1]
    sensor.init_read()
  
# Single-shot mode (blocking)
sensor.init_read()
data = sensor.get_sample(degf=True)
  
# Periodic mode
sensor.init_read()
while True:
    data = sensor.get_sample(degf=True)   

Data Logging

API includes logging features for logging temperature and humidity data to file or SQL database

Log to file

sensor.start_logging_file()

Add file path to TempHumiditySensor.LOGGING_PATH

Log to MySQL

sensor.start_logging_sql('192.168.1.1', 3306, "sampledatabase", "sampletable", 60)

Add MySQL credentials to my.cnf and set path TempHumiditySensor.SQL_CREDS_PATH

Command-line script for exporting MySQL sensor data

Usage example: sensor_data_export.py -f <path-to-outfile> -t <table> --maxsamples 1000

sht3x-dis_humidity_temperature_sensor's People

Contributors

qubitqualia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.