Commit c82e3a89 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Update for PlatformIO

parent 262b8211
......@@ -4,3 +4,7 @@
NodeManager is intended to take care on your behalf of all those common tasks a MySensors node has to accomplish, speeding up the development cycle of your projects.
NodeManager includes the following main components:
- Sleep manager: allows managing automatically the complexity behind battery-powered sensors spending most of their time sleeping
- Power manager: allows powering on your sensors only while the node is awake
- Battery manager: provides common functionalities to read and report the battery level
- Remote configuration: allows configuring remotely the node without the need to have physical access to it
- Built-in personalities: for the most common sensors, provide embedded code so to allow their configuration with a single line
Documentation available on:
// load user settings
#include "config.h"
// include supporting libraries
#ifdef MY_GATEWAY_ESP8266
#include <ESP8266WiFi.h>
// load MySensors library
#include <MySensors.h>
// load NodeManager library
#include "NodeManager.h"
// create a NodeManager instance
NodeManager nodeManager;
// before
void before() {
// setup the serial port baud rate
* Register below your sensors
nodeManager.setSleep(SLEEP, 2, MINUTES);
Serial.print(F("BEFORE registerSensor0: ")); printFM();
nodeManager.registerSensor(SENSOR_MQ, A0, 0);
Serial.print(F("BEFORE registerSensor1: ")); printFM();
nodeManager.registerSensor(SENSOR_MQ, A1, 1);
Serial.print(F("BEFORE registerSensor2: ")); printFM();
nodeManager.registerSensor(SENSOR_MQ, A2, 2);
Serial.print(F("BEFORE registerSensor3: ")); printFM();
nodeManager.registerSensor(SENSOR_MQ, A3, 3);
Serial.print(F("BEFORE reg.Sens. MHZ19: ")); printFM();
int co2 = nodeManager.registerSensor(SENSOR_MHZ19, 6, 4);
SensorMHZ19* co2Sensor = ((SensorMHZ19*)nodeManager.getSensor(co2));
co2Sensor->setRxTx(6, 7);
Serial.print(F("AFTER reg. sensors: "));printFM();
* Register above your sensors
// presentation
void presentation() {
// call NodeManager presentation routine
// setup
void setup() {
// call NodeManager setup routine
// loop
void loop() {
// call NodeManager loop routine
// receive
void receive(const MyMessage &message) {
// call NodeManager receive routine
// receiveTime
void receiveTime(unsigned long ts) {
// call NodeManager receiveTime routine
This directory is intended for the project specific (private) libraries.
PlatformIO will compile them to static libraries and link to executable file.
The source code of each library should be placed in separate directory, like
"lib/private_lib/[here are source files]".
For example, see how can be organized `Foo` and `Bar` libraries:
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |- readme.txt --> THIS FILE
|- platformio.ini
|- main.c
Then in `src/main.c` you should use:
#include <Foo.h>
#include <Bar.h>
// rest H/C/CPP code
PlatformIO will find your libraries automatically, configure preprocessor's
include paths and build them.
More information about PlatformIO Library Dependency Finder
; PlatformIO Project Configuration File
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
; Please visit documentation for the other options and examples
src_dir = .
platform = atmelavr
board = nanoatmega328
framework = arduino
lib_deps = MySensors
upload_port = /dev/ttyUSB1
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment