Tour of Modular Sensors Library

Overview

Teaching: 30 min
Exercises: 0 min
Questions
  • How does the Modular Sensors Library meet all of the requirements of data logging?

  • How do I use the Modular Sensors sketches?

  • Why would I clone vs download a repository?

  • Where do I store my own sketches?

Objectives
  • Download the Modular Sensors Library and become acquainted with its features.

Episode 9: Tour of Modular Sensors Library

The ModularSensors Library is thoroughly documented on GitHub, both in the repository’s readme files, and also in very extensive code documentation at https://envirodiy.github.io/ModularSensors/. The documentation outlines what Modular Sensors does, how to (get started)[https://envirodiy.github.io/ModularSensors/getting_started.html] to use it, (supported sensors)[https://envirodiy.github.io/ModularSensors/index.html#mainpage_supported_sensors], (supported radio modules)[https://envirodiy.github.io/ModularSensors/index.html#mainpage_modems], (walkthroughs of example sketches)[https://envirodiy.github.io/ModularSensors/the_examples.html], (frequently asked questions)[https://envirodiy.github.io/ModularSensors/faq_page.html], and more. You may refer to this documentation at any time. In this episode we will walk you through the process of getting Modular Sensors sketches ready to run on your system.

We learned in the last episode on data logging all of the things we need to consider when logging data. Moving from running simple sensor sketches like we did in Part 1 to meeting all of the demands of data logging requires a massive jump in skill level. Modular sensors provides us with a code “wrapper” that is designed to work within the EnviroDIY ecosystem to allow new users the means to log data.

Built into the Modular Sensors Library is the ability to

Clone the ModularSensors repository

To get the files on your computer from any public GitHub repo, including Modular Sensors, you have a couple of options. You may download all of the files for the repo, as we did in Part 1, Episode 5 to get the tutorial sketches. But if you want to remain current with development updates, we recommend that you “clone” a repo. Since your purpose in this tutorial is to begin your own environmental monitoring, we recommend that you clone the Modular Sensors repo.

To clone Modular Sensors,

  1. Go to the following site: https://github.com/EnviroDIY/ModularSensors
  2. Click on the green “Clone or download” button
  3. Select “Open in Desktop” (confirm to “Open GitHub Desktop.app”)
  4. A dialogue box will appear in GitHub Desktop where you can indicate where you want to put the files. (e.g. I keep all of my Arduino work in a folder by that name located in my root directory /~Documents/Arduino/…)

Repository branches

Modular Sensors repo is still new and is being regularly modified and improved with new or refined features. Developers add and test new features in different branches of the repository. At any given time, the branches will look something like the image below:

Notice in this image that an individual is working on their own branch of Modular Sensors. The way GitHub is structured, anyone can copy a repository and modify their copy. In much of society, this level of transparency and sharing is unusual. In the GitHub world this kind of activity is encouraged and regarded as a strength of the platform. When a repo is forked, the attribution of all original contributors is retained. Users who modify the fork can offer to merge their features back into the original repo (through a “pull request”), offering improvements and development capacity that the original team may not have considered or had time to contribute.

You can easily switch between which branch is saved on your computer in GitHub Desktop by changing the “Current Branch” selection (this may not be a good thing if you change it unintentionally!). “Master” is the default branch for the Modular Sensors repo, and is the place were features have been tested and are ready for use.

Managing your sketches in your own deployments repo

You just cloned a repository that we want to watch for updates, but you do not have access to send edits back to this repo. Also, you will be editing the sketches from the Modular Sensors repo for your own sensor stations, which may result in your files getting overwritten when you pull updates or “Fetch origin” from GitHub. For all of these reasons, we recommend that you create a new repository for your own sketches.

Anatomy of Modular Sensors Sketches

Open your copy of simple_logging.ino. This sketch is 209 lines long (as of ModularSensors v0.25.0) with multiple sections. We will give you a what you need to know for each section.

In the next episode, we will set up this sketch and run some sensors!

Key Points

  • Modular Sensors Library features. Cloning vs downloading repository. Using your own repository.