Data Logger Simple – Software Bugfix

After analysing recorded data from the simple version of the data logger, I found a problem I had to fix with a new release v1.1 of the software.

If you look at this chart, which is showing data recorded in 30 second intervals, you can clearly see the values do not really change every 30 seconds.

Data Logger Problem Chart

The values change every 40 minutes and this can not be correct, even the sensor is slow. I found the problem in the DHT library from Adafruit. It is not actually a problem, but the library relies on the function millis() to measure the time between two reads.

From the DHT sensor library:

boolean DHT::read(void) {
  // Check if sensor was read less than two seconds ago and return early
  // to use last reading.
  uint32_t currenttime = millis();
  if (currenttime < _lastreadtime) {
    // ie there was a rollover
    _lastreadtime = 0;
  }
  if (!_firstreading && ((currenttime - _lastreadtime) < 2000)) {
    return _lastresult; // return last correct measurement
  }
  _firstreading = false;
  _lastreadtime = millis();

The function millis() relies on timer1 which is counting the time for this function. To save power, I put the microcontroller into sleep mode, which stops all timers except timer2. Therefore the time is not counted anymore, and millis() returns a wrong value.

Continue reading Data Logger Simple – Software Bugfix

Simple Version of the Data Logger Published

I just published the simple version of the data logger hardware and software. The simple version extends storage of the minimal version with external persistent RAM.

The additional storage provides space for more records and a higher precision for the records. Temperature and humidity is stored as float and the time as a UNIX timestamp.

I use the FRAM breakout board from Adafruit, because writing to FRAM needs way less power than writing to flash RAM. It is also faster, which increases the “sleep” time for the microcontroller and it does not require to erase a full page writing a single byte. The only catch of FRAM, it is more expensive than flash RAM.

My software has a simple abstraction of the used storage, so you can simple replace the FRAM with a flash chip or even with a SD card reader.

Building the hardware for the simple version is almost identical like building the minimal version. Just follow the instructions how to build the minimal version but add the FRAM as shown on the following page:

Build the Hardware (Simple)

Have fun!

Long-Term Test Finished

I finished my long-term test of the minimal version of the data logger project after a few days. To simulate the situation for the actual usage, I setup the data logger to record data in 1 hour intervals.

The test answered these questions:

  • Does the data logger function properly over several days?
  • How much battery does the data logger use?

I could not answer the first question until I stopped the data logger and read all values over the TTL cable. I found this is a little bit tricky, because the microcontroller did reset as soon I attached the TTL cable. This automatically restarted the logging and logged some additional value, visible in the chart.

The battery life is hard to measure. I used a multimeter and measured the voltage on the battery. At the end, the voltage was still over 4.0V, which means the battery pack is almost full charged.

I would need to connect the battery to an analog input of the microcontroller, using a MOSFET as a switch. So I could measure the battery voltage over time.

Importing the Data

Working on Mac OS X, I am using the screen command as serial console. If you add the parameter -L to the command, the whole output is automatically logged in a file.

LR: ~lr$ screen -L /dev/cu.usbserial-FTHXXXXX 57600

I opened the file using BBEdit and removed any lines before and after the actual data. After the edit I saved this edited file as “data.csv”.

Temperature Humidity ChartTo get a little bit more options for the diagram, I used Microsoft Excel. After the import of the data, I formatted the columns, added a title and created a X/Y chart from it. After fine tuning all the titles, formats and lines I created a nice chart and could export it as PNG file.

You can see the chart as feature image of this article, or click on the thumbnail on the right side to see the full resolution version.

Conclusions

If you look at the chart you can clearly see the problem of the minimal version. It logs just integer values without fractions which is clearly not enough for the temperature. The sensor is capable of a higher precision, but not accuracy. But the higher precision will make trends better visible in the data.

What is Coming Next?

Next I will implement the simple version of the data logger. This will add additional 32KB of storage to the device, using the Non-Volatile FRAM Breakout from Adafruit. With this “vast” amount of storage, I can use a 14 bytes record which stores the date and time as unix time-stamp, using a float for humidity and temperature and a real CRC-16.

Date/Time    4b
Humidity     4b
Temperature  4b
crc          2b
---------------
total       14b

This will allow 2340 records in the FRAM, which sums up to 97 days recording time at one hour intervals.

Data Logger Documentation Online

I just published the minimal version of the data logger project. The minimal version uses the built-in EEPROM of the microcontroller to log sensor data. I decided to create this additional minimal version because it works for very simple cases and does not need any external memory.

Data Logger Wires

The data logging mode is controlled using a BCD DIL switch. Using this switch you can select logging mode, read mode and format mode.

Data Logger Mode Select

The documentation is explaining how to create this data logger in detail. All about the parts, how to build the hardware, how to build the software and a detailed page which explains the software in detail. There is also a short overview of the project and how to use the final device.

Start reading the detailed documentation here:

The Data Logger Project

If you have any questions or feedback about this project, feel free to leave comments on these pages.

Are My Documents Safe in the Root Cellar at ~80% Humidity?

Update 2015-08-21: Added the wiring diagram.
Update 2015-08-24: The documentation for the minimal version is online here.

There is a large cellar where I could store unused items and documents, but the catch is the humidity there. It is a root cellar near a small brook and the humidity varies between 75% up to 90%.

Archived material should never be exposed to humidity greater than 65%, therefore I have to isolate all documents in boxes from the air of the cellar. But are this boxes safe? Do they keep the humidity away from the documents – even for years?

To have a look into the box environment, I need a data logger. It would be simple to buy one, but much more fun to build one. So a new project is born: I call it the “Data Logger” project.

There are a few phases to realise this project:

  • Prototype (done)
  • Simple Version (in work)
  • Deluxe Version with Display and Case

The Prototype

For the prototype I used a large solderless breadboard from 3M. There I actually just tested the components for the simple version, especially if the protocols are working and if I can use them in the way intended. I will keep this section short and explain everything in detail in the next section. Just to remind you, I tested everything on a breadboard before I soldered the components to a stripboard.

Parts of The Simple Version

The simple version should be a data logger which automatically starts logging temperature and humidity values it it is powered on. Using a small switch, I can select between logging, reading and erase. In the reading mode, the logger will send all logged values to the serial interface.

Because I need quick results, I will build the whole device using components from Adafruit. Here a list of components I will use for the simple version of the data logger:

Continue reading Are My Documents Safe in the Root Cellar at ~80% Humidity?