Data Logger

Data Logger


The overall plan is to make a plug and play data logger than can store data to an SD card and over a network. The sensors to be logged will be configured using a text file on the SD card, so users don't need to actually program the mbed to reconfigure the device. The logger will have some basic built in sensors (temperature, pressure, light, etc) as well as breaking out extra analog and digital I/O as well as comms (I2C/SPI) to hook up other sensors. The data could be transferred over a network to a server running a MySQL database. This server could have web pages displaying the logged data, possibly also having the ability to reconfigure the logging from the web interface by providing a new configuration file for the mbed to download and use.

basic design

I'll try to implement a few of each of the following options:

Powering Options

  • AA battery pack
  • microUSB
  • coin cell for RTC?

Data Storage Options

  • SD card
  • MySQL over ethernet
  • Serial
  • Socket over ethernet?

On Board Sensors

  • Temperature
  • Light
  • Pressure
  • Humidity?

Breakout Pins

  • GND
  • 3.3V
  • 5V
  • AnalogOut (p18)
  • SPI
  • I2C
  • some digital I/O
  • some analog I

Configuration File

The configuration file will tell the mbed which channels to poll, use a counters, etc. The initial format (14 Jun 2012) will be:

PP <float: poll period>
FN <string: output filename>
DP <ints: digital poll pins>
AP <ints: analog poll pins>
CC <ints: counter (changing) pins>
CF <ints: counter (falling) pins>
CR <ints: counter (rising) pins> 
AS <floats: voltages>
PS <int: Pwm pin, floats: duty load>

For example:

PP 30.0
FN test.dat
DP 21 22
AP 20

This configuration will poll digital pins p21 and p22 as well as analog pin p20 every 30 seconds and save the results in a file called test.dat.

There is only one analog output (p18), so the analog scan doesn't need a pin number. A list of voltages (between 0 and 3.3) are given. The output will loop through these values, one per polling period. Each PWM scan needs its own line. First the pin number is given, followed by a list of duty loads (between 0.0 and 1.0) which are cycled through.

These parameters have been implemented already. I also plan to implement pulse inputs. I'll also implement MySQL info to connect to a remote MySQL server and store data there.


So far I've got the mbed saving data onto an SD card and also into a MySQL server on another computer via ethernet.


I'm currently implementing the different kinds of inputs/outputs I want the logger to have, although this is pretty much done.

To do list

  • display data from MySQL database on a webpage
  • make a configuration file on the SD card to define pins to log, logging period, etc
  • reorganise the code into useful libraries
  • Make the code more robust against SD card removal and bad configuration
  • test some on board sensors
  • test some powering options

2 comments on Data Logger:

16 Jun 2012

Hi, Can you please upload the code ? I am also working on SD+MYSQL data logging.

Thank you, Vatsal

16 Jun 2012

Hi Vatsal Shah,

Currently my main program is just a mash up of the example programs on /cookbook/MySQL-Client and /cookbook/SD-Card-File-System.

I'm working on the code to parse a text file to configure which pins to poll for analog/digital data. Once I have that working and tested I'll publish a first version of the code for this project.

Please log in to post comments.