Main »

Mini Data Logger

This project is a piece of software for recording events using an Arduino Pro Mini that has been converted to be clocked by a 32768 Hz crystal (see Arduino 32768). The ATMega 328p used in the Pro Mini has 1024 bytes of EEPROM/flash memory, enough to record 8 events a day for a month. The Pro Mini here emulates a Real Time Clock (RTC), although RTCs are cheap at ebay prices (£1), they involve more complexity and space. All that is needed is the Pro Mini and a small battery like a CR2032.

It is evident that the Pro Mini is going to have to go into sleep mode when nothing is happening to save battery power, and will wake either on a time event or on a level change on its inputs. If battery power is not a requirement there are other solutions, like running a normal Arduino continuously and using its standard internal clock.

The code uses the Arduino time library. This follows UNIX time and stores the number of seconds since the 1st January 1970 in a 4 byte integer. Every 8 seconds the Pro Mini wakes up and increments the time value. There is no effort to make resolution less than 8 seconds.

Communication with the Pro Mini is usually via the six pin header to which a TTL to USB serial port converter (FTDI - other brands are available) plugs in to. For the Mini Logger, the receive, transmit, CTS and GND pins can be connected as normal. DTR is used to reset the Pro Mini which will have the effect of resetting the clock, so DTR should not be connected. It is possible to open a serial port on Windows without toggling DTR (see Logger), just not easy or commonly supported.

Finally positive power from the USB converter is connected to the Pro Mini via a Schottky diode. Positive power from the battery comes via a similar diode. Some Pro Minis have a 'Raw' power pin with a reverse polarity protection diode to which the battery could be connected direct. These two diodes are simple 'power orring', whichever voltage is higher will power the Pro Mini and power will not flow back from USB converter to the battery or vice versa. The assumption is that the battery voltage will be lower than the 5 V from the USB.

Alas this is not the end of the matter, the transmit data pin of the Pro Mini defaults to high, as a result when the USB converter is disconnected from its host or the host is powered down, power from the battery will flow back via the Pro Mini transmit data pin into the USB converter. To get around this, the software monitors the Pro Mini power supply voltage and when it is less than a defined value (4.2 V look for 4200 in the code) turns off the serial port - allowing the transmit data pin to be put into a high impedance (input) state.

This connection scheme assumes the Pro Mini will be connected to a USB converter at the same time as a battery, and will have to cope with the USB host powering up and down. Other simpler modes of operation are possible.

With a serial connection, various commands can be used.

sl
Show Log - display the logged data

cl
Clear log - remove all data from memory

rt
Read Time - show the current time

wy <year>
Write Year - set clock year

wn <month>
Write moNth - set clock month

wd <day>
Write Day of month

wh <hour>
Write Hour (24 hour format)

wm <minute>
Write Minute

ws <second>
Write Second

Todo list:

  • Support sub-second resolution
  • Compensation for crystal clock
  • Allow analogue values to be written to the log
  • Provide alarm times to wake up and read things
  • Use RAM - there is more free RAM than EEPROM
  • Optimise data format to fit more in memory

I used a lot of freely available software. Credit to the people who wrote it and made it available.

Software sources:

Other resources:

Downloads:

Schematics: If you want the circuit diagram let me know.

Comments

Click to return to index

David Pilling's Wiki

Set view

Page last modified on November 05, 2016, at 02:20 AM - Powered by PmWiki pmwiki-2.3.31 (pmwiki-2.3.31)

^