ModularSensors > Pages > ModularSensors > Examples Using ModularSensors

Examples Using ModularSensors

These example programs demonstrate how to use the modular sensors library. Each example has slightly different functionality.


Basic Functionality

Single Sensor

The single_sensor example shows making use of the unified set of commands to print data from a MaxBotix ultrasonic range finder to the serial port. It also shows creating a calculated variable which is the water depth.

Simple Logging

The simple logging example shows how to create multiple sensors, create variables for the sensors in a variable array, and log the data from the sensors to an SD card.

Simple Logging for the Learn EnviroDIY course

The simple logging example for the Learn EnviroDIY programming course shows how to create multiple sensors, create variables for the sensors in a variable array, and log the data from the sensors to an SD card. It is very similar to the other simple logging example, with just a few extra sensors.


Publishing Data

Publishing to Monitor My Watershed

The logging to Monitor My Watershed example uses a Digi XBee in transparent mode to publish data live from a BME280 and Maxim DS18 to the Monitor My Watershed data portal.

Publishing to ThingSpeak

The logging to ThingSpeak example uses an ESP8266 to send data to ThingSpeak. It also includes a Meter Hydros 21 (formerly know as a Decagon CTD) and a Campbell OBS3+.


Calculations and Complex Logging

Barometric Pressure Correction

The barometric pressure correction example demonstrates how to work with calculated variables and calculates water depth by correcting the total pressure measured by a MeaSpec MS5803 with the atmospheric pressure measured by a Bosch BME280 environmental sensor and the temperature measured by a Maxim DS18 temperature probe.

Multiple Logging Intervals

The more complicated double logger example using two different logger instances to log data at two different intervals, in this case, an AM3215 logging every minute, while checking the battery voltage only every 5 minutes. This showcases both how to use two different logging instances and how to use some of the functions to set up your own logging loop rather than using the logData() function.

Minimizing Cell Data Usage

The data saving example is another double logger example, but in this case, both loggers are going at the same interval and the only difference between the loggers is the list of variables. There are two sets of variables, all coming from Yosemitech sensors. Because each sensor outputs temperature and we don't want to waste cellular data sending out multiple nearly identical temperature values, we have one logger that logs every possible variable result to the SD card and another logger that sends only unique results to the EnviroDIY data portal. This example also shows how to stop power draw from an RS485 adapter with automatic flow detection.


DRWI Citizen Science

DRWI Mayfly 1.x LTE

The DRWI Mayfly 1.x LTE example uses the sensors and equipment standard groups participating in the DRWI Citizen Science project with the Stroud Water Research Center. It includes a Meter Hydros 21 and a SIM7080G-based EnviroDIY Bee for communication. This examples also makes use of the on-board light, temperature, and humidity sensors on the Mayfly 1.x. The results are saved to the SD card and posted to the Monitor My Watershed data portal.

DRWI EnviroDIY Bee LTE

The DRWI EnviroDIY Bee LTE example uses the sensors and equipment standard groups participating in the DRWI Citizen Science project with the Stroud Water Research Center. It includes a Meter Hydros 21, a Campbell OBS3+, and a SIM7080G-based EnviroDIY Bee for communication. The results are saved to the SD card and posted to the Monitor My Watershed data portal. The only difference between this and the other cellular DRWI examples is the type of modem used.

DRWI Digi LTE

The DRWI Digi LTE example uses the sensors and equipment standard groups participating in the DRWI Citizen Science project with the Stroud Water Research Center. It includes a Meter Hydros 21 (formerly know as a Decagon CTD), a Campbell OBS3+, and a Digi XBee3 LTE-M for communication. The results are saved to the SD card and posted to the Monitor My Watershed data portal. The only difference between this and the other cellular DRWI examples is the type of modem used.

DRWI CitSci (2G)

The 2G DRWI Citizen Science example uses the sensors and equipment standard groups participating in the DRWI Citizen Science project with the Stroud Water Research Center. It includes a Meter Hydros 21 (formerly know as a Decagon CTD), a Campbell OBS3+, and a Sodaq GPRSBee for communication. The results are saved to the SD card and posted to the Monitor My Watershed data portal. The only difference between this and the other cellular DRWI examples is the type of modem used.

DRWI CitSci No Cellular

The DRWI no cellular example uses the sensors and equipment standard to the DRWI Citizen Science grant but omits the data publisher for circumstances where there is no cellular signal. The exclusion of the modem and publisher simplifies the code from the other DRWI examples and uses less power than running one of cellular versions without attaching the modem.


Everything at Once - a la carte

Menu a la carte

The "menu a la carte" example shows most of the functions of the library in one gigantic program. It has code in it for every possible sensor and modem and for both AVR and SAMD boards. It is also over 1500 lines long. This examples is intended to be used like an a la carte menu of all possible options where you selected only the portions of code pertenent to you and delete everything else. This example is NOT intended to be run in its entirety

  • The menu a la carte walkthrough
    • Unlike the instructions for the other examples which show how to modify the example for your own use, this is a chunk-by-chunk step through of the code with explanations of each portion of the code and links to further documentation on each sensor.
    • There is a table of contents at the top of the walkthrough; I strongly recommend using that to skip through to the portions you are interested in
  • The a la carte example on GitHub