User Tools

Site Tools


oak:tutorials:onewiretemp

This is an old revision of the document!


"THIS TUTORIAL HAS NOT YET BEEN REVIEWED, PLEASE DO NOT USE UNTIL IT HAS"

This tutorial is currently being edited. Please do not update until this statement has be removed.

Temperature Sensing and the 1-Wire Bus

This tutorial demonstrates how to use the Oak to read temperature data from the DS18B20 1-Wire Digital Thermometer and publish that data to the Particle.io Dashboard log. It will also demonstrate how to use the deep sleep capability of the Oak platform to minimize power requirements (if desired) between temperature readings.

Concepts:

  • How to connect a 1-Wire DS18B20 digital thermometer to the Oak platform.
  • How to read DS18S20 temperature data.
  • How to publish temperature data to the Particle.io Dashboard log.
  • How to use deep sleep capabilities of the Oak to minimize power usage between readings.

What's required:

  1. An active Particle.io account [https://www.particle.io/]
  2. Your Oak configured with the latest firmware
  3. Your Oak claimed as a device on your Particle.io account
  4. A D18B20 1-Wire Digital Thermometer [http://digistump.com/products/57]
  5. A 4.7K Ohm resister (3.3K and 2.2K can be substituted)
  6. OneWire library supporting the ESP8622

Connecting the DS18B20 device to the Oak

The 1-Wire DS18B20 digital thermometer can operate at either 3.3 volts or 5 volts. Since the Oak is a 3.3V device, in this tutorial we will use the 3.3V supplied by the Oak's VCC 3.3V pin to power the DS18B20. The DS18B20 Data Input/Output lead (DQ) must be pulled up to 3.3V using a 4.7K resister. While the DS18B20 does support a parasitic mode, this will not be demonstrated in this tutorial. Parasitic mode does not require the DS18B20 VDD lead to be connected to external power, but it does require a strong pullup on the 1-Wire bus. To learn more about operating the DS18B20 in parasitic mode, see the DS18B20 device data sheet (https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf).

Publishing Temperature Data

The provided example sketch (see below) uses the Particle.io function Particle.publish() to post temperature readings to the particle.io Dashboard log. In order to do this you must have an active Particle.io account, a functional Oak running the latest firmware, and that Oak claimed as an active device on Particle.io.

The actual command used is: Particle.publish(“Temp (F)”, tempFstring, 60, PRIVATE); where “Temp(F): is the event name and tempFstring is the actual temperature reading in string format.

For more information and other examples for how to use the Particle.publish function and other Particle device firmware Cloud functions, see https://docs.particle.io/reference/firmware/core/

Oak Deep Sleep function

The Oak is capable of entering a deep sleep to minimize power requirements. This may be desirable if, for example, your Oak will be battery powered. The provided example sketch demonstrates this mode of operation but will also support operating in a non-sleeping mode.

To indicate to the sketch that sleep mode is desired, we use pin 5 (pulled HIGH) as essentially as “switch”. If pin 5 is HIGH when read in setup(), the sketch operate in sleep mode. This will be considered the default operating mode and as such pin 5 will be defined as INPUT_PULLUP.

To facilitate the Oak's deep sleep and wake-up capabilities, you must also connect pin 10 (WAKE) to the reset (RST) pin. This allows the Oak to trigger a RESET after a user specified sleep period has expired. While in sleep mode, the sketch will enter and run setup after each time a RESET occurs. In this mode it never enters loop().

If you prefer to operate the Oak in non-sleep mode, or if you want to prevent it from sleeping (when in sleep mode) to allow for new sketch uploads, pin 5 simple needs to be connected to ground (GND) thus pulling pin 5 LOW. When pin 5 is LOW at power up the sketch will not sleep and does enter loop() where it remains and repeatedly reads and publishes data from the DS18B20 device. This mode consumes more power than does operating in a sleep mode.

If pin 5 is HIGH at power up (sleep mode), the example sketch will stay in sleep mode as long as pin 5 remains HIGH. If at anytime pin 5 is pulled LOW, the sketch will enter non-sleep mode following the next RESET. Once in non-sleep mode, it will remain in this mode at long as the Oak is powered up regardless of the state of pin 5 (HIGH or LOW).

Sleep Mode configuration:

  1. Oak powered through USB or VIN/GND
  2. The DS18B20 is powered by Oak's VCC (3.3V)
  3. Black wires - Ground connections
  4. Red wires - VCC 3.3V connections
  5. Yellow wire - pin 10 (WAKE) to RESET (RST)
  6. White wire – pin 2 to DS18B20 DQ (note: 4.7K pull-up resister)

oak-temp-sensing-1-wire-bus-1.jpg

Sleep Mode Configuration

In Sleep Mode (after reading and publishing temperature data) the Oak enters deep sleep and delays for a user specified number of seconds. When sleep time has expired, a RESET is triggered via pin 10 (WAKE). Following a RESET, the sketch starts from the beginning and never enters loop().

oak/tutorials/onewiretemp.1458511095.txt.gz · Last modified: 2016/03/20 14:58 by exeng