Added new (optional) arguments to begin where you can set PA level and radio channel in sketches and gateway. Default values for constructor and begin arguments also made it possible to simplify all sketches when using defualt ce/cs pins (9,10) for radio and AUTO radion Id mode.
This commit is contained in:
@@ -80,30 +80,28 @@ byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // DEAD BEEF FEED
|
||||
// a R/W server on the port
|
||||
EthernetServer server = EthernetServer(IP_PORT);
|
||||
|
||||
// No blink or button functionality. Use the vanilla constructor.
|
||||
Gateway gw(RADIO_CE_PIN, RADIO_SPI_SS_PIN, INCLUSION_MODE_TIME);
|
||||
|
||||
// Uncomment this constructor if you have leds and include button attached to your gateway
|
||||
//Gateway gw(RADIO_CE_PIN, RADIO_SPI_SS_PIN, INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
|
||||
//Gateway gw(RADIO_CE_PIN, RADIO_SPI_SS_PIN, INCLUSION_MODE_TIME, INCLUSION_MODE_PIN, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
|
||||
|
||||
// Constructor for NON blinking gateway
|
||||
Gateway gw(RADIO_CE_PIN, RADIO_SPI_SS_PIN, INCLUSION_MODE_TIME);
|
||||
|
||||
char inputString[MAX_RECEIVE_LENGTH] = ""; // A string to hold incoming commands from serial/ethernet interface
|
||||
int inputPos = 0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
gw.begin(GATEWAY_ADDRESS, writeEthernet);
|
||||
// Initialize gateway at maximum PA level, channel 70 and callback for write operations
|
||||
gw.begin(RF24_PA_MAX, 70, writeEthernet);
|
||||
|
||||
Ethernet.begin(mac, myIp);
|
||||
|
||||
|
||||
// give the Ethernet interface a second to initialize
|
||||
delay(1000);
|
||||
|
||||
// start listening for clients
|
||||
server.begin();
|
||||
|
||||
|
||||
// C++ classes and interrupts really sucks. Need to attach interrupt
|
||||
// outside thw Gateway class due to language shortcomings! Gah!
|
||||
|
||||
@@ -33,11 +33,13 @@
|
||||
#define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
|
||||
#define INCLUSION_MODE_PIN 3 // Digital pin used for inclusion mode button
|
||||
|
||||
// Start gateway with include button and led blinking functionality enabled (see documetation)
|
||||
//Gateway gw(9, 10, INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, 6, 5, 4);
|
||||
|
||||
// If blink and include mode button not is used uncomment and use below constructor instead
|
||||
Gateway gw(9, 10, INCLUSION_MODE_TIME);
|
||||
// No blink or button functionality. Use the vanilla constructor.
|
||||
Gateway gw;
|
||||
|
||||
// To start gateway with include button and led blinking functionality enabled use this instead!
|
||||
//Gateway gw(9, 10, INCLUSION_MODE_TIME, INCLUSION_MODE_PIN, 6, 5, 4);
|
||||
|
||||
|
||||
char inputString[MAX_RECEIVE_LENGTH] = ""; // A string to hold incoming commands from serial/ethernet interface
|
||||
int inputPos = 0;
|
||||
@@ -46,7 +48,7 @@ boolean commandComplete = false; // whether the string is complete
|
||||
void setup()
|
||||
{
|
||||
gw.begin();
|
||||
gw.setPALevel(RF24_PA_LOW); //Adjust PA-level: MIN, LOW, HIGH, MAX (MAX can sometimes cause problems when using amplified NRF24L01)
|
||||
gw.setPALevel(RF24_PA_LOW); //Adjust PA-level: MIN, LOW, HIGH, MAX (MAX can sometimes cause problems when using amplified NRF24L01)
|
||||
|
||||
// C++ classes and interrupts really sucks. Need to attach interrupt
|
||||
// outside thw Gateway class due to language shortcomings! Gah!
|
||||
@@ -67,6 +69,7 @@ void loop()
|
||||
|
||||
}
|
||||
|
||||
|
||||
void startInclusionInterrupt() {
|
||||
gw.startInclusionInterrupt();
|
||||
}
|
||||
|
||||
@@ -17,17 +17,18 @@ Gateway::Gateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion_time) : Rela
|
||||
inclusionTime = _inclusion_time;
|
||||
}
|
||||
|
||||
Gateway::Gateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion, uint8_t _inclusion_time, uint8_t _rx, uint8_t _tx, uint8_t _er) : Relay(_cepin, _cspin) {
|
||||
Gateway::Gateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion_time, uint8_t _inclusion_pin, uint8_t _rx, uint8_t _tx, uint8_t _er) : Relay(_cepin, _cspin) {
|
||||
ledMode = true;
|
||||
isRelay = true;
|
||||
pinInclusion = _inclusion;
|
||||
pinInclusion = _inclusion_pin;
|
||||
inclusionTime = _inclusion_time;
|
||||
pinRx = _rx;
|
||||
pinTx = _tx;
|
||||
pinEr = _er;
|
||||
}
|
||||
|
||||
void Gateway::begin(uint8_t _radioId, void (*inDataCallback)(char *)) {
|
||||
void Gateway::begin(rf24_pa_dbm_e paLevel, uint8_t channel, void (*inDataCallback)(char *)) {
|
||||
Serial.begin(BAUD_RATE);
|
||||
|
||||
if (inDataCallback != NULL) {
|
||||
useWriteCallback = true;
|
||||
@@ -64,11 +65,8 @@ void Gateway::begin(uint8_t _radioId, void (*inDataCallback)(char *)) {
|
||||
|
||||
}
|
||||
|
||||
// Set baudrate of serial link
|
||||
Serial.begin(BAUD_RATE);
|
||||
|
||||
// Start up the radio library
|
||||
setupRadio();
|
||||
setupRadio(paLevel, channel);
|
||||
RF24::openReadingPipe(CURRENT_NODE_PIPE, BASE_RADIO_ID);
|
||||
RF24::startListening();
|
||||
|
||||
@@ -103,7 +101,7 @@ void Gateway::checkButtonTriggeredInclusion() {
|
||||
}
|
||||
|
||||
void Gateway::checkInclusionFinished() {
|
||||
if (inclusionMode && millis()-inclusionStartTime>60000L*inclusionTime) {
|
||||
if (inclusionMode && millis()-inclusionStartTime>60000UL*inclusionTime) {
|
||||
// inclusionTimeInMinutes minute(s) has passed.. stop inclusion mode
|
||||
setInclusionMode(false);
|
||||
}
|
||||
@@ -111,13 +109,13 @@ void Gateway::checkInclusionFinished() {
|
||||
|
||||
|
||||
void Gateway::parseAndSend(char *commandBuffer) {
|
||||
boolean ok;
|
||||
char *str, *p, *value;
|
||||
boolean ok = false;
|
||||
char *str, *p, *value=NULL;
|
||||
int i = 0;
|
||||
uint16_t sensorRadioId;
|
||||
uint8_t childId;
|
||||
uint8_t messageType;
|
||||
uint8_t type;
|
||||
uint16_t sensorRadioId = 0;
|
||||
uint8_t childId = 0;
|
||||
uint8_t messageType = 0;
|
||||
uint8_t type = 0;
|
||||
|
||||
// Extract command data coming on serial line
|
||||
for (str = strtok_r(commandBuffer, ";", &p); // split using semicolon
|
||||
|
||||
@@ -27,20 +27,20 @@ class Gateway : public Relay
|
||||
* If you don't use status leds and/or inclusion mode button on your arduino gateway
|
||||
* you can disable this functionality by calling the 2 argument constructor.
|
||||
*
|
||||
* @param _cepin The pin attached to RF24 Chip Enable on the RF module
|
||||
* @param _cspin The pin attached to RF24 Chip Select
|
||||
* @param _inclusion Digital pin that triggers inclusion mode
|
||||
* @param _inclusion_time Time of inclusion mode (in minutes)
|
||||
* @param _cepin The pin attached to RF24 Chip Enable on the RF module (default 9)
|
||||
* @param _cspin The pin attached to RF24 Chip Select (defualt 10)
|
||||
* @param _inclusion_time Time of inclusion mode (in minutes, default 1)
|
||||
* @param _inclusion_pin Digital pin that triggers inclusion mode
|
||||
* @param _rx Digital pin for receive led
|
||||
* @param _tx Digital pin for transfer led
|
||||
* @param _er Digital pin for error led
|
||||
*
|
||||
*/
|
||||
Gateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion_time);
|
||||
Gateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion, uint8_t _inclusion_time, uint8_t _rx, uint8_t _tx, uint8_t _er);
|
||||
Gateway(uint8_t _cepin=9, uint8_t _cspin=10, uint8_t _inclusion_time = 1);
|
||||
Gateway(uint8_t _cepin, uint8_t _cspin, uint8_t _inclusion_time, uint8_t _inclusion_pin, uint8_t _rx, uint8_t _tx, uint8_t _er);
|
||||
|
||||
/* Use this and pass a function that should be called when you want to process commands that arrive from radio network */
|
||||
void begin(uint8_t _radioId=AUTO, void (*dataCallback)(char *)=NULL);
|
||||
void begin(rf24_pa_dbm_e paLevel=RF24_PA_MAX, uint8_t channel=70, void (*dataCallback)(char *)=NULL);
|
||||
|
||||
void processRadioMessage();
|
||||
void parseAndSend(char *inputString);
|
||||
|
||||
@@ -16,8 +16,8 @@ Relay::Relay(uint8_t _cepin, uint8_t _cspin) : Sensor(_cepin, _cspin) {
|
||||
}
|
||||
|
||||
|
||||
void Relay::begin(uint8_t _radioId) {
|
||||
Sensor::begin(_radioId);
|
||||
void Relay::begin(uint8_t radioId, rf24_pa_dbm_e paLevel, uint8_t channel) {
|
||||
Sensor::begin(radioId, paLevel, channel);
|
||||
// Read routing table from EEPROM
|
||||
for (unsigned int i=0;i<sizeof(childNodeTable);i++) {
|
||||
childNodeTable[i] = EEPROM.read(EEPROM_ROUTES_ADDRESS+i);
|
||||
|
||||
@@ -34,12 +34,12 @@ class Relay : public Sensor
|
||||
*
|
||||
* Creates a new instance of Relay class.
|
||||
*
|
||||
* @param _cepin The pin attached to RF24 Chip Enable on the RF module
|
||||
* @param _cspin The pin attached to RF24 Chip Select
|
||||
* @param _cepin The pin attached to RF24 Chip Enable on the RF module (default 9)
|
||||
* @param _cspin The pin attached to RF24 Chip Select (defualt 10)
|
||||
*/
|
||||
Relay(uint8_t _cepin, uint8_t _cspin);
|
||||
Relay(uint8_t _cepin = 9, uint8_t _cspin = 10);
|
||||
|
||||
void begin(uint8_t _radioId=AUTO);
|
||||
void begin(uint8_t radioId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_MAX, uint8_t channel=70);
|
||||
boolean messageAvailable();
|
||||
boolean send(message_s message, int length);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ Sensor::Sensor(uint8_t _cepin, uint8_t _cspin) : RF24(_cepin, _cspin) {
|
||||
}
|
||||
|
||||
|
||||
void Sensor::setupRadio() {
|
||||
void Sensor::setupRadio(rf24_pa_dbm_e paLevel, uint8_t channel) {
|
||||
failedTransmissions = 0;
|
||||
|
||||
// Start up the radio library
|
||||
@@ -25,8 +25,8 @@ void Sensor::setupRadio() {
|
||||
RF24::enableDynamicPayloads();
|
||||
RF24::setAutoAck(false);
|
||||
RF24::setRetries(15, 15);
|
||||
RF24::setPALevel(RF24_PA_MAX);
|
||||
//RF24::setChannel(70); // Default 70
|
||||
RF24::setPALevel(paLevel);
|
||||
RF24::setChannel(channel);
|
||||
RF24::setDataRate(RF24_2MBPS);
|
||||
RF24::setCRCLength(RF24_CRC_16);
|
||||
|
||||
@@ -36,12 +36,14 @@ void Sensor::setupRadio() {
|
||||
}
|
||||
}
|
||||
|
||||
void Sensor::begin(uint8_t _radioId) {
|
||||
void Sensor::begin(uint8_t _radioId, rf24_pa_dbm_e paLevel, uint8_t channel) {
|
||||
Serial.begin(BAUD_RATE);
|
||||
|
||||
radioId = _radioId;
|
||||
|
||||
debug(PSTR("Started %s.\n"), isRelay?"relay":"sensor");
|
||||
|
||||
setupRadio();
|
||||
setupRadio(paLevel, channel);
|
||||
|
||||
// Fetch relay from EEPROM
|
||||
relayId = EEPROM.read(EEPROM_RELAY_ID_ADDRESS);
|
||||
|
||||
@@ -123,18 +123,20 @@ class Sensor : public RF24
|
||||
*
|
||||
* Creates a new instance of Sensor class.
|
||||
*
|
||||
* @param _cepin The pin attached to RF24 Chip Enable on the RF module
|
||||
* @param _cspin The pin attached to RF24 Chip Select
|
||||
* @param _cepin The pin attached to RF24 Chip Enable on the RF module (defualt 9)
|
||||
* @param _cspin The pin attached to RF24 Chip Select (default 10)
|
||||
*/
|
||||
Sensor(uint8_t _cepin, uint8_t _cspin);
|
||||
Sensor(uint8_t _cepin=9, uint8_t _cspin=10);
|
||||
|
||||
/**
|
||||
* Begin operation of the sensor net library
|
||||
*
|
||||
* Call this in setup(), before calling any other sensor net library methods.
|
||||
* @param _radioId The unique id (1-254) for this sensor. Specify 255 for auto id mode.
|
||||
* @param radioId The unique id (1-254) for this sensor. Default 255 (auto mode).
|
||||
* @param paLevel Radio PA Level for this sensor. Default RF24_PA_MAX
|
||||
* @param channel Radio channel. Default RF24_PA_MAX
|
||||
*/
|
||||
void begin(uint8_t _radioId=AUTO);
|
||||
void begin(uint8_t radioId=AUTO, rf24_pa_dbm_e paLevel=RF24_PA_MAX, uint8_t channel=70);
|
||||
|
||||
uint8_t getRadioId();
|
||||
|
||||
@@ -255,7 +257,7 @@ class Sensor : public RF24
|
||||
message_s msg; // Buffer for incoming messages.
|
||||
char convBuffer[20];
|
||||
|
||||
void setupRadio();
|
||||
void setupRadio(rf24_pa_dbm_e paLevel, uint8_t channel);
|
||||
void findRelay();
|
||||
boolean send(message_s message, int length);
|
||||
boolean sendWrite(uint8_t dest, message_s message, int length);
|
||||
|
||||
@@ -6,31 +6,22 @@
|
||||
#include <RF24.h>
|
||||
#include <Sensor.h>
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID AUTO
|
||||
|
||||
#define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected
|
||||
|
||||
#define MAX_ATTACHED_DS18B20 16
|
||||
unsigned long SLEEP_TIME = 30; // Sleep time between reads (in seconds)
|
||||
|
||||
OneWire oneWire(ONE_WIRE_BUS);
|
||||
DallasTemperature sensors(&oneWire);
|
||||
|
||||
Sensor gw(9, 10);
|
||||
Sensor gw;
|
||||
Sleep sleep;
|
||||
|
||||
#define MAX_ATTACHED_DS18B20 16
|
||||
|
||||
float lastTemperature[MAX_ATTACHED_DS18B20];
|
||||
int numSensors=0;
|
||||
boolean metric = true;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_RATE); // Used to type in characters
|
||||
sensors.begin();
|
||||
gw.begin(RADIO_ID);
|
||||
gw.begin();
|
||||
|
||||
// Fetch the number of attached sensors
|
||||
numSensors = sensors.getDeviceCount();
|
||||
@@ -41,9 +32,6 @@ void setup()
|
||||
metric = gw.isMetricSystem();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
gw.powerUp();
|
||||
|
||||
@@ -5,28 +5,21 @@
|
||||
#include <Sensor.h>
|
||||
#include <NewPing.h>
|
||||
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID 8
|
||||
|
||||
#define TRIGGER_PIN 6 // Arduino pin tied to trigger pin on the ultrasonic sensor.
|
||||
#define ECHO_PIN 5 // Arduino pin tied to echo pin on the ultrasonic sensor.
|
||||
#define MAX_DISTANCE 300 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
|
||||
|
||||
unsigned long SLEEP_TIME = 5; // Sleep time between reads (in seconds)
|
||||
|
||||
Sensor gw(9, 10);
|
||||
Sensor gw;
|
||||
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
|
||||
Sleep sleep;
|
||||
|
||||
int lastDist;
|
||||
boolean metric;
|
||||
boolean metric = true;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_RATE); // Used to type in characters
|
||||
gw.begin(RADIO_ID);
|
||||
gw.begin();
|
||||
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
gw.sendSensorPresentation(0, S_DISTANCE);
|
||||
|
||||
@@ -13,21 +13,15 @@
|
||||
#include <RF24.h>
|
||||
#include <Sensor.h>
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID AUTO
|
||||
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your light sensor. (Only 2 and 3 generates interrupt!)
|
||||
#define PULSE_FACTOR 1000 // Nummber of blinks per KWH of your meeter
|
||||
#define SLEEP_MODE false // Watt-value can only be reported when sleep mode is false.
|
||||
#define MAX_WATT 10000 // Max watt value to report. This filetrs outliers.
|
||||
#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
|
||||
#define CHILD_ID 1 // Id of the sensor child
|
||||
unsigned long SEND_FREQUENCY = 20; // Minimum time between send (in seconds). We don't wnat to spam the gateway.
|
||||
|
||||
|
||||
#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
|
||||
#define CHILD_ID 5 // Id of the sensor child
|
||||
|
||||
Sensor gw(9,10);
|
||||
|
||||
Sensor gw;
|
||||
Sleep sleep;
|
||||
|
||||
//double kwhPerBlink = 1.0/((double)PULSE_FACTOR);
|
||||
@@ -43,8 +37,7 @@ unsigned long lastSend;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_RATE); // Used to type in characters
|
||||
gw.begin(RADIO_ID);
|
||||
gw.begin();
|
||||
|
||||
// Register this device as power sensor
|
||||
gw.sendSensorPresentation(CHILD_ID, S_POWER);
|
||||
|
||||
@@ -5,27 +5,21 @@
|
||||
#include <Sensor.h>
|
||||
#include <DHT.h>
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID AUTO
|
||||
#define CHILD_ID_HUM 0
|
||||
#define CHILD_ID_TEMP 1
|
||||
#define HUMIDITY_SENSOR_DIGITAL_PIN 3
|
||||
|
||||
unsigned long SLEEP_TIME = 30; // Sleep time between reads (in seconds)
|
||||
|
||||
Sensor gw(9, 10);
|
||||
Sensor gw;
|
||||
DHT dht;
|
||||
Sleep sleep;
|
||||
|
||||
float lastTemp;
|
||||
float lastHum;
|
||||
boolean metric = true;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_RATE); // Used to type in characters
|
||||
gw.begin(RADIO_ID);
|
||||
gw.begin();
|
||||
dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
|
||||
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
#include <RF24.h>
|
||||
#include <IRremote.h>
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID AUTO
|
||||
|
||||
int RECV_PIN = 8;
|
||||
|
||||
#define CHILD_1 3 // childId
|
||||
@@ -23,17 +19,12 @@ IRsend irsend;
|
||||
IRrecv irrecv(RECV_PIN);
|
||||
decode_results results;
|
||||
|
||||
|
||||
Sensor gw(9,10);
|
||||
|
||||
|
||||
Sensor gw;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_RATE); // Used to write debug info
|
||||
|
||||
irrecv.enableIRIn(); // Start the ir receiver
|
||||
gw.begin(RADIO_ID);
|
||||
gw.begin();
|
||||
|
||||
// Register a sensors to gw. Use binary light for test purposes.
|
||||
gw.sendSensorPresentation(CHILD_1, S_LIGHT);
|
||||
|
||||
@@ -25,25 +25,18 @@
|
||||
#include <BH1750.h>
|
||||
#include <Wire.h>
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID AUTO
|
||||
#define CHILD_ID_LIGHT 0
|
||||
#define LIGHT_SENSOR_ANALOG_PIN 0
|
||||
|
||||
BH1750 lightSensor;
|
||||
|
||||
unsigned long SLEEP_TIME = 30; // Sleep time between reads (in seconds)
|
||||
|
||||
Sensor gw(9,10);
|
||||
|
||||
int lastlux;
|
||||
BH1750 lightSensor;
|
||||
Sensor gw;
|
||||
Sleep sleep;
|
||||
int lastlux;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_RATE); // Used to type in characters
|
||||
gw.begin(RADIO_ID);
|
||||
gw.begin();
|
||||
|
||||
// Register all sensors to gateway (they will be created as child devices)
|
||||
gw.sendSensorPresentation(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
|
||||
@@ -53,7 +46,7 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
gw.powerUp(); // Power up radio
|
||||
gw.powerUp(); // Power up radio (after sleep)
|
||||
|
||||
uint16_t lux = lightSensor.readLightLevel();// Get Lux value
|
||||
Serial.println(lux);
|
||||
|
||||
@@ -4,23 +4,18 @@
|
||||
#include <EEPROM.h>
|
||||
#include <Sensor.h>
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID AUTO
|
||||
#define CHILD_ID_LIGHT 0
|
||||
#define LIGHT_SENSOR_ANALOG_PIN 0
|
||||
|
||||
unsigned long SLEEP_TIME = 30; // Sleep time between reads (in seconds)
|
||||
|
||||
Sensor gw(9,10);
|
||||
|
||||
Sensor gw;
|
||||
int lastLightLevel;
|
||||
Sleep sleep;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_RATE); // Used to type in characters
|
||||
gw.begin(RADIO_ID);
|
||||
gw.begin();
|
||||
|
||||
// Register all sensors to gateway (they will be created as child devices)
|
||||
gw.sendSensorPresentation(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
|
||||
@@ -28,7 +23,7 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
gw.powerUp(); // Power up radio
|
||||
gw.powerUp(); // Power up radio (after sleep)
|
||||
|
||||
int lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23;
|
||||
Serial.println(lightLevel);
|
||||
|
||||
@@ -4,23 +4,16 @@
|
||||
#include <RF24.h>
|
||||
#include <Sensor.h>
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID AUTO
|
||||
|
||||
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
|
||||
#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
|
||||
#define CHILD_ID 0 // Id of the sensor child
|
||||
|
||||
Sensor gw(9,10);
|
||||
|
||||
Sensor gw;
|
||||
Sleep sleep;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_RATE); // Used to type in characters
|
||||
gw.begin(RADIO_ID);
|
||||
gw.begin();
|
||||
pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
gw.sendSensorPresentation(CHILD_ID, S_MOTION);
|
||||
|
||||
@@ -6,16 +6,11 @@
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_BMP085.h>
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID AUTO
|
||||
|
||||
#define LIGHT_SENSOR_ANALOG_PIN 0
|
||||
|
||||
unsigned long SLEEP_TIME = 60; // Sleep time between reads (in seconds)
|
||||
|
||||
Adafruit_BMP085 bmp = Adafruit_BMP085(); // Digital Pressure Sensor
|
||||
Sensor gw(9, 10);
|
||||
Sensor gw;
|
||||
|
||||
float lastPressure = -1;
|
||||
float lastTemp = -1;
|
||||
@@ -31,8 +26,7 @@ float dP_dt;
|
||||
boolean metric;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(BAUD_RATE); // Used to type in characters
|
||||
gw.begin(RADIO_ID);
|
||||
gw.begin();
|
||||
if (!bmp.begin()) {
|
||||
Serial.println("Could not find a valid BMP085 sensor, check wiring!");
|
||||
while (1) { }
|
||||
@@ -42,7 +36,6 @@ void setup() {
|
||||
gw.sendSensorPresentation(0, S_BARO);
|
||||
gw.sendSensorPresentation(1, S_TEMP);
|
||||
metric = gw.isMetricSystem();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,23 +5,16 @@
|
||||
#include <EEPROM.h>
|
||||
#include <RF24.h>
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID AUTO
|
||||
|
||||
#define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
|
||||
#define NUMBER_OF_RELAYS 1
|
||||
|
||||
#define RELAY_ON 0
|
||||
#define RELAY_OFF 1
|
||||
|
||||
Relay gw(9,10);
|
||||
Relay gw;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_RATE); // Used to write debug info
|
||||
|
||||
gw.begin(RADIO_ID);
|
||||
gw.begin();
|
||||
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
for (int i=0; i<NUMBER_OF_RELAYS;i++) {
|
||||
|
||||
@@ -7,14 +7,9 @@
|
||||
#include <EEPROM.h>
|
||||
#include <RF24.h>
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID AUTO
|
||||
#define RELAY_PIN 4 // Arduino Digital I/O pin number for relay
|
||||
#define BUTTON_PIN 3 // Arduino Digital I/O pin number for button (with 10k pulldown)
|
||||
|
||||
#define CHILD_ID 1 // Id of the sensor child
|
||||
|
||||
#define RELAY_ON 0
|
||||
#define RELAY_OFF 1
|
||||
|
||||
@@ -25,13 +20,11 @@ int switched = 0;
|
||||
long pressTime = 0; // the last time the button pin was pressed
|
||||
long debounce = 200; // the debounce time, increase if the output flickers
|
||||
|
||||
Relay gw(9,10);
|
||||
Relay gw;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_RATE); // Used to write debug info
|
||||
|
||||
gw.begin(RADIO_ID);
|
||||
gw.begin();
|
||||
|
||||
// Set buttonPin as Input
|
||||
pinMode(BUTTON_PIN, INPUT);
|
||||
|
||||
@@ -9,23 +9,19 @@
|
||||
#include <EEPROM.h>
|
||||
#include <RF24.h>
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID AUTO
|
||||
|
||||
Relay gw(9,10);
|
||||
Relay gw;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_RATE); // Used to write debug info
|
||||
gw.begin(RADIO_ID);
|
||||
|
||||
gw.begin();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (gw.messageAvailable()) {
|
||||
// Incoming message for this node...
|
||||
// By calling this regularely you route messages in the background
|
||||
if (gw.messageAvailable()) {
|
||||
|
||||
// Handleincoming message for this node here...
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,24 +16,18 @@
|
||||
#define SERVO_MIN 0 // Fine tune your servos min. 0-180
|
||||
#define SERVO_MAX 180 // Fine tune your servos max. 0-180
|
||||
#define DETACH_DELAY 900 // Tune this to let your movement finish before detaching the servo
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID 6
|
||||
#define CHILD_ID 10 // Id of the sensor child
|
||||
|
||||
Sensor gw(9, 10);
|
||||
Sensor gw;
|
||||
Servo myservo; // create servo object to control a servo
|
||||
// a maximum of eight servo objects can be created Sensor gw(9,10);
|
||||
unsigned long timeOfLastChange = 0;
|
||||
bool attachedServo = false;
|
||||
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_RATE);
|
||||
gw.begin(RADIO_ID);
|
||||
gw.begin();
|
||||
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
gw.sendSensorPresentation(CHILD_ID, S_COVER);
|
||||
|
||||
@@ -4,29 +4,22 @@
|
||||
#include <RF24.h>
|
||||
#include <Sensor.h>
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID AUTO
|
||||
|
||||
#define DIGITAL_INPUT_SOIL_SENSOR 3 // Digital input did you attach your soil sensor.
|
||||
#define INTERRUPT DIGITAL_INPUT_SOIL_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
|
||||
#define CHILD_ID 0 // Id of the sensor child
|
||||
|
||||
Sensor gw(9, 10);
|
||||
Sensor gw;
|
||||
Sleep sleep;
|
||||
int lastSoilValue = -1;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_RATE); // Used to type in characters
|
||||
gw.begin(RADIO_ID);
|
||||
gw.begin();
|
||||
|
||||
pinMode(DIGITAL_INPUT_SOIL_SENSOR, INPUT); // sets the soil sensor digital pin as input
|
||||
// Register all sensors to gw (they will be created as child devices)
|
||||
gw.sendSensorPresentation(CHILD_ID, S_MOTION);
|
||||
|
||||
}
|
||||
|
||||
int lastSoilValue = -1;
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
@@ -8,19 +8,14 @@
|
||||
#include <Sensor.h>
|
||||
#include <Time.h>
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID AUTO
|
||||
|
||||
#define CHILD_ID 0 // Id of the sensor child
|
||||
|
||||
Sensor gw(9, 10);
|
||||
Sensor gw;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_RATE); // Used to type in characters
|
||||
gw.begin(RADIO_ID);
|
||||
gw.begin();
|
||||
|
||||
// Register any sensortype. This example we just create a motion sensor.
|
||||
gw.sendSensorPresentation(CHILD_ID, S_MOTION);
|
||||
|
||||
@@ -9,9 +9,6 @@
|
||||
// to calculate/report flow.
|
||||
//
|
||||
// Sensor on pin 3
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
#include <Relay.h>
|
||||
@@ -21,24 +18,15 @@
|
||||
#include <RF24.h>
|
||||
#include <Sensor.h>
|
||||
|
||||
// Set RADIO_ID to something unique in your sensor network (1-254)
|
||||
// or set to AUTO if you want gw to assign a RADIO_ID for you.
|
||||
#define RADIO_ID AUTO
|
||||
|
||||
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your sensor. (Only 2 and 3 generates interrupt!)
|
||||
#define PULSE_FACTOR 1000 // Nummber of blinks per m3 of your meter (One rotation/liter)
|
||||
#define SLEEP_MODE false // flowvalue can only be reported when sleep mode is false.
|
||||
#define MAX_FLOW 40 // Max flow (l/min) value to report. This filetrs outliers.
|
||||
unsigned long SEND_FREQUENCY = 20; // Minimum time between send (in seconds). We don't want to spam the gateway.
|
||||
#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
|
||||
#define CHILD_ID 5 // Id of the sensor child
|
||||
unsigned long SEND_FREQUENCY = 20; // Minimum time between send (in seconds). We don't want to spam the gateway.
|
||||
|
||||
|
||||
|
||||
|
||||
Sensor gw(9,10);
|
||||
|
||||
//enable sleep
|
||||
Sensor gw;
|
||||
Sleep sleep;
|
||||
|
||||
double ppl = ((double)PULSE_FACTOR)/1000; // Pulses per liter
|
||||
@@ -58,8 +46,7 @@ boolean metric;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(BAUD_RATE); // Used to type in characters
|
||||
gw.begin(RADIO_ID);
|
||||
gw.begin();
|
||||
|
||||
// Register this device as Waterflow sensor
|
||||
gw.sendSensorPresentation(CHILD_ID, S_WATER);
|
||||
|
||||
Reference in New Issue
Block a user