I've got MQTTClientGatewayW5100. In the Gateway sketch, there is an additional DHT22 Sensor. It worked for months with the 2.0.0beta lib. Today I recompiled it with the new 2.0.0 stable branch.
I've got a clean Arduino 1.6.9 portable with MySensors 2.0.0 Master from 10.7.2016.
The gateway only comes up on normal usb power plug if I disable the MY_DEBUG feature. Done that, the gw is only posting meassured values without presenting itself, the sketchname or sensors.
// W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
//#define MY_W5100_SPI_EN 4
// Enable Soft SPI for NRF radio (note different radio wiring is required)
// The W5100 ethernet module seems to have a hard time co-operate with
// radio on the same spi bus.
if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
define MY_SOFTSPI
define MY_SOFT_SPI_SCK_PIN 14
define MY_SOFT_SPI_MISO_PIN 16
define MY_SOFT_SPI_MOSI_PIN 15
endif
// When W5100 is connected we have to move CE/CSN pins for NRF radio
ifndef MY_RF24_CE_PIN
define MY_RF24_CE_PIN 5
endif
ifndef MY_RF24_CS_PIN
define MY_RF24_CS_PIN 6
endif
// Enable these if your MQTT broker requires usenrame/password
//#define MY_MQTT_USER "username"
//#define MY_MQTT_PASSWORD "password"
// Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
define MY_IP_ADDRESS 192,168,178,3
// If using static ip you need to define Gateway and Subnet address as well
define MY_IP_GATEWAY_ADDRESS 192,168,178,1
define MY_IP_SUBNET_ADDRESS 255,255,255,0
// MQTT broker ip address or url. Define one or the other.
//#define MY_CONTROLLER_URL_ADDRESS "m20.cloudmqtt.com"
define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 2
// The MQTT broker port to to open
define MY_PORT 1883
/*
// Flash leds on rx/tx/err
define MY_LEDS_BLINKING_FEATURE
// Set blinking period
define MY_DEFAULT_LED_BLINK_PERIOD 300
// Enable inclusion mode
define MY_INCLUSION_MODE_FEATURE
// Enable Inclusion mode button on gateway
define MY_INCLUSION_BUTTON_FEATURE
// Set inclusion mode duration (in seconds)
define MY_INCLUSION_MODE_DURATION 60
// Digital pin used for inclusion mode button
define MY_INCLUSION_MODE_BUTTON_PIN 3
// Uncomment to override default HW configurations
//#define MY_DEFAULT_ERR_LED_PIN 16 // Error led pin
//#define MY_DEFAULT_RX_LED_PIN 16 // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN 16 // the PCB, on board LED
*/
include
include
include
define CHILD_ID_HUM 0
define CHILD_ID_TEMP 1
define HUMIDITY_SENSOR_DIGITAL_PIN 3
unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds)
void presentation() {
// Send the Sketch Version Information to the Gateway
sendSketchInfo(SKETCH_NAME, SKETCH_DATE);
// Register all sensors to gw (they will be created as child devices)
present(CHILD_ID_HUM, S_HUM, "Humidity");
present(CHILD_ID_TEMP, S_TEMP, "Temperature");
}
I've got MQTTClientGatewayW5100. In the Gateway sketch, there is an additional DHT22 Sensor. It worked for months with the 2.0.0beta lib. Today I recompiled it with the new 2.0.0 stable branch. I've got a clean Arduino 1.6.9 portable with MySensors 2.0.0 Master from 10.7.2016.
The gateway only comes up on normal usb power plug if I disable the MY_DEBUG feature. Done that, the gw is only posting meassured values without presenting itself, the sketchname or sensors.
`
include
define FILENAME (strrchr(FILE, '\') ? strrchr(FILE, '\') + 1 : FILE)
define SKETCH_NAME FILENAME
define SKETCH_DATE DATE
include
// Enable debug prints to serial monitor //#define MY_DEBUG
// Enables and select radio type (if attached)
define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
define MY_GATEWAY_MQTT_CLIENT
// Set this nodes subscripe and publish topic prefix
define MY_MQTT_PUBLISH_TOPIC_PREFIX "mysensors-out"
define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mysensors-in"
// Set MQTT client id
define MY_MQTT_CLIENT_ID "mysensors"
// W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal) //#define MY_W5100_SPI_EN 4
// Enable Soft SPI for NRF radio (note different radio wiring is required) // The W5100 ethernet module seems to have a hard time co-operate with // radio on the same spi bus.
if !defined(MY_W5100_SPI_EN) && !defined(ARDUINO_ARCH_SAMD)
define MY_SOFTSPI
define MY_SOFT_SPI_SCK_PIN 14
define MY_SOFT_SPI_MISO_PIN 16
define MY_SOFT_SPI_MOSI_PIN 15
endif
// When W5100 is connected we have to move CE/CSN pins for NRF radio
ifndef MY_RF24_CE_PIN
define MY_RF24_CE_PIN 5
endif
ifndef MY_RF24_CS_PIN
define MY_RF24_CS_PIN 6
endif
// Enable these if your MQTT broker requires usenrame/password //#define MY_MQTT_USER "username" //#define MY_MQTT_PASSWORD "password"
// Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
define MY_IP_ADDRESS 192,168,178,3
// If using static ip you need to define Gateway and Subnet address as well
define MY_IP_GATEWAY_ADDRESS 192,168,178,1
define MY_IP_SUBNET_ADDRESS 255,255,255,0
// MQTT broker ip address or url. Define one or the other. //#define MY_CONTROLLER_URL_ADDRESS "m20.cloudmqtt.com"
define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 2
// The MQTT broker port to to open
define MY_PORT 1883
/* // Flash leds on rx/tx/err
define MY_LEDS_BLINKING_FEATURE
// Set blinking period
define MY_DEFAULT_LED_BLINK_PERIOD 300
// Enable inclusion mode
define MY_INCLUSION_MODE_FEATURE
// Enable Inclusion mode button on gateway
define MY_INCLUSION_BUTTON_FEATURE
// Set inclusion mode duration (in seconds)
define MY_INCLUSION_MODE_DURATION 60
// Digital pin used for inclusion mode button
define MY_INCLUSION_MODE_BUTTON_PIN 3
// Uncomment to override default HW configurations //#define MY_DEFAULT_ERR_LED_PIN 16 // Error led pin //#define MY_DEFAULT_RX_LED_PIN 16 // Receive led pin //#define MY_DEFAULT_TX_LED_PIN 16 // the PCB, on board LED */
include
include
include
define CHILD_ID_HUM 0
define CHILD_ID_TEMP 1
define HUMIDITY_SENSOR_DIGITAL_PIN 3
unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds)
DHT dht; float lastTemp; float lastHum; boolean metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
void setup() { dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); }
void presentation() { // Send the Sketch Version Information to the Gateway sendSketchInfo(SKETCH_NAME, SKETCH_DATE);
// Register all sensors to gw (they will be created as child devices) present(CHILD_ID_HUM, S_HUM, "Humidity"); present(CHILD_ID_TEMP, S_TEMP, "Temperature"); }
void loop() { wait(dht.getMinimumSamplingPeriod());
float temperature = dht.getTemperature(); if (isnan(temperature)) { } else if (temperature != lastTemp) { lastTemp = temperature; send(msgTemp.set(temperature, 1)); }
float humidity = dht.getHumidity(); if (isnan(humidity)) { } else if (humidity != lastHum) { lastHum = humidity; send(msgHum.set(humidity, 1)); } wait(SLEEP_TIME); //sleep a bit }
`