Public Lab Research note

  • 1

Simple data logger

by david_uwi |

Newer microprocessors have quite a bit of flash memory and any that is left over from the main program can be used to store data. So a single chip can act as simple data logger. It also uses very little power 2xAAA bateries will last for about one year with a monitor screen attached or several years if the screen is disconnected.
I have used the chip PIC16F18326 which has 16K of 14 bit words. After loading the processing program some 14K is left to store data. I have used it to measure barometric pressure at 12 minute intervals for 16 weeks (each 12 minute point is the average of 360 readings).
Below is the graph of 16 weeks of data (note the picture is only 2K pixels across and there are 13K data points so some information is lost).image description
Below is the circuit diagram. Accurate timing is achieved by using a clock crystal.image description

datalogger pressure barometric


This is very clever. I wonder whether the memory in a Atmega 328p can be used to store data. I wonder if it is possible to access those data later. If those things are possible then a $2.00 Arduino Pro Mini might be all you need. Is the millisecond counter in a 328p good enough to rely on for timekeeping? If so, you can note the actual time you power it up and then compute clock time afterwards from the millisecond stamps.


Yes it would seem that you could do it with an atmega 328 one of the timers supports the use of a clock crystal which will get your timing accurate and if I am reading the data sheet correctly you can indeed store data in the unused flash memory. It does however seem like overkill to use a 28 pin device with huge amounts of memory. I case anybody is wondering about the barometric pressure data the wobbling is not noise it is showing (rather nicely in my opinion) the semidiurnal pressure variation which is rather pronounced close to the equator (where I am located).

It seems that it might be straightforward to store arrays of data in the 32k of flash memory in a 328p chip. Flash memory is non-volatile and your data will persist if the device is powered down. The keyword PROGMEM will write data to flash memory. I don't know how one would retrieve the data, but a sketch can read the data from flash. So your sketch could include code in the startup loop that read all the data from flash (one array element at a time?) and wrote it via serial (e.g., USB). So when you are finished logging data, connect via serial to a computer and the first thing that happens when the device is powered on is that all the data in flash memory is printed to the serial monitor.

Clock crystals which improve the precision of the arduino's millisecond counter cost five cents apiece, so that could be a worthwhile addition to a $2.00 Pro Mini data logger.

So this concept is for a single Arduino Pro Mini with a little crystal soldered to it, period. Cost so far $2.05. Connect batteries and sensors to it and it logs data for a long time.

But the Pro Mini could be put to sleep between logging events. This requires a real time clock ($1.00) with alarms to wake it up for the next logging. I don't know whether this is worthwhile because there is no uart chip or SD card to waste current, so there might be nothing to put to sleep.

If I had any real understanding of these things this would be a fun project to try.


I just use my programmer to read the falsh memory when it is getting full. The clcok crystal causes an wake-up (from sleep) interrupt when the timer overflows which is every 2 seconds.

It appears that storing data in flash memory on an Arduino is not so easy. The PROGMEM keyword only works for writing constants before the main loop starts. It cannot write anything to flash while the program is running.


Oh well. I know about everyones strange reluctance to use microchip devices, but really they do not keep much of any value to the experimenter hidden. If you look at their datasheets the PIC16F18326 is 470 pages long in fact it is probably too detailed. If anyone is interested I use the open source Great Cow Basic (which is excellent) to program the chips. I have a homemade programmer to load and read into and out of flash memory. The data from the flash memory(in HEX) is processed into a graph using (open source) QB64.

You must be logged in to comment.