Public Lab Research note

Simple data logger

by david_uwi | | 414 views | 10 comments |

Read more:

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

I did this Help out by offering feedback!

People who did this (0)

None yet. Be the first to post one!


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.


Is this a question? Click here to post it to the Questions page.

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.


Is this a question? Click here to post it to the Questions page.

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.

Thanks for this super work @david_uwi ! I tagged this note so that it appears with the other data loggers

Thanks for bringing this to prominence again. I will attach the code that runs the microprocessor.

presslogger.txt This as mentioned above is writtten in GCBasic ( ) Note: the total cost is about 8GBP (the optional display is most of the cost).

I also like the prospect of an Atmega 328 with no SD card for logging. How much of the 32k memory would be available after flashing the program?

Maybe we could formulate some questions/challenges on this site to frame out that project and get other people to dig into prototyping these. It's also a bit beyond my skill set at the moment but if we frame the challenge and constraints narrowly enough (like with the prices and parts you listed above, Chris) maybe we can inspire someone to take a crack at it!

Is this a question? Click here to post it to the Questions page.

Super - added this here:

Login to comment.

Public Lab is open for anyone and will always be free. By signing up you'll joined a diverse group of community researchers and tapped into a lot of grassroots expertise.

Sign up