In this course, we’ll go through the practical skills and knowledge base you need to deploy a custom, Arduino-based data logger in the field.
Through 6.5 hours of instructional, learn-at-your-own-pace videos, we cover everything a beginner to Arduino needs to get started, from common terminology and components to programming, and all the way though piloting, testing, deploying, and troubleshooting.
Build Your Own Data Logger is a collaboration between WILDLABS.NET – a community of conservationists, technologists, engineers, data scientists, entrepreneurs and change makers, and Freaklabs.
This 8-part series covers the following modules:
- Course Introduction and Q&A (video)
- Module 1: Understand the Hardware
- Module 2: Setting up the Arduino IDE
- Module 3: Programming Basic Functionality
- Module 3.1: The Arduino Command Line
- Module 3.2: Temperature and Humidity Settings
- Module 3.3: Measuring Battery Status
- Module 3.4: Real Time Clock
- Module 3.5: SD Card
- Module 3.6: Interrupts
- Module 4: Tying It All Together
- Module 5: Optimising Our Application
- Module 6: Ruggedizing Devices
- Module 7: Testing and Piloting
- Module 8: In The Field
Module 1: Understand the Hardware Design Stack
In Module 1, we take you through the design flow we use when we design devices. This gives a broad overview of what the requirements are, how we prototype, iterate, test, pilot and deploy them. We also discuss the basic hardware and software blocks that are common to most devices, their terminology, and what they do.
Module 2: Setting up the Arduino IDE
In Module 2, we first describe what we mean by ‘data logger’. Then we go into detail on setting up the Arduino environment for this course. We discuss installing the WildLogger board files, and setting up drivers so we can communicate with the board. Once that’s done, we introduce the Arduino program structure, then write and upload our first program, “Hello world”.
Module 3: Proof of Concept: Programming the Basic Functionality
In Module 3, we break down the basic functionality of our data logger into submodules. In each submodule, we explain the principles behind what we’re doing, and then write the code to interface with each functional block.
Module 3.1: Setting Up the Arduino Command Line
In Module 3.1, we discuss why we’re using the command line, and install the Arduino Command Line library written by us at Freaklabs. Once that’s installed, we go through our hands-on labs where we write code to implement the command line directly on the Wildlogger board. We also implement a table of custom commands which allows us to control the WildLogger in real time, in this case, changing the speed of a blinking LED.
Module 3.2: Temperature and Humidity Settings
In Module 3.2, we get an overview of the temperature and humidity sensor we’ll be using for this course. We learn the basics of temperature and humidity measurement, how the sensor works, and how to install the Arduino library to access and control the sensor. After that, we do hands-on labs where we read the temperature and humidity, control the sensor from our command line, and then use the temperature and humidity data to control another device.
Module 3.3: Measuring Battery Status
In Module 3.3, we learn about how analog to digital conversion (ADC) works and what the terminology actually means. We learn about ADC resolution and bit-depth, sampling rates, and things that can increase or decrease the accuracy of our ADC. Finally we use the internal ADC on the Wildlogger board to measure our battery voltage which will eventually allow us to track our battery levels on the datalogger. By the end of this submodule, you’ll know the difference between a 10-bit ADC and a 16-bit ADC, how to interface sensors to them, and how to write software to read and process their data.
Module 3.4: Real Time Clock
In Module 3.4, we learn about how real time clocks (RTCs) are used in instrumentation. Timekeeping plays a central role in scientific field instrumentation. It’s used to timestamp data, synchronize multiple standalone devices, and also controls power management. We discuss how RTCs work, how outdoor conditions affect clock accuracy, and the different types of clocks and their accuracy. We also learn how to access and control the real time clock on the WildLogger board, set the date and time, and read it in different formats.
Module 3.5: SD Cards and the FAT File System
In Module 3.5, we begin with the basics of SD cards in all their wonderful form factors and flavors. We discuss the technology that makes SD cards possible, the types of memory cards, the form factors, their reliability, and power consumption. We also discuss what all those little numbers you normally ignore on your SD card mean, like read speed, card type, speed class, UHS speed class, and bus speed.
Once that’s done, we talk about file systems and why they’re needed. We go into how a file system fits on top of SD cards, how it organizes the bulk storage on an SD card, and the different types of file systems including FAT32 and exFAT.
In the lab portion, we’ll learn how we access the SD card on the WildLogger, installing the Arduino library to control our SD cards, and how easy it is to implement a system that can access multiple SD cards. We learn how to create and open files for reading, writing, or appending, how to read and write to a file, and things to watch out for to prevent file corruption. We implement a mini DOS system (Wild-DOS?) with commands to list files in a directory, and read, write, and delete files. Finally we finish off by implementing a command to write timestamped sensor data and files to our SD card.
Module 3.6: Interrupts
In this final submodule for Module 3, we’ll be discussing the voodoo topic of interrupts. Interrupts are a bit of an intermediate/advanced topic in device design but they’ll also play an important role in our data logger, and many other field devices.
We start by discussing interrupts, how they fit into our power management strategy, and how they can be extended to implement things like operating systems. We then get introduced to actual interrupt implementation using the on-board pushbutton on the WildLogger. We learn things that can go wrong with push buttons, how to work around those limitations, and how to write interrupt handlers to manage push button events.
We then learn about PIR motion sensors, how they work, their limitations, and what PIR stands for. We learn how temperature affects range and also how to compensate to reduce false positives at low temperatures and missed opportunities at high temperatures. We learn how to interface a PIR motion sensor, how to write an interrupt handler for them, and programmatic limitations like their warm-up times and reset times.
Finally we learn how to set timers and alarms on our real-time clock. This fits into the main power management strategy for WildLogger and will allow us to sleep most of the time and just wake up to collect data on a minute, hourly, daily, weekly, or even monthly basis.
Now that we have an understanding of the basic functionality of our data logger, and working code that’s been tested, we’ll be ready to tie everything together in Module 4 where we create our functional data logger application.
Module 4: Tying It All Together
In this module, we tie together everything we’ve learned so far into a functional data logger application. We’ll be implementing the temperature and humidity sensor, realtime clock, analog digital converter, SD cards,PIR motion sensor, and command line interface to implement a test version of our datalogger. We’ll then test it for functionality and check that we have things in the format we want it in.
In the second part of this module, preparing for failure, we learn that everything fails and it’s important to prepare for this. We’ll add additional safety checks to prevent what we can, diagnostic logs for documenting errors after the fact, and error codes which will be important for both field work and forensic studies when a device fails in the field.
This module will be code heavy since we’re not introducing any new concepts, but integrating a lot of things together.
Module 5: Optimising Our Application
In Module 5 we’ll optimise our data logger application, and add the finishing touches to our application code so it’s ready for deployment.
We go through calculating battery life, ways to power optimise our device in both the hardware and software, putting our device into low power mode and waking it up again, and implementing a watchdog timer to gracefully recover from tricky embedded software bugs like stack overflows, race conditions and memory leaks. Then, we’ll remove our command line code, and implement all these features into our final deployment code. Woohoo!
Module 6: Optimising Our Application
In Module 6 we discuss ways to project devices from water, dust and animals. Then we assemble the WildLogger using cable glands so our device remains protected in its enclosure.
Mechanical failures are a common reason devices fail in the field, however there’s lots we can do to protect our devices. In this module we cover enclosure IP ratings, screws, and protecting the bare PCB using varnish, potting, heat shrink tubing and silica gel. We also discuss wire gauges and AWG ratings. Plus we cover waterproofing holes with ePTFE and TPU, securing cables using cable harnesses, and getting our cables safely through the enclosure using cable glands and external connectors like barrel jack aviation, SP and M connectors.
Finally, we go through how to disassemble and reassemble cable harnesses so we can thread the WildLogger cables through the cable glands and seal it, ensuring our enclosure remains IP65 rated.
Module 7: Optimising Our Application
In module 7, we take our fully assembled system into the lab, sandbox and pilot test environments. We go through the purpose of each environment, running accelerated testing and some general tips. We also troubleshoot common issues such as shorter-than-expected battery life, inaccurate readings and missed readings.
Module 8: In The Field
We’ve built, coded and tested our data logger. In Module 8, we take it into the field. We’ll discuss the overall field maintenance approach, and go through useful equipment to have with you including solder irons, wire strippers, wire crimpers, extra cable harnesses, extra wires, and a bunch more. Finally, we discuss visually expecting devices for damage, and debugging with and without a laptop.
Course Materials
Each module includes sketches (Arduino programmes), terminology sheets and pdfs of the video presentations. You can download the materials for each module individually via the module page, or download the complete set below.
- All sketches (github repo)
- All sketches (page)
- All terminology (pdf zip)
- Modules 1 -3 (pdf zip)
- Modules 4 -8 (pdf zip)