Page 131 - Programming the Photon Getting Started With the Internet of Things
P. 131
voltage reading from the Photon by calling g.refresh. In the Div ID gauge you can
determine many factors of the gauge such as color, min/max values, and labels. The
current script reads the value of the light sensor every second; it may be worth changing
this value to something a bit more appropriate, such as every 30 seconds or one minute, as
updating the reading every second would be inefficient.
Open up the HTML page in your Web browser and you should see the current voltage
reading. Cover the photoresistor with your hand and you should see that the value changes
as it drops off. If you hold the photoresistor up to the light or flash a light of some kind
into it, the voltage rating will go up.
This is the basic principle of reading a sensor with a resistance value. There are also
other kinds of sensors that can be used in place of the photoresistor, such as a gas sensor
or even a photoresistor dial.
In the next experiment we will look at reading a temperature sensor using a Maxim
DS18b20 digital chip.
Reading a Temperature Sensor
For this experiment we are going to use what we learned in the previous project and use it
to read a simple Maxim one-wire digital temperature sensor. We are going to use the same
graphical interface for the gauge but change the parameters to display the temperature
rather than the voltage. Figure 6.10 shows the webpage temperature reading from the
digital temperature sensor.
Figure 6.10 Reading the temperature over the Internet.
This experiment uses the Maxim DS18b20 digital temperature sensor, which comes in
all shapes and sizes and is more commonly found as an integrated circuit (IC). This digital
temperature sensor can read temperatures in the range of −55° C to 125° C. These sensors