Journal:Open source data logger for low-cost environmental monitoring

From LIMSWiki
Revision as of 19:37, 30 June 2016 by Shawndouglas (talk | contribs) (Added content. Saving and adding more.)
Jump to navigationJump to search
Full article title Open source data logger for low-cost environmental monitoring
Journal Biodiversity Data Journal
Author(s) Baker, Ed
Author affiliation(s) The Natural History Museum - London
Primary contact edwbaker at gmail dot com
Editors Caithness, Neil
Year published 2014
Volume and issue 2
Page(s) e1059
DOI 10.3897/BDJ.2.e1059
ISSN 1314-2828
Distribution license Creative Commons Attribution 4.0 International
Download Click the "PDF" button on the website.


The increasing transformation of biodiversity into a data-intensive science has seen numerous independent systems linked and aggregated into the current landscape of biodiversity informatics. This paper outlines how we can move forward with this program, incorporating real-time environmental monitoring into our methodology using low-power and low-cost computing platforms.

Keywords: Arduino, open source, open hardware, environmental monitoring, big data, internet of things, temperature, humidity, Ethernet


Low power and cheap computational projects such as Arduino and Raspberry Pi have brought the use of small computers and micro-controllers to the masses, and their use in fields related to biodiversity science is increasing (e.g. Hirafuji shows the use of Arduino in agriculture[1]). There is a large amount of potential in using automated tools for monitoring environments and identifying species based on these emerging hardware platforms, but to be truly useful we must integrate the data they generate with our existing systems. This paper describes the construction of an open-source environmental data logger based on the Arduino platform and its integration with the web content management system Drupal which is used as the basis for Scratchpads[2] among other biodiversity tools. The Drupal platform uses familiar open-source standards while the Arduino hardware uses the emerging open hardware licenses (see below). It is assumed that most biodiversity scientists are not familiar with the construction of electronic devices, so this paper is presented more in the style of a "how to guide" rather than a straightforward functional description. It is hoped that people will make use of the technologies described here and adapt them to the needs of their own interests and projects.

Open hardware?

The open source hardware movement extends the familiar licenses of open-access and open-source software to physical objects. The aim is to create an ecosystem of projects and products much like the community that develops around open-source software. To be open hardware, all materials needed to construct the hardware (schematics, printed circuit board (PCB) layouts, bills of materials) and the software required (on device and ideally to interface with the device) must be released under a permissive "copyleft" license. More information about open hardware can be found at the Open Source Hardware Association.[3]

Citizen engineers

The introduction of easy-to-use micro-controller devices such as the Arduino brought working with digital electronics to a broader audience. The Arduino project[4] (and similar initiatives) has generated a number of books and a plethora of web pages detailing the basic use of the devices and the use of sensors (ideal for data-logging), writing to SD cards (Secure Digital: a format of memory card widely used in digital cameras) and interfacing with the internet.[5][6] Additionally, there are a wide range of books describing the basics of electronics; Scherz's Practical Electronics for Inventors[7] is recommended as a reference text due to its comprehensive approach and detailed theory, but one of the many electronics "primer" books may be a better introduction. There is great potential for the biodiversity community if we collaborate with knowledgeable "hackers" and "makers" as citizen engineers in the same way we interact with knowledgeable amateur natural historians as citizen scientists.

Project description

Design description

The device constructed is intended both as a functional device capable of generating useful environmental datasets and also as a demonstration to the biodiversity community of what is possible using the Arduino system as a base. This project aims to be as easy as possible to construct and use for those with no experience in electronic devices, and for this reason we have steered away from the use of custom PCBs or other materials. The use of a prototyping board rather than a custom PCB also allows for the project to be extended more easily and assembled without soldering. The author would encourage anybody who wishes to release a custom PCB layout for this project to do so.


This project was supported by the European Union funded ViBRANT project (Contract no. RI-261532).

Web location (URLs)


Bug database:

Technical specification

Platform: Arduino / Drupal

Programming language: C / PHP

Operating system: Arduino / Linux (can also run on Windows/OS X)


Type: Git

Browse URL:

Usage rights

Use license: Other

IP rights notes: The Drupal code and Arduino code are released under the GNU General Public License version 2 or later.


The requirements for the device, and the server software (Drupal) that receives the data were specified as follows:

Data logger

  • Be able to record the temperature and humidity at a regular time interval (e.g. every five minutes)
  • Record the data collected to a micro-SD card
  • Submit data collected automatically and in real time to a Drupal website (using an Ethernet connection)
  • Have a real time clock (RTC) – the Arduino internal clock counts milliseconds since the micro-controller was turned on, we need to record the actual time of measurement
  • Use standard and readily-available components
  • Be able to run off readily-available batteries (e.g. AA) for at least eight hours

Server software

  • Be able to receive data from a device or more than one device and save it as a Drupal node (content item)
  • Be able to generate code for the Arduino to assist others in using this software to post data


