Close

Creating a Simple Data Logger

A project log for LP Mini - Low Power Dev Board

Inexpensive, Arduino Compatible Low Power Dev Board

maxkMax.K 12/10/2016 at 21:240 Comments

The most obvious application for a low power board is a data logger. And this is exactly what I am creating as a first test of the boards capabilities.

Hardware

The goal is to measure temperature in certain intervals and save these measurements to an SD card, which can later be used to transfer the data to a PC. For a sensor I am using the Dallas ds18b20, which is a cheap 1-wire sensor. An old 64 mb card is connected to the LP mini via SPI and a simple breakout. The benefit of this setup is that it doesn't use the I2C bus, whose pins I forgot to include on the board (well, there was not that much space left, so I figured A4 and A5 wouldn't be that important).

The power pins of both the sensor and the SD card are connected to pin 10. The integrated mosfet enables this pin to switch devices with high current consumption (or at least more than the digital pins can supply) off and on.

The components are assembled on a breadboard. An Arduino UNO is used for programming.

Software

The Arduino code is heavily relying on libraries. Those are:

The basic steps of the code are simple:

Initialize,

Get time,

get temperature,

save data,

sleep,

repeat.

Talking to the sensor and SD is mostly done by the libraries, so I won't go into detail.

After saving the data, the SD and sensor are powered down and the RTC is set to wake the board after a given time. The Atmega itself then goes into sleep mode. When the RTC wakes up the µC, the external devices are powered up again and the loop repeats itself.

The complete Arduino sketch has less than 80 lines of code. The source code is available on Github: https://github.com/CoretechR/lpmini/tree/master/Examples/SDcardTemperatureLogger

Obstacles

Both the ds18b20 and the SD card breakout had difficulties running at 3 V, so I replaced the regulator with a 5 V one. This only slightly affects the current consumption but makes the LP compatible with more hardware.

At first the current consumption in sleep mode was over 300µA, which is 3 zeros more than I expected. The problem was that although the power pin of the SD card was disabled, it was still drawing current from the SPI pins. This is a common behavior for ICs. Depending on the SPI mode, the SCK, MOSI and enable pin are in a high state even when the µC is not running. This problem is fixed by simply configuring the corresponding pins as a digital input before sleeping. Of course they have to be enabled again or else SPI won't work.

The Result

With a bit of optimization, the LP mini is doing its job as a data logger at only 3 µA during sleep. Assuming the device wakes up every 5 minutes for 1 second and the operating current is around 30 mA, we are looking at 1,5 to 2 years of operating time (using AA batteries).

So far I have not encountered any serious problems with the board. Especially after switching to 5 V it works very reliably. I already made a new version in EAGLE with the I2C pins accessible, but haven't ordered it yet.

Discussions