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:
@@ -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