This project should be useful to a wide range of biodiversity scientists. Some possible study scenarios include:

  • using a single device alongside a light, malaise or pitfall trap to collect abiotic data over the study period
  • using multiple devices to study small climatic differences between different micro-habitats
  • using devices over a long period to compliment studies on organism phenology

It is hoped that the publication of this device will encourage biodiversity scientists to collaborate outside of their discipline, whether it be with citizen engineers or professional academics. A work by Baker, Bennett and Chesmore (University of York) in 2013 (in prep) expands the concept of using electronic devices from monitoring environments to automated species identification using the acoustics of orthoptera.[8] Where reliable identification of species can be performed by machines, the potential for collecting high quality, high precision and long-term datasets on species abundance alongside environmental variables becomes a possibility.

Additional information

Sourcing of components

This project uses standard components which can be sourced from specialist electronics suppliers (e.g. Maplin[9], RS[10], Rapid Electronics[11] in the U.K.). A number of online shops serve the needs of the hacker and maker communities including Adafruit[12] in the U.S. and Cool Components[13] in the U.K. Generic online retailers such as eBay and Amazon will also have listings for most, if not all, of the materials required.

Assembly of the device

The data logging device uses the Arduino Mega board[14] (Fig. 1) which encompasses an ATmega2560 micro-controller[15] and associated hardware to provide a clock signal, regulate power to the board and to allow the micro-controller to be programmed via the USB interface. A number of analogue input and digital input/output pins are exposed on the board for the attachment of other electronic devices for input or output (these connectors are known as 'headers'). The Arduino Mega is an expanded version of the standard Arduino Uno[16] which has a greater number of input/output connections and also a larger programmable memory. The code and libraries required for this project exceed the Arduino Uno's capacity, but an Arduino Uno may be used if some functionality (e.g. the real-time clock or Ethernet libraries) is removed. You will need to download the Arduino Integrated Development Environment (IDE) software from the Arduino website.[17] The Arduino platform is favoured over the Raspberry Pi in this instance due to its lower power consumption allowing the device to run longer on battery power (the Raspberry Pi is a low-power Linux computer and has capabilities well beyond what is needed for this project).

Fig1 Baker BiodiversityDataJournal2014 2.JPG

Figure 1. An Arduino Mega board. The board can be powered and programmed using the USB connector (top left) or powered as a standalone device using the circular power connector (bottom left).

Several expansion boards are available for the Arduino, which have pins allowing them to attach to the black connectors on the main Arduino board. These expansion boards are known as "shields" and two different ones have been used in this project. The first, the Arduino Ethernet Shield[18] (Fig. 2), provides both an Ethernet interface (allowing the Arduino to communicate over a local network or the Internet) and allows a micro-SD card to be inserted (allowing data to be saved locally). Both of these shields expose the full set of Arduino headers – allowing the shields to be stacked on each other for additional functionality. Standard software libraries for the Arduino are available to provide easy access in code to this hardware. The second shield used is one of the available "prototyping shields"[19] – an electronics breadboard that allows for the prototyping of different circuitry without having to make permanent soldered connections (Fig. 3). While for a production product a custom printed circuit board (PCB) would be much better than a temporary prototype shield it is used here, as one of the hopes of this paper is that readers will take the work presented and once familiar with the principles modify or extend it to meet the requirements of their projects.

Fig2 Baker BiodiversityDataJournal2014 2.jpg

Figure 2. The Arduino Ethernet Shield attached to the Arduino Uno. The Ethernet socket (left) and micro-SD socket (right) are indicated.

Fig3 Baker BiodiversityDataJournal2014 2.jpg

Figure 3. The Arduino Mega (bottom), Ethernet shield (middle) and prototyping shield (top) stacked as the core of the data logger. Some of the other components of the device are being assembled using the solder-less breadboard on the prototyping shield.

By stacking first the Ethernet shield and then the prototyping shield on top of the Arduino Mega the central core of the data logger is formed. This central system controls reading data from the sensors, processing that data into standard units of measurement if needed, then recording them to a micro-SD card and/or submitting them to a website. What we have is a small, low power and low cost internet-connected computational device. Systems using these components are often used for "Internet of Things" projects.[6]

The temperature and humidity measurements are made using a DHT22 digital sensor (a digital output sensor sold packaged in plastic housing as AM2303[20]; Fig. 4). These sensors communicate with the Arduino using a DHT22 library (this abstracts the details of communicating directly with the sensor). You will need to download this library and add it to your Arduino Integrated Development Environment (IDE) before trying to compile the code for this project.[21] For ease of (re/de)assembly male-female connecting wires (Fig. 5) are used to attach the sensor to the Arduino. With the sensor facing you the pins are numbered left to right from 1 to 4. Pin 1 should be connected to the 5 V supply from the Arduino, pin 2 from the sensor should be attached to digital (not analogue) pin 2 on the Arduino – this is the line of communication between the devices. Finally pin 4 should be attached to the Arduino ground (GND) – pin 3 is not used.

