Skip to content

Commit 2647345

Browse files
committed
Adding defines for different board layouts in MyConfig
Adjusted all Gateway examples but only one sensor example so far (DallasTemperature). Other sensor examples should get the same three lines added (not mandatory but helps avoiding unnecessary debugging when selecting the wrong setup)
1 parent 39bab3d commit 2647345

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed

libraries/MySensors/MyConfig.h

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,39 @@
44
/***
55
* Configure Sensor Network
66
*/
7-
#define COMMDRIVER_NRF24
7+
8+
// pick ONE of these - other board layouts can be easily added this way
9+
#define MYSENSORS_SENSOR
10+
//#define MYSENSORS_SERIAL_GATEWAY
11+
//#define MYSENSORS_ETHERNET_MQTT_GATEWAY
12+
13+
#ifdef MYSENSORS_SENSOR
14+
#define MYSENSORS_RF_NRF24
15+
#define RF24_CE_PIN 9
16+
#define RF24_CS_PIN 10
17+
#define RF24_PA_LEVEL RF24_PA_MAX
18+
#endif
819

9-
#ifdef COMMDRIVER_NRF24
20+
#ifdef MYSENSORS_SERIAL_GATEWAY
21+
#define MYSENSORS_RF_NRF24
22+
#define RF24_CE_PIN 9
23+
#define RF24_CS_PIN 10
24+
#define RF24_PA_LEVEL RF24_PA_LOW
25+
#endif
26+
27+
#ifdef MYSENSORS_ETHERNET_MQTT_GATEWAY
28+
#define MYSENSORS_RF_NRF24
29+
#define RF24_CE_PIN 5
30+
#define RF24_CS_PIN 6
31+
#define RF24_PA_LEVEL RF24_PA_LOW
32+
#endif
33+
34+
#ifdef MYSENSORS_RF_NRF24
1035
#include "MyDriverNRF24.h"
1136
typedef class MyDriverNRF24 MyDriverClass;
1237
#define RF24_CHANNEL 76 //RF channel for the sensor net, 0-127
1338
#define RF24_DATARATE RF24_250KBPS //RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps
14-
#define RF24_PA_LEVEL RF24_PA_MAX //Sensor PA Level == RF24_PA_MIN=-18dBm, RF24_PA_LOW=-12dBm, RF24_PA_HIGH=-6dBM, and RF24_PA_MAX=0dBm
1539
#define RF24_BASE_RADIO_ID ((uint64_t)0xA8A8E1FC00LL) // This is also act as base value for sensor nodeId addresses. Change this (or channel) if you have more than one sensor network.
16-
#define RF24_CE_PIN 9
17-
#define RF24_CS_PIN 10
1840
#endif
1941

2042
/***

libraries/MySensors/examples/DallasTemperatureSensor/DallasTemperatureSensor.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#include <DallasTemperature.h>
55
#include <OneWire.h>
66

7+
#ifndef MYSENSORS_SENSOR
8+
#error Please switch to MYSENSORS_SENSOR in MyConfig.h
9+
#endif
10+
711
#define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected
812
#define MAX_ATTACHED_DS18B20 16
913
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)

libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
#include <PinChangeInt.h>
5757
#include "GatewayUtil.h"
5858

59+
#ifndef MYSENSORS_ETHERNET_MQTT_GATEWAY
60+
#error Please switch to MYSENSORS_ETHERNET_MQTT_GATEWAY in MyConfig.h
61+
#endif
5962

6063
// Use this if you have attached a Ethernet ENC28J60 shields
6164
#include <UIPEthernet.h>

libraries/MySensors/examples/MQTTGateway/MQTTGateway.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ http://forum.mysensors.org/topic/303/mqtt-broker-gateway
6262
#include <Ethernet.h>
6363
#include "MyMQTT.h"
6464

65+
#ifndef MYSENSORS_ETHERNET_MQTT_GATEWAY
66+
#error Please switch to MYSENSORS_ETHERNET_MQTT_GATEWAY in MyConfig.h
67+
#endif
6568

6669
#define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
6770
#define INCLUSION_MODE_PIN 3 // Digital pin used for inclusion mode button

libraries/MySensors/examples/SerialGateway/SerialGateway.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
2121
* - ERR (red) - fast blink on error during transmission error or recieve crc error
2222
*/
23-
23+
2424
#define NO_PORTB_PINCHANGES
2525

2626
#include <SPI.h>
@@ -30,6 +30,9 @@
3030
#include <PinChangeInt.h>
3131
#include "GatewayUtil.h"
3232

33+
#ifndef MYSENSORS_SERIAL_GATEWAY
34+
#error Please switch to MYSENSORS_SERIAL_GATEWAY in MyConfig.h
35+
#endif
3336

3437
#define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
3538
#define INCLUSION_MODE_PIN 3 // Digital pin used for inclusion mode button

0 commit comments

Comments
 (0)