MySQL for the Internet of Things

(Steven Felgate) #1

ChapTeR 1 ■ The InTeRneT Of ThIngs and daTa


Perhaps equally important is how that data is stored and protected from exploitation or misuse. This
is an especially important aspect of IOT solutions, which I will discuss in more detail later. For now, let’s
consider data for IOT solutions starting with a simple plant-monitoring system. Figure 1-7 shows a simple
solution with a single plant. While a good solution would also include a light sensor to monitor how much
light the plant is receiving, this one has been simplified so you can see the data produced.


Figure 1-7. Plant monitoring with Arduino


In this example, you see an Arduino with a soil moisture sensor connected. The Arduino generates a
list of readings from the soil moisture sensor that is placed in the soil of the plant. The code to do this is not
complicated, as shown in Listing 1-1.


Listing 1-1. Plant Soil Monitoring


/*
Simple Plant Monitor Example


Display the value of the soil moisture sensor and threshold status.


*/


// Thresholds for sensor to detect wet/dry conditions. Adjust these
// to match your soil characteristics.
int upper = 400;
int lower = 250;


// Pin for reading the sensor
int sensorPin = A0;


void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial);

Free download pdf