Initial Commit.

This commit is contained in:
2018-03-16 22:18:22 +01:00
commit aa19772d4f
4 changed files with 424 additions and 0 deletions
+106
View File
@@ -0,0 +1,106 @@
<?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.665016491">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="io.sloeber.core.toolChain.release.665016491" 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.665016491" name="Release" parent="org.eclipse.cdt.build.core.emptycfg">
<folderInfo id="io.sloeber.core.toolChain.release.665016491.473582763" name="/" resourcePath="">
<toolChain id="io.sloeber.core.toolChain.release.2092822723" name="Arduino Toolchain (Sloeber edition)" superClass="io.sloeber.core.toolChain.release">
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="io.sloeber.targetplatform.555948808" name="Arduino Target" osList="all" superClass="io.sloeber.targetplatform"/>
<builder buildPath="${workspace_loc:/MySmartHomeBase}/Release" id="io.sloeber.sketch.builder.1523803109" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Arduino sketch builder" superClass="io.sloeber.sketch.builder"/>
<tool id="io.sloeber.tool.sketch.compiler.cpp.1190644162" name="Arduino C++ Compiler" superClass="io.sloeber.tool.sketch.compiler.cpp">
<option id="io.sloeber.compiler.cpp.sketch.option.incpath.1996223427" name="Include Paths (-I)" superClass="io.sloeber.compiler.cpp.sketch.option.incpath" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/core/core}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/core/variant}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/MySensors}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/SPI}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/SPI/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Adafruit_Unified_Sensor}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/DHT_sensor_library}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Wire}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Wire/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Adafruit_BME280_Library}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Adafruit_BMP280_Library}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Adafruit_ADS1X15}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/EEPROM}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/EEPROM/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/MyNodeManager}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase}&quot;"/>
</option>
<inputType id="io.sloeber.compiler.cpp.sketch.input.702163962" name="CPP source files" superClass="io.sloeber.compiler.cpp.sketch.input"/>
</tool>
<tool id="io.sloeber.tool.compiler.c.1453993972" name="Arduino C Compiler" superClass="io.sloeber.tool.compiler.c">
<option id="io.sloeber.compiler.c.sketch.option.incpath.404780511" name="Include Paths (-I)" superClass="io.sloeber.compiler.c.sketch.option.incpath" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/core/core}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/core/variant}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/MySensors}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/SPI}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/SPI/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Adafruit_Unified_Sensor}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/DHT_sensor_library}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Wire}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Wire/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Adafruit_BME280_Library}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Adafruit_BMP280_Library}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Adafruit_ADS1X15}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/EEPROM}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/EEPROM/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/MyNodeManager}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase}&quot;"/>
</option>
<inputType id="io.sloeber.compiler.c.sketch.input.2039460578" name="C Source Files" superClass="io.sloeber.compiler.c.sketch.input"/>
</tool>
<tool id="io.sloeber.tool.sketch.compiler.s.869437862" name="Arduino Assembler" superClass="io.sloeber.tool.sketch.compiler.s">
<option id="io.sloeber.compiler.asm.sketch.option.incpath.647374840" name="Include Paths (-I)" superClass="io.sloeber.compiler.asm.sketch.option.incpath" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/core/core}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/core/variant}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/MySensors}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/SPI}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/SPI/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Adafruit_Unified_Sensor}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/DHT_sensor_library}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Wire}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Wire/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Adafruit_BME280_Library}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Adafruit_BMP280_Library}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/Adafruit_ADS1X15}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/EEPROM}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/EEPROM/src}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase/libraries/MyNodeManager}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MySmartHomeBase}&quot;"/>
</option>
<inputType id="io.sloeber.compiler.S.sketch.input.1783435425" name="Assembly source files" superClass="io.sloeber.compiler.S.sketch.input"/>
</tool>
<tool id="io.sloeber.tool.ar.1973553121" name="Arduino archiver" superClass="io.sloeber.tool.ar"/>
<tool id="io.sloeber.tool.combine.1705081208" name="Arduino combiner" superClass="io.sloeber.tool.combine"/>
<tool id="io.sloeber.tool.objcopy.eep.688165734" name="Arduino tool Create eeprom" superClass="io.sloeber.tool.objcopy.eep"/>
<tool id="io.sloeber.tool.size.1805878380" name="Arduino tool Print Size" superClass="io.sloeber.tool.size"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="libraries/?*/**/test*/**|libraries/MySensors/core|libraries**/._*|libraries/?*/**/?xamples/**|libraries/MySensors/initscripts|libraries/?*/**/?xtras/**|libraries/?*/d*/?*|libraries/MySensors/.mystools|libraries/MySensors/hal|libraries/MySensors/examples_linux|libraries/MySensors/.ci|libraries/?*/**/third-party/**|libraries/MySensors/projects|libraries/MySensors/Documentation|libraries/?*/c*/?*|libraries/MySensors/drivers|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="MySmartHomeBase.null.1845851626" name="MySmartHomeBase"/>
</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>
+95
View File
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MySmartHomeBase</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_ADS1X15</name>
<type>2</type>
<locationURI>ECLIPSE_HOME/arduinoPlugin/libraries/Adafruit_ADS1X15/1.0.0</locationURI>
</link>
<link>
<name>libraries/Adafruit_BME280_Library</name>
<type>2</type>
<locationURI>ECLIPSE_HOME/arduinoPlugin/libraries/Adafruit_BME280_Library/1.0.5</locationURI>
</link>
<link>
<name>libraries/Adafruit_BMP280_Library</name>
<type>2</type>
<locationURI>ECLIPSE_HOME/arduinoPlugin/libraries/Adafruit_BMP280_Library/1.0.2</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/EEPROM</name>
<type>2</type>
<locationURI>ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.18/libraries/EEPROM</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/SPI</name>
<type>2</type>
<locationURI>ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.18/libraries/SPI</locationURI>
</link>
<link>
<name>libraries/Wire</name>
<type>2</type>
<locationURI>ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.18/libraries/Wire</locationURI>
</link>
</linkedResources>
</projectDescription>
+149
View File
@@ -0,0 +1,149 @@
#include <nodemanager_config.h>
#include <MySensors.h>
#include <NodeManager.h>
#define SENSOR_CHECK_INTERVAL 4000
#define MSG_SEND_CYCLES 15
#define MSG_SEND_INTERVAL 60000
#define PIN_DHT 8
#define PIN_LDR A7
#define PIN_MOTION 2
#define PIN_DOOR0 7
#define PIN_DOOR1 6
#define PIN_DOOR2 5
#define PIN_DOOR3 4
#define PIN_BACKLIGHT A0
#define SENSOR_ID_DHT_TEMP 0
#define SENSOR_ID_DHT_HUM 1
#define SENSOR_ID_BMP_TEMP 2
#define SENSOR_ID_BMP_BARO 3
#define SENSOR_ID_LDR 4
#define SENSOR_ID_MQ 5
//#define SENSOR_ID_SOUND 6
#define SENSOR_ID_MOTION 7
#define SENSOR_ID_DOOR0 8
#define SENSOR_ID_DOOR1 9
#define SENSOR_ID_DOOR2 10
#define SENSOR_ID_DOOR3 11
#define SENSOR_ID_BACKLIGHT 100
#define SENSOR_ID_VCC 210
#define ADS_CHANNEL_MQ 0
#define ADS_CHANNEL_SOUND 1
#define I2C_ADDR_ADS 0x48
#define I2C_ADDR_BMP 0x76
#define DIN_DEBOUNCE 6
#define MQ_RL 1000
#define MQ_EEPROM_BASE 0
// We need to subclass here to enable temperature/humidity compensation
template<
uint8_t _tchannel,
uint8_t _tsensorId,
unsigned _trl = 1000,
unsigned _teepromBase = 0,
unsigned long _checkInterval = 2000,
unsigned long _msgSendTimeout = 30
> class CustomADS1115ChannelMQ135Module : public ADS1115ChannelMQ135Module<_tchannel, _tsensorId, _trl, _teepromBase, _checkInterval, _msgSendTimeout> {
public:
virtual bool getTempAndHum(float& temp, float& hum) override;
};
// For convenience
typedef SensorDHT<DHT22, PIN_DHT, SENSOR_ID_DHT_TEMP, SENSOR_ID_DHT_HUM, SENSOR_CHECK_INTERVAL, MSG_SEND_CYCLES> MySensorDHT;
typedef SensorADS1115<
Tuple<
CustomADS1115ChannelMQ135Module<ADS_CHANNEL_MQ, SENSOR_ID_MQ, MQ_RL, MQ_EEPROM_BASE, SENSOR_CHECK_INTERVAL, MSG_SEND_CYCLES>
>, I2C_ADDR_ADS
> MySensorADS1115;
// create a NodeManager instance
typedef NodeManager<
Tuple<
MySensorDHT,
SensorBMP280<I2C_ADDR_BMP, SENSOR_ID_BMP_TEMP, SENSOR_ID_BMP_BARO, SENSOR_CHECK_INTERVAL, MSG_SEND_CYCLES>,
SensorLDR<PIN_LDR, SENSOR_ID_LDR, SENSOR_CHECK_INTERVAL, MSG_SEND_CYCLES>,
MySensorADS1115,
SensorMotion<PIN_MOTION, SENSOR_ID_MOTION, INPUT_PULLUP, DIN_DEBOUNCE, MSG_SEND_INTERVAL>,
SensorDoor<PIN_DOOR0, SENSOR_ID_DOOR0, INPUT_PULLUP, DIN_DEBOUNCE, MSG_SEND_INTERVAL>,
SensorDoor<PIN_DOOR1, SENSOR_ID_DOOR1, INPUT_PULLUP, DIN_DEBOUNCE, MSG_SEND_INTERVAL>,
SensorDoor<PIN_DOOR2, SENSOR_ID_DOOR2, INPUT_PULLUP, DIN_DEBOUNCE, MSG_SEND_INTERVAL>,
SensorDoor<PIN_DOOR3, SENSOR_ID_DOOR3, INPUT_PULLUP, DIN_DEBOUNCE, MSG_SEND_INTERVAL>,
SwitchBacklight<PIN_BACKLIGHT, SENSOR_ID_BACKLIGHT, MSG_SEND_INTERVAL>,
SensorVcc<SENSOR_ID_VCC, SENSOR_CHECK_INTERVAL, MSG_SEND_CYCLES>
>
> MyNodeManagerBase;
class MyNodeManager : public MyNodeManagerBase {
protected:
virtual void processCommand(const char * message) override {
if (strcmp_P(message, PSTR("MQ_CAL")) == 0) {
getSensor<3, MySensorADS1115>().calibrateSubmodule<0>();
} else {
MyNodeManagerBase::processCommand(message);
}
}
} nodeManager;
template<
uint8_t _tchannel,
uint8_t _tsensorId,
unsigned _trl,
unsigned _teepromBase,
unsigned long _checkInterval,
unsigned long _msgSendTimeout
> bool CustomADS1115ChannelMQ135Module<_tchannel, _tsensorId, _trl, _teepromBase, _checkInterval, _msgSendTimeout>::getTempAndHum(float& temp, float& hum) {
auto& dht = nodeManager.getSensor<0, MySensorDHT>();
temp = dht.getTemperature();
hum = dht.getHumidity();
return true;
}
void before() {
//nodeManager.setSleep(ALWAYS_ON, 2, SECONDS);
nodeManager.before();
}
void setup() {
nodeManager.setup();
}
void presentation() {
nodeManager.presentation();
}
void receive(const MyMessage &message) {
nodeManager.receive(message);
}
void receiveTime(unsigned long ts) {
nodeManager.receiveTime(ts);
}
void loop() {
nodeManager.loop();
}
+74
View File
@@ -0,0 +1,74 @@
#ifndef config_h
#define config_h
/**********************************
* Sketch configuration
*/
#define SKETCH_NAME "Gateway"
#define SKETCH_VERSION "1.1"
/**********************************
* MySensors node configuration
*/
#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
// Enable serial gateway
#define MY_GATEWAY_SERIAL
#define MY_BAUD_RATE 115200
/***********************************
* 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 0
// if enabled, will load the battery manager library to allow the battery level to be reported automatically or on demand
#define BATTERY_MANAGER 0
// if enabled, allow modifying the configuration remotely by interacting with the configuration child id
#define REMOTE_CONFIGURATION 0
// if enabled, persist the remote configuration settings on EEPROM
#define PERSIST 0
// 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 0
// 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 MODULE_BMP280 1
#define MODULE_DHT 1
#define MODULE_ADS1115 1
#define DISABLE_SLEEP_MODE
#endif