diff --git a/.gitignore b/.gitignore index 126fc83fa4e6c16c24e50bddb945d2b9a20a1dce..918d2c77f9dab9df203a4f5fb4c3f3fdc2405fd7 100755 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,7 @@ *~ *.tmp *.part +.pioenvs +.piolibdeps +.clang_complete +.gcc-flags.json diff --git a/NodeManager_GasSensor.ino b/NodeManager_GasSensor.ino new file mode 100644 index 0000000000000000000000000000000000000000..1301d1f6de4a0ed427be3879863625b44127c017 --- /dev/null +++ b/NodeManager_GasSensor.ino @@ -0,0 +1,91 @@ +/* +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: https://github.com/mysensors/NodeManager + */ + + +// load user settings +#include "config.h" +// include supporting libraries +#ifdef MY_GATEWAY_ESP8266 + #include <ESP8266WiFi.h> +#endif +// 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 + Serial.println(F("BEFORE")); + printFM(); + Serial.begin(MY_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 + */ + nodeManager.before(); +} + +// presentation +void presentation() { + // call NodeManager presentation routine + nodeManager.presentation(); +} + +// setup +void setup() { + // call NodeManager setup routine + nodeManager.setup(); +} + +// loop +void loop() { + // call NodeManager loop routine + nodeManager.loop(); + +} + +// receive +void receive(const MyMessage &message) { + // call NodeManager receive routine + nodeManager.receive(message); +} + +// receiveTime +void receiveTime(unsigned long ts) { + // call NodeManager receiveTime routine + nodeManager.receiveTime(ts); +} + + diff --git a/lib/readme.txt b/lib/readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..dbadc3d6300dc26014ef1a9704190db470289c3d --- /dev/null +++ b/lib/readme.txt @@ -0,0 +1,36 @@ + +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: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- 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 +- http://docs.platformio.org/page/librarymanager/ldf.html diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..3c97f47be6179f4ab77cd8ae3e1d22d14cebc229 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,19 @@ +; 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 +; http://docs.platformio.org/page/projectconf.html + +[platformio] +src_dir = . + +[env:nanoatmega328] +platform = atmelavr +board = nanoatmega328 +framework = arduino +lib_deps = MySensors +upload_port = /dev/ttyUSB1