Initial Commit.
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="io.sloeber.core.toolChain.release.1354458730">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="io.sloeber.core.toolChain.release.1354458730" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildProperties="" description="" id="io.sloeber.core.toolChain.release.1354458730" name="Release" parent="org.eclipse.cdt.build.core.emptycfg">
|
||||
<folderInfo id="io.sloeber.core.toolChain.release.1354458730.530506174" name="/" resourcePath="">
|
||||
<toolChain id="io.sloeber.core.toolChain.release.455336398" name="Arduino Toolchain (Sloeber edition)" superClass="io.sloeber.core.toolChain.release">
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="io.sloeber.targetplatform.429246207" name="Arduino Target" osList="all" superClass="io.sloeber.targetplatform"/>
|
||||
<builder buildPath="${workspace_loc:/MyOutdoorSensor01}/Release" id="io.sloeber.sketch.builder.1514630368" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Arduino sketch builder" superClass="io.sloeber.sketch.builder"/>
|
||||
<tool id="io.sloeber.tool.sketch.compiler.cpp.74689443" name="Arduino C++ Compiler" superClass="io.sloeber.tool.sketch.compiler.cpp">
|
||||
<option id="io.sloeber.compiler.cpp.sketch.option.incpath.133861677" name="Include Paths (-I)" superClass="io.sloeber.compiler.cpp.sketch.option.incpath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/core/core}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/core/variant}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/RF24}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/SPI}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/SPI/src}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/Adafruit_Unified_Sensor}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/DHT_sensor_library}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/MySensors}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/MyNodeManager}""/>
|
||||
</option>
|
||||
<inputType id="io.sloeber.compiler.cpp.sketch.input.1276132195" name="CPP source files" superClass="io.sloeber.compiler.cpp.sketch.input"/>
|
||||
</tool>
|
||||
<tool id="io.sloeber.tool.compiler.c.494587259" name="Arduino C Compiler" superClass="io.sloeber.tool.compiler.c">
|
||||
<option id="io.sloeber.compiler.c.sketch.option.incpath.34861341" name="Include Paths (-I)" superClass="io.sloeber.compiler.c.sketch.option.incpath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/core/core}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/core/variant}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/RF24}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/SPI}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/SPI/src}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/Adafruit_Unified_Sensor}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/DHT_sensor_library}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/MySensors}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/MyNodeManager}""/>
|
||||
</option>
|
||||
<inputType id="io.sloeber.compiler.c.sketch.input.598585182" name="C Source Files" superClass="io.sloeber.compiler.c.sketch.input"/>
|
||||
</tool>
|
||||
<tool id="io.sloeber.tool.sketch.compiler.s.165286284" name="Arduino Assembler" superClass="io.sloeber.tool.sketch.compiler.s">
|
||||
<option id="io.sloeber.compiler.asm.sketch.option.incpath.957826874" name="Include Paths (-I)" superClass="io.sloeber.compiler.asm.sketch.option.incpath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/core/core}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/core/variant}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/RF24}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/SPI}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/SPI/src}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/Adafruit_Unified_Sensor}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/DHT_sensor_library}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/MySensors}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyOutdoorSensor01/libraries/MyNodeManager}""/>
|
||||
</option>
|
||||
<inputType id="io.sloeber.compiler.S.sketch.input.587456553" name="Assembly source files" superClass="io.sloeber.compiler.S.sketch.input"/>
|
||||
</tool>
|
||||
<tool id="io.sloeber.tool.ar.2108334586" name="Arduino archiver" superClass="io.sloeber.tool.ar"/>
|
||||
<tool id="io.sloeber.tool.combine.2108510122" name="Arduino combiner" superClass="io.sloeber.tool.combine"/>
|
||||
<tool id="io.sloeber.tool.objcopy.eep.918254546" name="Arduino tool Create eeprom" superClass="io.sloeber.tool.objcopy.eep"/>
|
||||
<tool id="io.sloeber.tool.size.269296505" name="Arduino tool Print Size" superClass="io.sloeber.tool.size"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="libraries/MySensors/projects|libraries/MySensors/initscripts|libraries/MySensors/hal|libraries/MySensors/examples_linux|libraries/MySensors/drivers|libraries/MySensors/Documentation|libraries/MySensors/core|libraries/MySensors/.mystools|libraries/MySensors/.ci|libraries/?*/**/?xamples/**|libraries/?*/**/?xtras/**|libraries/?*/**/test*/**|libraries/?*/**/third-party/**|libraries**/._*|libraries/?*/c*/?*|libraries/?*/d*/?*|libraries/?*/D*/?*" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="MyOutdoorSensor01.null.1423474161" name="MyOutdoorSensor01"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
</cproject>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>MyOutdoorSensor01</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>io.sloeber.core.inoToCpp</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
<nature>io.sloeber.arduinonature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>core/core</name>
|
||||
<type>2</type>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.18/cores/arduino</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>core/variant</name>
|
||||
<type>2</type>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.18/variants/eightanaloginputs</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>libraries/Adafruit_Unified_Sensor</name>
|
||||
<type>2</type>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/libraries/Adafruit_Unified_Sensor/1.0.2</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>libraries/DHT_sensor_library</name>
|
||||
<type>2</type>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/libraries/DHT_sensor_library/1.3.0</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>libraries/MyNodeManager</name>
|
||||
<type>2</type>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/libraries/MyNodeManager/1.0.0</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>libraries/MySensors</name>
|
||||
<type>2</type>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/libraries/MySensors/2.2.0</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>libraries/RF24</name>
|
||||
<type>2</type>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/libraries/RF24/1.2.0</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>libraries/SPI</name>
|
||||
<type>2</type>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.18/libraries/SPI</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,124 @@
|
||||
|
||||
#include <nodemanager_config.h>
|
||||
#include <MySensors.h>
|
||||
#include <NodeManager.h>
|
||||
|
||||
|
||||
#define SENSOR_CHECK_INTERVAL 2000
|
||||
#define MSG_SEND_CYCLES 0
|
||||
|
||||
#define PIN_DHT 4
|
||||
#define PIN_LDR A0
|
||||
#define PIN_BAT A1
|
||||
#define PIN_MOSFET 8
|
||||
|
||||
#define SENSOR_ID_DHT_TEMP 0
|
||||
#define SENSOR_ID_DHT_HUM 1
|
||||
#define SENSOR_ID_LDR 2
|
||||
#define SENSOR_ID_VCC 210
|
||||
|
||||
|
||||
// For convenience
|
||||
typedef SensorDHT<DHT22, PIN_DHT, SENSOR_ID_DHT_TEMP, SENSOR_ID_DHT_HUM, SENSOR_CHECK_INTERVAL, MSG_SEND_CYCLES> MySensorDHT;
|
||||
|
||||
|
||||
// create a NodeManager instance
|
||||
typedef NodeManager<
|
||||
Tuple<
|
||||
MySensorDHT,
|
||||
SensorLDR<PIN_LDR, SENSOR_ID_LDR, SENSOR_CHECK_INTERVAL, MSG_SEND_CYCLES>,
|
||||
SensorVcc<SENSOR_ID_VCC, SENSOR_CHECK_INTERVAL, MSG_SEND_CYCLES>
|
||||
>
|
||||
> MyNodeManagerBase;
|
||||
|
||||
class MyNodeManager : public MyNodeManagerBase {
|
||||
protected:
|
||||
virtual void _power_on_before() override {
|
||||
if (pin_backup_valid) {
|
||||
// Restore pin state
|
||||
DDRB = ddrb_backup;
|
||||
PORTB = portb_backup;
|
||||
DDRC = ddrc_backup;
|
||||
PORTC = portc_backup;
|
||||
DDRD = ddrd_backup;
|
||||
PORTD = portd_backup;
|
||||
}
|
||||
}
|
||||
virtual void _power_on_after() override {
|
||||
// Enable NRF24
|
||||
power_spi_enable();
|
||||
transportInit();
|
||||
}
|
||||
virtual void _power_off_after() override {
|
||||
power_spi_disable();
|
||||
// Set all pins as INPUTS and disable pull-ups to avoid current leakage
|
||||
ddrb_backup = DDRB;
|
||||
portb_backup = PORTB;
|
||||
DDRB = 0x00;
|
||||
PORTB = 0x00;
|
||||
ddrc_backup = DDRC;
|
||||
portc_backup = PORTC;
|
||||
DDRC = 0x00;
|
||||
PORTC = 0x00;
|
||||
ddrd_backup = DDRD;
|
||||
portd_backup = PORTD;
|
||||
DDRD = 0x00;
|
||||
PORTD = 0x00;
|
||||
pin_backup_valid = true;
|
||||
}
|
||||
virtual void _sleep_before() override {
|
||||
powerOff();
|
||||
}
|
||||
virtual void _sleep_after() override {
|
||||
powerOn();
|
||||
wdt_enable(WDTO_2S);
|
||||
WDTCSR &= ~_BV(WDIE); /* Disable the WD interrupt. */
|
||||
}
|
||||
|
||||
uint8_t ddrb_backup, ddrc_backup, ddrd_backup;
|
||||
uint8_t portb_backup, portc_backup, portd_backup;
|
||||
bool pin_backup_valid = false;
|
||||
} nodeManager;
|
||||
|
||||
|
||||
void before() {
|
||||
nodeManager.setSleep(POWER_DOWN_WDT, 5, MINUTES);
|
||||
nodeManager.setPowerPins(PIN_MOSFET, -1, 0);
|
||||
nodeManager.setAutoPowerPins(false);
|
||||
nodeManager.setBatteryInternalVcc(false);
|
||||
nodeManager.setBatteryPin(PIN_BAT);
|
||||
nodeManager.setBatteryVoltsPerBit(5.0 / 1023.0);
|
||||
nodeManager.setBatteryReportCycles(0);
|
||||
nodeManager.setBatteryMax(4.1);
|
||||
nodeManager.setBatteryMin(3.4);
|
||||
nodeManager.before();
|
||||
}
|
||||
|
||||
|
||||
void presentation() {
|
||||
nodeManager.presentation();
|
||||
}
|
||||
|
||||
|
||||
void receive(const MyMessage &message) {
|
||||
nodeManager.receive(message);
|
||||
}
|
||||
|
||||
|
||||
void receiveTime(unsigned long ts) {
|
||||
nodeManager.receiveTime(ts);
|
||||
}
|
||||
|
||||
|
||||
void setup() {
|
||||
ACSR &= (1<<7); // Disable the AC
|
||||
DIDR0 = 0xFF; // We don't use need digital input from the analog pins, so disable the digital input buffer
|
||||
//DIDR1 = 0x3; // The same for the AC pins?
|
||||
nodeManager.setup();
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
nodeManager.loop();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#ifndef config_h
|
||||
#define config_h
|
||||
|
||||
/**********************************
|
||||
* Sketch configuration
|
||||
*/
|
||||
|
||||
#define SKETCH_NAME "Outdoor01"
|
||||
#define SKETCH_VERSION "1.0"
|
||||
|
||||
/**********************************
|
||||
* MySensors node configuration
|
||||
*/
|
||||
|
||||
#define MY_NODE_ID 2
|
||||
|
||||
#define MY_MSG_ACK 1
|
||||
#define MY_MSG_RETRIES 3
|
||||
#define MY_MSG_RETRY_DELAY 1
|
||||
|
||||
|
||||
// Enable debug prints to serial monitor
|
||||
//#define MY_DEBUG
|
||||
//#define MY_DEBUG_VERBOSE_RF24
|
||||
//#define MY_SPECIAL_DEBUG
|
||||
#define MY_SPLASH_SCREEN_DISABLED
|
||||
|
||||
|
||||
// Enable and select radio type attached
|
||||
#define MY_RADIO_NRF24
|
||||
|
||||
#define MY_RF24_PA_LEVEL RF24_PA_MAX
|
||||
#define MY_RF24_DATARATE RF24_250KBPS
|
||||
#define MY_RF24_CHANNEL 82
|
||||
#define MY_RF24_BASE_RADIO_ID 0x00,0x30,0x08,0x19,0x82
|
||||
#define MY_RF24_ENABLE_XTEA
|
||||
#define MY_RF24_XTEA_KEY { 0xF0, 0xE1, 0xD2, 0xC3, 0xB4, 0xA5, 0x96, 0x87, 0x78, 0x69, 0x5A, 0x4B, 0x3C, 0x2D, 0x1E, 0x0F }
|
||||
#define MY_MESSAGE_ENABLE_NONCE
|
||||
#define MY_MESSAGE_ENABLE_HASH
|
||||
#define MY_SMART_SLEEP_WAIT_DURATION_MS 60
|
||||
|
||||
#define MY_RF24_CE_PIN 9
|
||||
#define MY_RF24_CS_PIN 10
|
||||
|
||||
|
||||
/***********************************
|
||||
* NodeManager configuration
|
||||
*/
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
// if enabled, enable the capability to power on sensors with the arduino's pins to save battery while sleeping
|
||||
#define POWER_MANAGER 1
|
||||
// if enabled, will load the battery manager library to allow the battery level to be reported automatically or on demand
|
||||
#define BATTERY_MANAGER 1
|
||||
// if enabled, allow modifying the configuration remotely by interacting with the configuration child id
|
||||
#define REMOTE_CONFIGURATION 1
|
||||
// if enabled, persist the remote configuration settings on EEPROM
|
||||
#define PERSIST 1
|
||||
// if enabled, a battery sensor will be created at BATTERY_CHILD_ID and will report vcc voltage together with the battery level percentage
|
||||
#define BATTERY_SENSOR 1
|
||||
// if enabled, send a SLEEPING and AWAKE service messages just before entering and just after leaving a sleep cycle and STARTED when starting/rebooting
|
||||
#define SERVICE_MESSAGES 0
|
||||
|
||||
#define NODE_SMART_SLEEP_ENABLE
|
||||
|
||||
#define MODULE_DHT 1
|
||||
|
||||
#define ENABLE_SLEEP_HOOKS
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user