This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
oak:tutorials:onewiretemp [2016/03/22 00:01] exeng created |
oak:tutorials:onewiretemp [2016/03/26 17:17] (current) bjh [Initialization and Setup()] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== "THIS TUTORIAL HAS NOT YET BEEN REVIEWED, PLEASE DO NOT USE UNTIL IT HAS" ====== | + | |
| ====== Oak: Temperature Sensing and the 1-Wire Bus Lesson ====== | ====== Oak: Temperature Sensing and the 1-Wire Bus Lesson ====== | ||
| Line 23: | Line 23: | ||
| - | ===== Circuit: ===== | + | ===== Circuit: ===== |
| - | {{:oak:tutorials:ds18b20example.jpg?direct&200|}} | + | {{:oak:tutorials:ds18b20example.jpg?direct@300|}} |
| Note the orientation of the leads on the DS18B20 device. From left to right they are: (1) GND, (2) DQ, (3) Vdd. | Note the orientation of the leads on the DS18B20 device. From left to right they are: (1) GND, (2) DQ, (3) Vdd. | ||
| Line 34: | Line 35: | ||
| - Oak powered through USB or VIN/GND | - Oak powered through USB or VIN/GND | ||
| - | - The DS18B20 is powered by Oak's VCC (3.3V) | + | - The DS18B20 Vdd lead (3) is powered by Oak's VCC (3.3V) |
| - Black wires - Ground connections | - Black wires - Ground connections | ||
| - Red wires - Oak VCC 3.3V | - Red wires - Oak VCC 3.3V | ||
| - White wire – pin 2 to DS18B20 DQ 1-Wire bus lead (2) | - White wire – pin 2 to DS18B20 DQ 1-Wire bus lead (2) | ||
| - | - 4.7K pull-up resister from DS18B20 VDD lead (3) to DQ lead (1) | + | - 4.7K pull-up resister from Oak VCC 3.3V to DS18B20 DQ 1-Wire bus lead (2) |
| - DS18B20 GND lead (1) to Oak GND | - DS18B20 GND lead (1) to Oak GND | ||
| Line 56: | Line 57: | ||
| Where “Temp(F)" is the event name and tempFstring is the actual temperature reading in string format. | Where “Temp(F)" is the event name and tempFstring is the actual temperature reading in string format. | ||
| + | |||
| + | You should see log entries with temperature like this. | ||
| + | {{:oak:tutorials:ds18b20particlelog.jpg?direct&200|}} | ||
| 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/]] | 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/]] | ||
| Line 117: | Line 121: | ||
| ==== Initialization and Setup() ==== | ==== Initialization and Setup() ==== | ||
| - | DS18B20_Pin defines the pin to use for the 1-Wire bus (DQ line). In this example it is set to pin 2 but can be changed to ay pin that can tolerate being pulled up at power on. | + | DS18B20_Pin defines the pin to use for the 1-Wire bus (DQ line). In this example it is set to pin 2 but can be changed to any pin that can tolerate being pulled up at power on. |
| The OakLEDpin, pin 1 is used to provide a visual output when temperature is being read. | The OakLEDpin, pin 1 is used to provide a visual output when temperature is being read. | ||
| - | sleepTimeS specifies the delay in seconds between readings. We don't actually sleep but rather simply delay a specified amount of time in seconds before that next temperature update. It's important to keep this relatively course as we don't wont to flood Particle.io with constant updates to the log. For slow changing inputs, 30 seconds to 1 minute is about right but you can easily change this to suit your own needs. | + | sleepTimeS specifies the delay in seconds between readings. We don't actually sleep but rather simply delay a specified amount of time in seconds before that next temperature update. It's important to keep this relatively coarse as we don't want to flood Particle.io with constant updates to the log. For slow changing inputs, 30 seconds to 1 minute is about right but you can easily change this to suit your own needs. |
| <code> | <code> | ||