Coder Social home page Coder Social logo

mmm-temp-ds18b20's Introduction

Module: MMM-temp-ds18b20

Display DS18B20 sensor's temperature on your MagicMirror

DS18B20 visualisation

DS18B20 visualisation DS18B20 visualisation

Module installation

Dependencies

Useful commands

List DS18B20 sensors IDs:

find /sys/bus/w1/devices/ -name "28-*"

Get DS18B20 sensors temperatures:

find /sys/bus/w1/devices/ -name "28-*" -exec cat {}/w1_slave \; | grep "t=" | awk -F "t=" '{print $2/1000}'

Installation

Navigate into your MagicMirror's modules folder:

cd ~/MagicMirror/modules

Clone this repository:

git clone https://github.com/thlb/MMM-temp-ds18b20

Navigate to the new MMM-temp-ds18b20 folder and install the node dependencies.

npm install

Configure the module in your config.js file.

Using the module

To use this module, add it to the modules array in the config/config.js file:

modules: [
   {
       module: 'MMM-temp-ds18b20',
       position: 'top_right',
       header: 'Temperature sensors',
       config: {
            refreshInterval: 10, // in seconds
            displayMode: 'x-stack',
            sensors:[
                {
                    id: "28-800000xxxxxx",
                    label: "Inside"
                },
                {
                    id: "28-800000xxxxxx",
                    label: "Outside"
                }
            ]
        }
    },
]

Configuration options

The sensors property contains an array with multiple objects (one per sensor connected the Raspberry). These objects have the following properties:

Option Description
id Unique ID of a DS18B20 sensor. This ID always beggin with '28-'.

To find the sensor value, go to "Useful commands" section.

Required
Possible values: 28-XXXXXXXXXXXX
label Sensor name.

Required
Possible values: Inside, Kitchen, or any String you want.

The following properties can be configured:

Option Description
refreshInterval The refresh interval of sensors values (in seconds).

Default value: 10
displayMode Display in horizontal/vertical mode.

Required
Possible values: x-stack or y-stack
Default value: y-stack
displayTempIcon Display the "termomether" icon.

Possible values: true or false
Default value: true
iconSize Size of thermometer icon.

Possible values: xsmall, small, medium, large, xlarge
Default value: small
labelSize Size of sensor name.

Possible values: xsmall, small, medium, large, xlarge
Default value: medium
tempSize Display sensor's temperature value.

Possible values: xsmall, small, medium, large, xlarge
Default value: medium
units What units to use. Specified by config.js

Possible values: config.units = Specified by config.js, default = Kelvin, metric = Celsius, imperial = Fahrenheit
Default value: config.units

DS18B20 Installation

Requirements

  • Raspberry
  • DS18B20 sensor(s)
  • 4.7kΩ resistor (Yellow, Violet, Red, Gold)
  • Breadboard (optionnal)
  • Jumper wires (optionnal)

Foreword

The DS18B20 communicates with the controlling device via the “One-Wire” communication protocol, a proprietary serial communication protocol that uses only one wire to transmit the temperature reading to the microcontroller. There is differents models :

###Technical specifications :

  • -55°C to 125°C range
  • 3.0V to 5.0V operating voltage
  • 750 ms sampling
  • 0.5°C (9 bit); 0.25°C (10 bit); 0.125°C (11 bit); 0.0625°C (12 bit) resolution
  • 64 bit unique address
  • One-Wire communication protocol

DS18B20 Layout

This sensor has three pins :

PIN DS18B20+ Genuine DS18B20 Pre-wired waterproof
GND PIN 1 (Cf. diagram below) Black wire
DATA PIN 2 (Cf. diagram below) Yellow or Blue wire
3.3V power line PIN 3 (Cf. diagram below) Red wire

DS18B20+ Diagram

Hardware installation

  1. Power off the Raspberry.
  2. Follow this diagram :

DS18B20+ Diagram

Using multiples sensors

Plug multiples sensors on the Raspberry is very easy. With multiples sensors, we still only have three connections to the Raspberry (+3.3V, GND & Data). The single data wire will return the temperature readings from all th sensors. This is possible because each DS18B20 sensor has a unique serial number coded into it which the Raspberry Pi can be used to identify them by.

DS18B20 Multiple Diagram

Raspberry configuration

Edit file /boot/config.txt and add the following line :

dtoverlay=w1-gpio

Load the drivers :

sudo modprobe w1-gpio
sudo modprobe w1-therm

Edit file /etc/modules and add the following lines to auto-load drivers on boot :

w1-therm
w1-gpio

Check that sensors are well recognized by the Raspberry :

find /sys/bus/w1/devices/ -name "28-*"

You should see as many lines as sensors plugged. Note that the part 28-xxxxxxxxxxxx is the ID of the sensor.

Now, if you want to check the temperatures value af all your sensors :

find /sys/bus/w1/devices/ -name "28-*" -exec cat {}/w1_slave \; | grep "t=" | awk -F "t=" '{print $2/1000}'

Finnaly, perform a sudo reboot of your Raspberry to check the proper load of the driver on boot. If the previous command still works, the drivers are correctly loaded.

mmm-temp-ds18b20's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

mmm-temp-ds18b20's Issues

several ds18b20 connected separately to gpio

Hi, I can't put this module into operation on several thermometers connected separately to different Gpio. The system sees them, but I don't know how to modify the module to read them. For example, mmm-domoti cz can read them, but I would like to use this module. Please here's advice on how to set it up?

Screenshot_8

Screenshot_1

Screenshot_2

maybe somehow modify this path?
Screenshot_3

Screenshot_4

Undefined instead of actual temperature

Hello, im getting an error i cant fix.

everything is working.

If it type

find /sys/bus/w1/devices/ -name "28-*"
and

find /sys/bus/w1/devices/ -name "28-*" -exec cat {}/w1_slave ; | grep "t=" | awk -F "t=" '{print $2/1000}'

im getting the right module and temperature. But if i refresh the mirror there is only "undefined" instead of the temperature. Tried with different options but it displays always the same

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.