MySQL for the Internet of Things

(Steven Felgate) #1

ChapTeR 1 ■ The InTeRneT Of ThIngs and daTa


291,ok
302,ok
394,ok
467,wet
506,wet
419,wet


■Note You can download the source code examples for this book from the apress web site.


For purposes of this illustration, the text output is sufficient. This is because I want to call your attention
to the rows of data. The first column is the raw value as read from the sensor. Clearly, this data has little
human-readable information. After all, it’s just a numeric value for the analog signal. That is why I used
threshold values to determine or qualify the data. You can see this as the values change and the moisture
level rises.
As you can see, the data that makes most sense to us is the “dry,” “wet,” and “ok” values. The raw values
are not really that interesting. This is an excellent albeit simplistic illustration of how the raw data from a
sensor needs additional augmentation to make it useful. However, I must also point out that if you stored
only the derived values, if you need to adjust your thresholds, you cannot reevaluate the derived values. For
example, if you determine the upper threshold needs to change and you want to do some analysis on how
the change would have affected readings in the past, since you have only the “dry,” “wet,” and “ok” values,
you cannot perform this analysis. Thus, saving the raw data is always a good practice.


■Tip always save the raw data as well as the calculated or derived values. You never know when you


will need it.


If you are interested in building this example or perhaps embellishing it with an LCD or LED to warn
when the plant needs water or better still to automatically water the plant with a servo or stepper motor
and a water source, I encourage you to do so. It is a fun project. You can even modify the code to support
a web server that you can use to remotely check the status of your plants.^9 The parts are easy to find and
available from most online electronics stores such as SparkFun (http://sparkfun.com), Maker Shed
(http://makershed.com), and AdaFruit (http://adafruit.com). I’ve included a couple of links to articles
ordered from simple to complex that explain how to build this project and similar projects. Figure 1-8 shows
how the sensor is wired to the Arduino.



(^9) Hint: See the web server example under the Ethernet category in the Arduino IDE.

Free download pdf