SensorReporter
is the quickest way to fetch and publish data from IoT sensors.
SensorReporter
is an Arduino Library but was only tested with Particle ecosystem.
Note: if you tested it with any other platforms, please create a PR with instructions to let everyone know!
- Using the Web IDE, Desktop IDE or the CLI add the
SensorReporter
to your project. - Create a
sr-config.h
file and configure all connected sensors and reporters - In your main file, Include and instantiate
SensorReporter
:#include "sensor_reporter.h" SensorReporter sensorReporter;
- In
setup()
function initalize all sensors and reporters:void setup() { sensorReporter.begin(); }
- In
loop()
function request a report:void loop() { sensorReporter.loop(); }
- If you're using external library, add it to the
library.properties
file as well
Note: if you want to implement additional sensors or reporters, please submit a PR!
- Analog input using built in ADC
- HTU21D temperature & humidity sensor via SparkFun_HTU21D_Breakout_Arduino_Library
- Soil moisture sensor using ADC
- PMS3003 air quality sensor
- Printing to serial port in
NAME=VALUE
format - Publishing Particle events
This header file is used to configure the SensorReporter
. To disable a sensor or reporter, comment out the relevant lines. Here's a reference file:
// ***** GENERAL SETTINGS *****
// All sample names will be prefixed with this string
#define SAMPLE_PREFIX "home_"
// How many miliseconds wait before next report
#define REPORTING_INTERVAL 10000
// ***** SENSORS *****
// First built-in ADC pin (in the future, you'll be able to pull more pins)
#define SENSOR_ANALOG_PIN_1 A0
// Name to report this pin as
#define SENSOR_ANALOG_PIN_1_NAME "soil"
// HTU21D temperature and humidity sensor
#define SENSOR_HTU21D
// PMS3003 air quality sensor
#define SENSOR_PMS3003
// Soil moisture sensor using ADC
#define SENSOR_MOISTURE_ANALOG_PIN A7
// Pin connected to sensor's VCC
#define SENSOR_MOISTURE_ENABLE_PIN D2
// ***** REPORTERS *****
// Serial port reporter
#define REPORTER_SERIAL_BAUDRATE 9600
// Particle event reporter
#define REPORTER_PARTICLE
- Take a peek at
src/sensors
andsrc/reporters
directories - Create a class that inherits
ISensor
orIReporter
and implements all virtual methods - In
sensor_reporter.cpp
:- add declarations of your classes in the beginning
- in the
begin()
function:- initialize your class
- add it to collector with
collector.addSensor()
orcollector.addReporter()
Once it's working, please create a PR so more people can use it :) All contributions (no matter if small or big) are always welcome!
- Thermometer, Wind & Drops icons by Luis Rodrigues from the Noun Project
- Serial Port icon by Dalpat Prajapati from the Noun Project