Skip to content

Compact Flash based serial (RS232) data logger powered by PIC18F458


This is a complete project with following features:

  • Serial Data (received by built-in RS232 port of the PIC18F) logging with receive date/time
  • Compact Flash data storage
  • Last record display in character LCD
  • Built-in RTC (DS17885) with  battery backup
  • Setting the date/time and retrieval/erasing data via PC RS232 port


This project was done in order to receive and log serial data from a lighting location finder. We wanted to replace the PC used as the data logger with a less battery consuming reliable data-logger. We ended up designing and constructing our very own data logger for this purpose. The same data logger was also used as data logger for an unmanned weather station.

The Hardware

  • The design is based on a 40 pin PIC18F microcontroller. We have successfully tested this with PIC18F452, PIC18F458 and PIC18F4580.
  • A 40 x 2 character LCD is used as the display.
  • We used a 128MB CF card in the initial design and also tested with a 512MB card.
  • DS17885 RTC with built-in lithium battery
  • The CF card, LCD and the RTC share PORTD as the data/address bus. This minimizes required pins from microcontroller.
  • MAXIM RS232 transceiver IC supporting flow control (4Tx and 4Rx pins)
  • For pin connection of devices with microcontroller please refer to header files and ‘main.c’ main program file.

The Firmware/Software

  • Compact Flash data routines are based on MintyMP3 project. Used with some minor modifications and also altered to be compatible with HI-TECH PIC18 compiler.
  • RTC routines were written by me and are as same as what’s uploaded here
  • Delay, LCD and Serial port code is based on Shane Tolmie’s routines.
  • Serial port data retrieval is interrupt driven to minimize data loss. Maximum record length is  492 characters. Each record should be terminated with a CRLF. The maximum number of records is either 2^32-100 or the maximum number of LBA sectors in the CF card.
  • Records are saved as null-terminated strings preceded with date-time of the reception.
  • Uses hardware flow-control to signal not-ready while writing to CF card.


Download the complete project: CF-DAQ


Atmospheric and Lightning Research Group, Department of Physics, University of Colombo

2 thoughts on “Compact Flash based serial (RS232) data logger powered by PIC18F458

  1. Pavan Kakarla says:

    Can in use DS1307?


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.