Fig4 Baker BiodiversityDataJournal2014 2.jpg

Figure 4. DHT22 digital temperature and humidity sensor in AM2303 package. From left to right the pins are VDD (power supply), DATA, unused and GRD (ground).

Fig5 Baker BiodiversityDataJournal2014 2.jpg

Figure 5. Male-Female connecting wires make it easy to attach sensors to the Arduino board while prototyping.

The device uses a battery-powered real time clock (RTC) to maintain an internal measurement of Universal Coordinated Time (UTC). The RTC chip used is a standard DS1307[22] in a dual-in line (DIL) package (Fig. 6) and we make use of the DS1307RTC Arduino library.[23] You may prefer to invest in some basic tools for handling DIL packages (Fig. 7). In addition to the DS1307 chip we also need a 32.768 kHz crystal (used by the DS1307 to maintain accurate time; Fig. 6) and a 3 V Lithium cell and cell holder (a CR2032 cell is used here; Fig. 8). These Lithium cells are widely known as "coin" or "watch" cells. The cell provides a power source for the DS1307 and crystal circuit when the Arduino power is removed (when the device is turned off). The DS1307 has very low power requirements and a CR2032 cell should last for several years.

Fig6 Baker BiodiversityDataJournal2014 2.jpg

Figure 6. DS1307 RTC and 32.768 kHz crystal.

Fig7 Baker BiodiversityDataJournal2014 2.jpg

Figure 7. Tools for manipulating DIL integrated circuit packages such as the DS1307. On the left is an extraction tool which helps to remove DIL packaged chips from a breadboard, on the right is a tool to assist in straightening any bent pins on the package.

Fig8 Baker BiodiversityDataJournal2014 2.jpg

Figure 8. Clip for a Lithium coin cell: empty (left) and with cell inserted (right). The clip has pins for insertion into a breadboard or PCB on the reverse.


  1. Hirafuji, M. (2013). "Comprehensive Data Collection by Sensor Network and Optical Sensor for Agricultural Big Data" (PDF). APAN. 
  2. Smith, V.S.; Rycroft, S.D.; Brake, I. et al. (2011). "Scratchpads 2.0: a Virtual Research Environment supporting scholarly collaboration, communication and data publication in biodiversity science". ZooKeys 150: 53–70. doi:10.3897/zookeys.150.2193. PMC PMC3234431. PMID 22207806. 
  3. "Open Source Hardware Association". Open Source Hardware Association. 
  4. "Arduino - Home". Arduino, LLC. 
  5. McRoberts, M. (2010). Beginning Arduino. Apress Media, LLC. pp. 472. ISBN 9781430232407. 
  6. 6.0 6.1 McEwen, A.; Cassimally, H. (2013). Designing the Internet of Things. John Wiley & Sons. pp. 336. ISBN 9781118430620. 
  7. Scherz, P.; Monk, S. (2013). Practical Electronics for Inventors (3rd ed.). McGraw-Hill Education. pp. 1040. ISBN 9780071771337. 
  8. Bennett, W.; Chesmore, D.; Baker, E. (6 December 2013). "Speckled Bush Cricket Data Logger - Project Report". University of York. pp. 29. doi:10.6084/m9.figshare.1430094. 
  9. "Maplin". Maplin Electronics. 
  10. "RS Components". RS Components Ltd. 
  11. "Electronic components from Rapid". Rapid Electronics Limited. 
  12. "Adafruit". Adafruit Industries, LLC. 
  13. "Cool Components". Cool Components Ltd. 
  14. "Arduino MEGA 2560 & Genuino MEGA 2560". Arduino, LLC. 
  15. "ATmega2560". Atmel Corporation. 
  16. "Arduino UNO & Genuino UNO". Arduino, LLC. 
  17. "Download the Arduino Software". Arduino, LLC. 
  18. "Arduino Ethernet Shield". Arduino, LLC. 
  19. "Adafruit Proto Shield for Arduino". Adafruit Industries, LLC. 
  20. "Digital-output relative humidity & temperature sensor/module AM2303" (PDF). Aosong (Guangzhou) Electronics Co., Ltd. pp. 7. 
  21. "Installing Additional Arduino Libraries". Arduino, LLC. 
  22. "DS1307 64 x 8, Serial, I2C Real-Time Clock" (PDF). Maxim Integrated Products, Inc. 
  23. "arduino-libraries/Time_root/DS1307RTC/". GitHub, Inc. 


This presentation is faithful to the original, with only a few minor changes to presentation. In some cases important information was missing from the references, and that information was added. In many cases what were originally inline external links were turned into proper citations. A few references were mentioned but not directly cited; citations were added to fill those gaps.