Contents
  1. 1. Parts
  2. 2. Wiring
  3. 3. Code
  4. 4. Debug
  5. 5. Repository

During the weekend I wanted to create a small project which logs the data provided by an athmospheric pressure sensor to an SD card.

Parts

Previously I ordered a micro SD card shield from Banggood.com and I have a BMP180 pressure sensor from Adafruit.

The idea was to connect these two components to an Arduino Nano microcontroller and put the whole project onto a breadboard.

Wiring

The electrical connections among the project components can be seen on the following Fritzing diagram:

Code

The code was written in Arduino IDE. An excerpt can be seen below:

First the following required libraries have to be included:

1
2
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085_U.h>

The baud rate of the Serial connection has to be adjusted. I used 19200 as it can be seen below:

1
Serial.begin(19200);

The maximum amount of log lines is customizable through the following variables:

1
2
3
//Vairables for log count 
unsigned int logCountMaximum = 42;
unsigned int currentLogCount = 1;

The data will be logged into a file called pressure.log, which will be found in the root folder of the SD card:

The content of the log file is in the following format:

Index Pressure Temperature Altitude
milliBar celsius meters

Debug

In order to help debugging everything is written to the serial interface, so it can be viewed in Serial Monitor:

Repository

The PressureSensorLogger GitHub repository contains all project related materials.

Contents
  1. 1. Parts
  2. 2. Wiring
  3. 3. Code
  4. 4. Debug
  5. 5. Repository