done is unnecessarily reset our starting values. However,
the data will still be correct for the subsequent readings.
Logging the Exception
Under the condition of any sensor reading byte being
outside the nibble range of – 8 to + 7, we will record the
four nibbles (two bytes) as 0x88, 0x88. We will follow
these two bytes with four new full byte initial values for
each of the indoor and outdoor temperature and humidity
readings. After this reset, we will resume packing the data
Reading the Exception
When the software that reads the downloaded sensor
data sees the two bytes for a single sensor reading, it will
respond to those values as an exception, discard the
values, and then read the next four bytes into the initial
sensor reading. It will use them as the actual sensor
reading for that time period. We’ll assume each
subsequent reading will be in nibble format and used to
calculate the true reading from the prior value.
These unpredictable exceptions mean that we won’t
actually know how much data we can store until we’ve
finished since the exceptions will take up extra space. We
can hope not to see many exceptions and if we do, well ...
we can always write more code.
Again — Too Much!
Exceptions? I’m already confused by all the different
kinds of data we are using! We’ve got an origin date/time,
an origin indoor temperature, an origin outdoor
temperature, an origin indoor humidity, an origin outdoor
humidity, and then nibbles for the changes in indoor and
outdoor temperatures and humidities. Now, we also have
a special exception state that resets stuff ... my head just
sprung a leak.
I’m going to stop here and write a test program so
that I can see all this in action before attempting to hook
it up to real world sensors and actually log the data. Of
course, we are out of space again, so you can find this
code (fac_data_logger_test) at the article link.
Next month, we’ll hook this up to the sensors and
vastly extend the amount of data we can log by using an
SD card. This will turn our modest handheld prototyper
into a real beast capable of logging gigabytes of data! NV
November 2013 59