From eacaaab9dc9c626b6c7e806bbc482c65fc41bae7 Mon Sep 17 00:00:00 2001 From: user2684 <user2684@users.noreply.github.com> Date: Sat, 15 Jul 2017 16:21:15 +0200 Subject: [PATCH] Added support for RS485 (#169) --- NodeManager.cpp | 4 ++-- NodeManager.h | 33 +++++++++++++++++++-------------- NodeManager.ino | 2 +- config.h | 10 ++++++++-- 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/NodeManager.cpp b/NodeManager.cpp index 03a891a..5a02a55 100755 --- a/NodeManager.cpp +++ b/NodeManager.cpp @@ -2713,7 +2713,7 @@ void SensorTSL2561::onProcess(Request & request) { /* SensorPT100 */ - +#if MODULE_PT100 == 1 // contructor SensorPT100::SensorPT100(NodeManager* node_manager, int child_id, int pin): Sensor(node_manager, child_id, pin) { // set presentation, type and value type @@ -2767,7 +2767,7 @@ void SensorPT100::onProcess(Request & request) { } _send(_msg_service.set(function)); } - +#endif /******************************************* NodeManager diff --git a/NodeManager.h b/NodeManager.h index 58c4c44..2f7b9db 100755 --- a/NodeManager.h +++ b/NodeManager.h @@ -111,7 +111,7 @@ Default module settings */ -// Enable this module to use one of the following sensors: SENSOR_ANALOG_INPUT, SENSOR_LDR, SENSOR_THERMISTOR, SENSOR_ACS712, SENSOR_PT100 +// Enable this module to use one of the following sensors: SENSOR_ANALOG_INPUT, SENSOR_LDR, SENSOR_THERMISTOR, SENSOR_ML8511, SENSOR_ACS712, SENSOR_RAIN_GAUGE, SENSOR_RAIN, SENSOR_SOIL_MOISTURE #ifndef MODULE_ANALOG_INPUT #define MODULE_ANALOG_INPUT 0 #endif @@ -123,18 +123,14 @@ #ifndef MODULE_DIGITAL_OUTPUT #define MODULE_DIGITAL_OUTPUT 0 #endif -// Enable this module to use one of the following sensors: SENSOR_SHT21, SENSOR_HTU21D -#ifndef MODULE_SHT21 - #define MODULE_SHT21 0 -#endif -// Enable this module to use one of the following sensors: SENSOR_AM2320 -#ifndef MODULE_AM2320 - #define MODULE_AM2320 0 -#endif // Enable this module to use one of the following sensors: SENSOR_DHT11, SENSOR_DHT22, SENSOR_DHT21 #ifndef MODULE_DHT #define MODULE_DHT 0 #endif +// Enable this module to use one of the following sensors: SENSOR_SHT21, SENSOR_HTU21D +#ifndef MODULE_SHT21 + #define MODULE_SHT21 0 +#endif // Enable this module to use one of the following sensors: SENSOR_SWITCH, SENSOR_DOOR, SENSOR_MOTION #ifndef MODULE_SWITCH #define MODULE_SWITCH 0 @@ -147,10 +143,6 @@ #ifndef MODULE_BH1750 #define MODULE_BH1750 0 #endif -// Enable this module to use one of the following sensors: SENSOR_TSL2561 -#ifndef MODULE_TSL2561 - #define MODULE_TSL2561 0 -#endif // Enable this module to use one of the following sensors: SENSOR_MLX90614 #ifndef MODULE_MLX90614 #define MODULE_MLX90614 0 @@ -183,6 +175,18 @@ #ifndef MODULE_MHZ19 #define MODULE_MHZ19 0 #endif +// Enable this module to use one of the following sensors: SENSOR_AM2320 +#ifndef MODULE_AM2320 + #define MODULE_AM2320 0 +#endif +// Enable this module to use one of the following sensors: SENSOR_TSL2561 +#ifndef MODULE_TSL2561 + #define MODULE_TSL2561 0 +#endif +// Enable this module to use one of the following sensors: SENSOR_PT100 +#ifndef MODULE_PT100 + #define SENSOR_PT100 0 +#endif /*********************************** Supported Sensors @@ -1276,7 +1280,7 @@ class SensorTSL2561: public Sensor { /* SensorPT100 */ - +#if MODULE_PT100 == 1 class SensorPT100: public Sensor { public: SensorPT100(NodeManager* node_manager, int child_id, int pin); @@ -1292,6 +1296,7 @@ class SensorPT100: public Sensor { DFRobotHighTemperature* _PT100; float _voltageRef = 3.3; }; +#endif /*************************************** NodeManager: manages all the aspects of the node diff --git a/NodeManager.ino b/NodeManager.ino index f2296b5..657bfaf 100755 --- a/NodeManager.ino +++ b/NodeManager.ino @@ -30,7 +30,7 @@ void before() { Serial.begin(MY_BAUD_RATE); /* - * Register below your device specific config + * Register below your sensors */ diff --git a/config.h b/config.h index f3136dd..42d0447 100755 --- a/config.h +++ b/config.h @@ -18,9 +18,8 @@ //#define MY_NODE_ID 100 // NRF24 radio settings -//#define MY_RADIO_NRF24 +#define MY_RADIO_NRF24 //#define MY_RF24_ENABLE_ENCRYPTION - //#define MY_RF24_CHANNEL 76 //#define MY_RF24_PA_LEVEL RF24_PA_HIGH //#define MY_DEBUG_VERBOSE_RF24 @@ -38,6 +37,13 @@ //#define MY_RF69_IRQ_NUM MY_RF69_IRQ_PIN //#define MY_RF69_SPI_CS D2 +// RS485 serial transport settings +//#define MY_RS485 +//#define MY_RS485_BAUD_RATE 9600 +//#define MY_RS485_DE_PIN 2 +//#define MY_RS485_MAX_MESSAGE_LENGTH 40 +//#define MY_RS485_HWSERIAL Serial1 + /********************************** * MySensors gateway configuration */ -- GitLab