Skip to content

Latest commit

 

History

History
113 lines (83 loc) · 3.68 KB

README.md

File metadata and controls

113 lines (83 loc) · 3.68 KB


SensorReporter


SensorReporter is the quickest way to fetch and publish data from IoT sensors.


Installation & configuration

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!

  1. Using the Web IDE, Desktop IDE or the CLI add the SensorReporter to your project.
  2. Create a sr-config.h file and configure all connected sensors and reporters
  3. In your main file, Include and instantiate SensorReporter:
    #include "sensor_reporter.h"
    SensorReporter sensorReporter;
  4. In setup() function initalize all sensors and reporters:
    void setup()
    {
        sensorReporter.begin();
    }
  5. In loop() function request a report:
    void loop()
    {
        sensorReporter.loop();
    }
  6. If you're using external library, add it to the library.properties file as well

Supported sensors & reporters

Note: if you want to implement additional sensors or reporters, please submit a PR!

Sensors

Reporters

sr-config.h file

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

Implementing new reporters or sensors

  1. Take a peek at src/sensors and src/reporters directories
  2. Create a class that inherits ISensor or IReporter and implements all virtual methods
  3. 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() or collector.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!

Attributions

  • Thermometer, Wind & Drops icons by Luis Rodrigues from the Noun Project
  • Serial Port icon by Dalpat Prajapati from the Noun Project