Page 133 - Programming the Photon Getting Started With the Internet of Things
P. 133

Figure 6.11 Breadboard layout diagram.


             The resistor is used as a pull-down resistor to make sure there is no ghost reading from
        the sensor and gives us a more accurate reading.

             Let’s take a look at the program code that we will be using to read the temperature
        sensor:


        #include "OneWire/OneWire.h"

        #include "spark-dallas-temperature/spark-dallas-temperature.h"


        double tempC = 0.0;
        double tempF = 0.0;



        int tempSensorPin = D0;


        OneWire oneWire(tempSensorPin);
   128   129   130   131   132   133   134   135   136   137   138