MySQL for the Internet of Things

(Steven Felgate) #1

Chapter 4 ■ Data transformation


■Tip Consider how often you want to record the observation based on what you may learn from change


over time.


What Type of Data Does the Sensor Produce?


The next thing to consider is the type of data that the sensor is producing. Resist the temptation to jump to
how the data is interpreted—we’ll do that next. For now, make a note of what the data type is so that you can
refer to it when you implement your solution.
It is possible the data type of the data from the sensor could be quite different from what we are
observing. We have already seen this for sensors that produce analog data in the form of voltage. A voltage
of plus or minus volts may not be obvious as to what it indicates. Making a note of what data each sensor
produces will help you when it comes time to write code to read, analyze, and store the observations.


■Tip make a list of the data types that your sensors produce. Keep this list handy when designing


your solution.


Are There Interpretations Needed for the Observation Data?


Once we know what we are observing, what we can learn from the observation, how frequently we need to
make the observation, and what the data type is, we now must consider if there are any interpretations that
need to be made.
Returning to the analog sensor discussion, most analog sensors have specific interpretations, and
indeed the interpretation is documented. That is, the documentation for the sensor will tell you how to
interpret the values produced. This is presented via a common mechanism called a data sheet.


reaD the Data Sheet


You can find more about how to interpret the data from the data sheet for the sensor. most
manufacturers produce a short description of their device including operating parameters (voltage,
current, and so on) as well as the data type the sensor produces and how to interpret that data. refer to
the data sheet if you are unfamiliar with the sensor or its discrete components.

Once you understand how the data type is interpreted, make notes about how to perform the
interpretation. I like to include this data in a notebook along with pseudo-code for how to make the
observation. Not only will it help you write code to interpret the data, it can also help you should you
consider including the interpretation inside the database.
Additionally, you should also consider how the data is to be presented, that is, how you want to show
the data to the user. For example, it would not be helpful for the user to read a value of -4.12 volts, but it
would be helpful for the user if that value was presented as category such as “ok,” “wet,” or “dry.”


■Tip make a plan for how to interpret and present the data. record it in a notebook for reference.

Free download pdf