Giter VIP home page Giter VIP logo

ds1621's Introduction

DS1621.py Readme

Python library for Maxim/Dallas DS1621 I2C temperature sensor, originally written for Raspberry Pi's I2C-bus.

Functional description

Primary functions

  • Read temperature with 3 precisions
  • Read high-resolution temperature (is one of the 3)
  • Read & verbosely report status register
  • Set measurement mode to Continuous or One Shot
  • Stop conversion command to end a Continuous session.

Reading in One-shot mode issues a start command, takes a reading, and then leaves the device idle.

Setting to Continous mode issues a start command. You can then take a any number of readings, until you issue a stop conversion command. For more information, see the DS1621 datasheet.

Functions for the thermostat pin on the DS1621

  • Get thermostat setting from DS1621 non-volatile memory
  • Set thermostat High and Low temperature
  • Set thermohyst, same but with high temp and hysteresis
  • Set thermoLOW makes thermostat pin active Low (1 = heater on)
  • Set thermoLOW False makes thermostat pin active High (1 = cooler on)

Assist functions for converting to and from the DS's register format

  • range is -55 to +125 degrees Celsius with .5 resolution
  • data format is LSB MSB
  • MSB is desired temperature in two's complement
  • LSB is 0x80 for an additional .5 degrees.

Dependencies

smbus

Furthermore

datalog.py is a simple script for taking and logging temperature readings. This is useful for calibrating the device, for example if it's mounted near a more or less constant heat source that offsets the reading.

How to use

A sensor more or less directly mounted on or near a Raspberry Pi will be heated up by the RPi and may read several degrees higher than the actual room temperature. You can find out more about maximum cable length for the I2C-bus here.

Just for clarity, this is the chips pinout:

           _____  
    SDA - 1     8 - Vdd  
    SCL - 2     7 - A0  
   Tout - 3     6 - A1  
    GND - 4_____5 - A2  

Recommended reading is Maxim's datasheet.

A DS1621 with address pins A2A1A0 = 000 (all tied to GND) will appear at bus address 0x48. Another DS1621 with A2A1A0 = 001 (A0 to Vdd) will be at 0x49, and so on.

Sensornames should be declared in the calling module or in main(), for example:

Room    = 0x48  
Remote  = 0x49  

Using RPi's GPIO (which includes I2C) requires root rights. Run the the driver with elevation like this:

$ sudo python DS1621.py  

You can also run it with indirect elevation with this script:

#! /usr/bin/env python  
# -*- coding: utf-8 -*-  

import subprocess  

subprocess.call(['sudo', './DS1621.py'])  

In both cases however, the user who issues the command or launches the script, must be a sudoer.

Tighter security is possible with this workaround. Essentially, you make the GPIO memory belong to group gpio, and then make your DS1621 user a member of gpio and i2c.
Check that /dev/gpiomem has the correct permissions.

$ ls -l /dev/gpiomem  
crw-rw---- 1 root gpio 244, 0 Dec 28 22:51 /dev/gpiomem  

If it doesn't then set the correct permissions as follows

sudo chown root.gpio /dev/gpiomem  
sudo chmod g+rw /dev/gpiomem  

ds1621's People

Contributors

rolfbly avatar

Stargazers

Gerad Munsch avatar Lee avatar Thomas avatar  avatar stam avatar

Watchers

 avatar  avatar

ds1621's Issues

ImportError

Hi,

when I start ds1621.py I get the error:

"ImportTraceback (most recent call last):
File "/home/pi/capt/ds1621.py", line 37, in
import datalog
ImportError: No module named datalog"

but I have datalog installed, any idea ?

Thanks in advance.

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.