Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
C

cleight

@cleight
About
Posts
43
Topics
6
Shares
0
Groups
0
Followers
0
Following
1

Posts

Recent Best Controversial

  • Iboard - Cheap Single board Ethernet Arduino with Radio
    C cleight

    Hello,

    I have been trying to get my iBoard working correctly for a few months on and off and finally got it up and running with good range and things are working good. However I am having an issue with the gateway always being stuck in inclusion mode, I have the following sketch, I would like to retain the onboard LED's but I don't have an inclusion button or need one since I can start the inclusion process from Vera. Any guidance would be greatly appreciated.

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik EKblad
     * Contribution by a-lurker and Anticimex, 
     * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
     *
     * 
     * DESCRIPTION
     * The EthernetGateway sends data received from sensors to the ethernet link. 
     * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
     *
     * The GW code is designed for Arduino 328p / 16MHz.  ATmega168 does not have enough memory to run this program.
     * 
     *
     * COMPILING WIZNET (W5100) ETHERNET MODULE
     * > Edit MyConfig.h in (libraries\MySensors\) to enable softspi (remove // before "#define SOFTSPI").
     *
     * COMPILING ENC28J60 ETHERNET MODULE
     * > Use Arduino IDE 1.5.7 (or later) 
     * > Disable DEBUG in Sensor.h before compiling this sketch. Othervise the sketch will probably not fit in program space when downloading. 
     * > Remove Ethernet.h include below and include UIPEthernet.h 
     * > Remove DigitalIO include 
     * Note that I had to disable UDP and DHCP support in uipethernet-conf.h to reduce space. (which means you have to choose a static IP for that module)
     *
     * VERA CONFIGURATION:
     * Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin. 
     * E.g. If you want to use the defualt values in this sketch enter: 192.168.178.66:5003
     *
     * LED purposes:
     * - To use the feature, uncomment WITH_LEDS_BLINKING in MyConfig.h
     * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
     * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
     * - ERR (red) - fast blink on error during transmission error or recieve crc error  
     * 
     * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
     *
     */
    #define NO_PORTB_PINCHANGES 
    
    #include <DigitalIO.h>     // This include can be removed when using UIPEthernet module  
    #include <SPI.h>  
    
    #include <MySigningNone.h>
    #include <MyTransportRFM69.h>
    #include <MyTransportNRF24.h>
    #include <MyHwATMega328.h>
    #include <MySigningAtsha204Soft.h>
    #include <MySigningAtsha204.h>
    
    #include <MyParserSerial.h>  
    #include <MySensor.h>  
    #include <stdarg.h>
    #include <PinChangeInt.h>
    #include "GatewayUtil.h"
    
    
    // Use this if you have attached a Ethernet ENC28J60 shields  
    // #include <UIPEthernet.h>  
    
    // Use this for WizNET W5100 module and Arduino Ethernet Shield 
    #include <Ethernet.h>   
    
    
    #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
    #define INCLUSION_MODE_PIN  14 // Digital pin used for inclusion mode button
    
    #define RADIO_CE_PIN        3  // radio chip enable
    #define RADIO_SPI_SS_PIN    8  // radio SPI serial select
    
    #define RADIO_ERROR_LED_PIN 7  // Error led pin
    #define RADIO_RX_LED_PIN    6  // Receive led pin
    #define RADIO_TX_LED_PIN    9  // the PCB, on board LED
    
    
    // NRFRF24L01 radio driver (set low transmit power by default) 
    MyTransportNRF24 transport(RADIO_CE_PIN, RADIO_SPI_SS_PIN, RF24_PA_LEVEL_GW);  
    //MyTransportRFM69 transport;
    
    // Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
    //MySigningNone signer;
    //MySigningAtsha204Soft signer;
    //MySigningAtsha204 signer;
    
    // Hardware profile 
    MyHwATMega328 hw;
    
    // Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
    // To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h
    #ifdef WITH_LEDS_BLINKING
    MySensor gw(transport, hw /*, signer*/, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
    #else
    MySensor gw(transport, hw /*, signer*/);
    #endif
    
    
    #define IP_PORT 5003        // The port you want to open 
    IPAddress myIp (192, 168, 2, 62);  // Configure your static ip-address here    COMPILE ERROR HERE? Use Arduino IDE 1.5.7 or later!
    
    // The MAC address can be anything you want but should be unique on your network.
    // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
    // Note that most of the Ardunio examples use  "DEAD BEEF FEED" for the MAC address.
    byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  // DEAD BEEF FEED
    
    // a R/W server on the port
    EthernetServer server = EthernetServer(IP_PORT);
    // handle to open connection
    EthernetClient client = EthernetClient();
    
    char inputString[MAX_RECEIVE_LENGTH] = "";    // A string to hold incoming commands from serial/ethernet interface
    int inputPos = 0;
    bool sentReady = false;
    
    void output(const char *fmt, ... ) {
       va_list args;
       va_start (args, fmt );
       vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args);
       va_end (args);
       Serial.print(serialBuffer);
       server.write(serialBuffer);
    }
    
    void setup()  
    { 
      Ethernet.begin(mac, myIp);
    
      setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
    
      // Add interrupt for inclusion button to pin
      PCintPort::attachInterrupt(pinInclusion, startInclusionInterrupt, RISING);
    
      // give the Ethernet interface a second to initialize
      delay(1000);
    
      // Initialize gateway at maximum PA level, channel 70 and callback for write operations 
      gw.begin(incomingMessage, 0, true, 0);
    
      
      // start listening for clients
      server.begin();
    
    }
    
    
    void loop() {
      gw.process();  
      
      checkButtonTriggeredInclusion();
      checkInclusionFinished();
      
      // if an incoming client connects, there will be
      // bytes available to read via the client object
      EthernetClient newclient = server.available();
      // if a new client connects make sure to dispose any previous existing sockets
      if (newclient) {
          if (client != newclient) {
           client.stop();
           client = newclient;
           output(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"),  C_INTERNAL, I_GATEWAY_READY);
         }
       }
            
       if (client) {
         if (!client.connected()) {
           client.stop();
         } else if (client.available()) { 
           // read the bytes incoming from the client
           char inChar = client.read();
           if (inputPos<MAX_RECEIVE_LENGTH-1) { 
             // if newline then command is complete
             if (inChar == '\n') {  
               Serial.println("Finished");
                // a command was issued by the client
                // we will now try to send it to the actuator
                inputString[inputPos] = 0;
          
                // echo the string to the serial port
                Serial.print(inputString);
          
                parseAndSend(gw, inputString);
          
                // clear the string:
                inputPos = 0;
             } else {  
               // add it to the inputString:
               inputString[inputPos] = inChar;
               inputPos++;
             }
          } else {
             // Incoming message too long. Throw away 
             inputPos = 0;
          }
        }
      }
    }
    
    Hardware iboard

  • Ethernet Gateway stuck in inclusion mode
    C cleight

    Good evening everyone,

    I have been having issues with getting my iBoard gateway with the hardware mod to be stable. I finally got my range issues straightened out and now I am on to the next issue, the gateway being stuck in inclusion mode. I don't have an inclusion button connected to the gateway nor LED's with the exception of the onboard ones. I somehow need to remove the inclusion button from the sketch but not sure how to go about doing that.

    Gateway Sketch:

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik EKblad
     * Contribution by a-lurker and Anticimex, 
     * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
     *
     * 
     * DESCRIPTION
     * The EthernetGateway sends data received from sensors to the ethernet link. 
     * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
     *
     * The GW code is designed for Arduino 328p / 16MHz.  ATmega168 does not have enough memory to run this program.
     * 
     *
     * COMPILING WIZNET (W5100) ETHERNET MODULE
     * > Edit MyConfig.h in (libraries\MySensors\) to enable softspi (remove // before "#define SOFTSPI").
     *
     * COMPILING ENC28J60 ETHERNET MODULE
     * > Use Arduino IDE 1.5.7 (or later) 
     * > Disable DEBUG in Sensor.h before compiling this sketch. Othervise the sketch will probably not fit in program space when downloading. 
     * > Remove Ethernet.h include below and include UIPEthernet.h 
     * > Remove DigitalIO include 
     * Note that I had to disable UDP and DHCP support in uipethernet-conf.h to reduce space. (which means you have to choose a static IP for that module)
     *
     * VERA CONFIGURATION:
     * Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin. 
     * E.g. If you want to use the defualt values in this sketch enter: 192.168.178.66:5003
     *
     * LED purposes:
     * - To use the feature, uncomment WITH_LEDS_BLINKING in MyConfig.h
     * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
     * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
     * - ERR (red) - fast blink on error during transmission error or recieve crc error  
     * 
     * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
     *
     */
    #define NO_PORTB_PINCHANGES 
    
    #include <DigitalIO.h>     // This include can be removed when using UIPEthernet module  
    #include <SPI.h>  
    
    #include <MySigningNone.h>
    #include <MyTransportRFM69.h>
    #include <MyTransportNRF24.h>
    #include <MyHwATMega328.h>
    #include <MySigningAtsha204Soft.h>
    #include <MySigningAtsha204.h>
    
    #include <MyParserSerial.h>  
    #include <MySensor.h>  
    #include <stdarg.h>
    #include <PinChangeInt.h>
    #include "GatewayUtil.h"
    
    
    // Use this if you have attached a Ethernet ENC28J60 shields  
    // #include <UIPEthernet.h>  
    
    // Use this for WizNET W5100 module and Arduino Ethernet Shield 
    #include <Ethernet.h>   
    
    
    #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
    #define INCLUSION_MODE_PIN  14 // Digital pin used for inclusion mode button
    
    #define RADIO_CE_PIN        3  // radio chip enable
    #define RADIO_SPI_SS_PIN    8  // radio SPI serial select
    
    #define RADIO_ERROR_LED_PIN 7  // Error led pin
    #define RADIO_RX_LED_PIN    6  // Receive led pin
    #define RADIO_TX_LED_PIN    9  // the PCB, on board LED
    
    
    // NRFRF24L01 radio driver (set low transmit power by default) 
    MyTransportNRF24 transport(RADIO_CE_PIN, RADIO_SPI_SS_PIN, RF24_PA_LEVEL_GW);  
    //MyTransportRFM69 transport;
    
    // Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
    //MySigningNone signer;
    //MySigningAtsha204Soft signer;
    //MySigningAtsha204 signer;
    
    // Hardware profile 
    MyHwATMega328 hw;
    
    // Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
    // To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h
    #ifdef WITH_LEDS_BLINKING
    MySensor gw(transport, hw /*, signer*/, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
    #else
    MySensor gw(transport, hw /*, signer*/);
    #endif
    
    
    #define IP_PORT 5003        // The port you want to open 
    IPAddress myIp (192, 168, 2, 62);  // Configure your static ip-address here    COMPILE ERROR HERE? Use Arduino IDE 1.5.7 or later!
    
    // The MAC address can be anything you want but should be unique on your network.
    // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
    // Note that most of the Ardunio examples use  "DEAD BEEF FEED" for the MAC address.
    byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  // DEAD BEEF FEED
    
    // a R/W server on the port
    EthernetServer server = EthernetServer(IP_PORT);
    // handle to open connection
    EthernetClient client = EthernetClient();
    
    char inputString[MAX_RECEIVE_LENGTH] = "";    // A string to hold incoming commands from serial/ethernet interface
    int inputPos = 0;
    bool sentReady = false;
    
    void output(const char *fmt, ... ) {
       va_list args;
       va_start (args, fmt );
       vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args);
       va_end (args);
       Serial.print(serialBuffer);
       server.write(serialBuffer);
    }
    
    void setup()  
    { 
      Ethernet.begin(mac, myIp);
    
      setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
    
      // Add interrupt for inclusion button to pin
      PCintPort::attachInterrupt(pinInclusion, startInclusionInterrupt, RISING);
    
      // give the Ethernet interface a second to initialize
      delay(1000);
    
      // Initialize gateway at maximum PA level, channel 70 and callback for write operations 
      gw.begin(incomingMessage, 0, true, 0);
    
      
      // start listening for clients
      server.begin();
    
    }
    
    
    void loop() {
      gw.process();  
      
      checkButtonTriggeredInclusion();
      checkInclusionFinished();
      
      // if an incoming client connects, there will be
      // bytes available to read via the client object
      EthernetClient newclient = server.available();
      // if a new client connects make sure to dispose any previous existing sockets
      if (newclient) {
          if (client != newclient) {
           client.stop();
           client = newclient;
           output(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"),  C_INTERNAL, I_GATEWAY_READY);
         }
       }
            
       if (client) {
         if (!client.connected()) {
           client.stop();
         } else if (client.available()) { 
           // read the bytes incoming from the client
           char inChar = client.read();
           if (inputPos<MAX_RECEIVE_LENGTH-1) { 
             // if newline then command is complete
             if (inChar == '\n') {  
               Serial.println("Finished");
                // a command was issued by the client
                // we will now try to send it to the actuator
                inputString[inputPos] = 0;
          
                // echo the string to the serial port
                Serial.print(inputString);
          
                parseAndSend(gw, inputString);
          
                // clear the string:
                inputPos = 0;
             } else {  
               // add it to the inputString:
               inputString[inputPos] = inChar;
               inputPos++;
             }
          } else {
             // Incoming message too long. Throw away 
             inputPos = 0;
          }
        }
      }
    }
    
    Troubleshooting

  • Poor Signal range from sensor to gateway
    C cleight

    Hardware mod

    Troubleshooting

  • Poor Signal range from sensor to gateway
    C cleight

    Good news! I was able to get everything working finally! Here it must of been an issue with my gateway sketch along with changing power settings on the gateway to RF24_PA_LOW. my only issue now with my gateway is Vera shows it constantly in inclusion mode, I believe it has something to do with my sketch, I don't have an inclusion button on my iBoard Gateway so I changed the PIN in the sketch to a fictitious pin but that seems to have just compounded the issue, if anyone can point me in the right direction on that front it would be much appreciated.

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik EKblad
     * Contribution by a-lurker and Anticimex, 
     * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
     *
     * 
     * DESCRIPTION
     * The EthernetGateway sends data received from sensors to the ethernet link. 
     * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
     *
     * The GW code is designed for Arduino 328p / 16MHz.  ATmega168 does not have enough memory to run this program.
     * 
     *
     * COMPILING WIZNET (W5100) ETHERNET MODULE
     * > Edit MyConfig.h in (libraries\MySensors\) to enable softspi (remove // before "#define SOFTSPI").
     *
     * COMPILING ENC28J60 ETHERNET MODULE
     * > Use Arduino IDE 1.5.7 (or later) 
     * > Disable DEBUG in Sensor.h before compiling this sketch. Othervise the sketch will probably not fit in program space when downloading. 
     * > Remove Ethernet.h include below and include UIPEthernet.h 
     * > Remove DigitalIO include 
     * Note that I had to disable UDP and DHCP support in uipethernet-conf.h to reduce space. (which means you have to choose a static IP for that module)
     *
     * VERA CONFIGURATION:
     * Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin. 
     * E.g. If you want to use the defualt values in this sketch enter: 192.168.178.66:5003
     *
     * LED purposes:
     * - To use the feature, uncomment WITH_LEDS_BLINKING in MyConfig.h
     * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
     * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
     * - ERR (red) - fast blink on error during transmission error or recieve crc error  
     * 
     * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
     *
     */
    #define NO_PORTB_PINCHANGES 
    
    #include <DigitalIO.h>     // This include can be removed when using UIPEthernet module  
    #include <SPI.h>  
    
    #include <MySigningNone.h>
    #include <MyTransportRFM69.h>
    #include <MyTransportNRF24.h>
    #include <MyHwATMega328.h>
    #include <MySigningAtsha204Soft.h>
    #include <MySigningAtsha204.h>
    
    #include <MyParserSerial.h>  
    #include <MySensor.h>  
    #include <stdarg.h>
    #include <PinChangeInt.h>
    #include "GatewayUtil.h"
    
    
    // Use this if you have attached a Ethernet ENC28J60 shields  
    // #include <UIPEthernet.h>  
    
    // Use this for WizNET W5100 module and Arduino Ethernet Shield 
    #include <Ethernet.h>   
    
    
    #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
    #define INCLUSION_MODE_PIN  14 // Digital pin used for inclusion mode button
    
    #define RADIO_CE_PIN        3  // radio chip enable
    #define RADIO_SPI_SS_PIN    8  // radio SPI serial select
    
    #define RADIO_ERROR_LED_PIN 7  // Error led pin
    #define RADIO_RX_LED_PIN    6  // Receive led pin
    #define RADIO_TX_LED_PIN    9  // the PCB, on board LED
    
    
    // NRFRF24L01 radio driver (set low transmit power by default) 
    MyTransportNRF24 transport(RADIO_CE_PIN, RADIO_SPI_SS_PIN, RF24_PA_LEVEL_GW);  
    //MyTransportRFM69 transport;
    
    // Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
    //MySigningNone signer;
    //MySigningAtsha204Soft signer;
    //MySigningAtsha204 signer;
    
    // Hardware profile 
    MyHwATMega328 hw;
    
    // Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
    // To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h
    #ifdef WITH_LEDS_BLINKING
    MySensor gw(transport, hw /*, signer*/, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
    #else
    MySensor gw(transport, hw /*, signer*/);
    #endif
    
    
    #define IP_PORT 5003        // The port you want to open 
    IPAddress myIp (192, 168, 2, 62);  // Configure your static ip-address here    COMPILE ERROR HERE? Use Arduino IDE 1.5.7 or later!
    
    // The MAC address can be anything you want but should be unique on your network.
    // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
    // Note that most of the Ardunio examples use  "DEAD BEEF FEED" for the MAC address.
    byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  // DEAD BEEF FEED
    
    // a R/W server on the port
    EthernetServer server = EthernetServer(IP_PORT);
    // handle to open connection
    EthernetClient client = EthernetClient();
    
    char inputString[MAX_RECEIVE_LENGTH] = "";    // A string to hold incoming commands from serial/ethernet interface
    int inputPos = 0;
    bool sentReady = false;
    
    void output(const char *fmt, ... ) {
       va_list args;
       va_start (args, fmt );
       vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args);
       va_end (args);
       Serial.print(serialBuffer);
       server.write(serialBuffer);
    }
    
    void setup()  
    { 
      Ethernet.begin(mac, myIp);
    
      setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
    
      // Add interrupt for inclusion button to pin
      PCintPort::attachInterrupt(pinInclusion, startInclusionInterrupt, RISING);
    
      // give the Ethernet interface a second to initialize
      delay(1000);
    
      // Initialize gateway at maximum PA level, channel 70 and callback for write operations 
      gw.begin(incomingMessage, 0, true, 0);
    
      
      // start listening for clients
      server.begin();
    
    }
    
    
    void loop() {
      gw.process();  
      
      checkButtonTriggeredInclusion();
      checkInclusionFinished();
      
      // if an incoming client connects, there will be
      // bytes available to read via the client object
      EthernetClient newclient = server.available();
      // if a new client connects make sure to dispose any previous existing sockets
      if (newclient) {
          if (client != newclient) {
           client.stop();
           client = newclient;
           output(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"),  C_INTERNAL, I_GATEWAY_READY);
         }
       }
            
       if (client) {
         if (!client.connected()) {
           client.stop();
         } else if (client.available()) { 
           // read the bytes incoming from the client
           char inChar = client.read();
           if (inputPos<MAX_RECEIVE_LENGTH-1) { 
             // if newline then command is complete
             if (inChar == '\n') {  
               Serial.println("Finished");
                // a command was issued by the client
                // we will now try to send it to the actuator
                inputString[inputPos] = 0;
          
                // echo the string to the serial port
                Serial.print(inputString);
          
                parseAndSend(gw, inputString);
          
                // clear the string:
                inputPos = 0;
             } else {  
               // add it to the inputString:
               inputString[inputPos] = inChar;
               inputPos++;
             }
          } else {
             // Incoming message too long. Throw away 
             inputPos = 0;
          }
        }
      }
    }
    
    Troubleshooting

  • Poor Signal range from sensor to gateway
    C cleight

    I recieved my NRF24L01+PA+LNA yesterday in the mail. I installed this on my gateway and still the range is exactly how it was to my sensors. I have built another simple temp/humidity sensor that is only 10' from the gateway and still cannot communicate to the gateway. I still have RF24_PA_MAX for both the sensors and the gateway and nothing.

    I am now at the point of wondering if I have a bad iBoard (gateway) that is causing these issues. Any more insight before I order another iBoard for a gateway?

    Also if I wanted to temporarily change from an ethernet gateway to a serial/usb gateway with Vera what all would be involved?

    Troubleshooting

  • Poor Signal range from sensor to gateway
    C cleight

    So my only options are a lp radio with an extension cable /antenna outside the hot tub cabinet or possibly the rm69 radio correct?

    Would it be possible to hard wire the sensor via ether net to the mysen sort network?

    Troubleshooting

  • Poor Signal range from sensor to gateway
    C cleight

    Since no one has posted anything in the form of suggestions. I am going to order a NRF24L01+PA+LNA for my gateway and see if it helps. I built a simple temp/humidity sensor from the examples and have it directly 1 floor above the gateway and it isn't being picked up by the gateway either. The power supply going to my iBoard gateway is a 9V 1000ma wall wart, I believe this has plenty of power to run the Ardunio, Ethernet, and the radio. I have also switched the 4.7uf capacitor for a 47uf capacitor without luck either.

    Troubleshooting

  • Poor Signal range from sensor to gateway
    C cleight

    I am hoping someone here could possibly shed some insight as to what steps to take next. I am having issues getting a sensor that is approximately 15ft (3m) from the gateway to communicate. It appears it will not communicate with the gateway unless it is approximately 3ft (1m) away from the gateway. Here is some background of my environment:

    Gateway:
    itead studio iBoard
    NRF24L01+ (Added 4.7u Decoupling Capacitor, didn't make a difference)
    Version 1.5
    Sketch:

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik EKblad
     * Contribution by a-lurker and Anticimex, 
     * Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
     *
     * 
     * DESCRIPTION
     * The EthernetGateway sends data received from sensors to the ethernet link. 
     * The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
     *
     * The GW code is designed for Arduino 328p / 16MHz.  ATmega168 does not have enough memory to run this program.
     * 
     *
     * COMPILING WIZNET (W5100) ETHERNET MODULE
     * > Edit MyConfig.h in (libraries\MySensors\) to enable softspi (remove // before "#define SOFTSPI").
     *
     * COMPILING ENC28J60 ETHERNET MODULE
     * > Use Arduino IDE 1.5.7 (or later) 
     * > Disable DEBUG in Sensor.h before compiling this sketch. Othervise the sketch will probably not fit in program space when downloading. 
     * > Remove Ethernet.h include below and include UIPEthernet.h 
     * > Remove DigitalIO include 
     * Note that I had to disable UDP and DHCP support in uipethernet-conf.h to reduce space. (which means you have to choose a static IP for that module)
     *
     * VERA CONFIGURATION:
     * Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin. 
     * E.g. If you want to use the defualt values in this sketch enter: 192.168.178.66:5003
     *
     * LED purposes:
     * - To use the feature, uncomment WITH_LEDS_BLINKING in MyConfig.h
     * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
     * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
     * - ERR (red) - fast blink on error during transmission error or recieve crc error  
     * 
     * See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
     *
     */
    #define NO_PORTB_PINCHANGES 
    
    #include <DigitalIO.h>     // This include can be removed when using UIPEthernet module  
    #include <SPI.h>  
    
    #include <MySigningNone.h>
    #include <MyTransportRFM69.h>
    #include <MyTransportNRF24.h>
    #include <MyHwATMega328.h>
    #include <MySigningAtsha204Soft.h>
    #include <MySigningAtsha204.h>
    
    #include <MyParserSerial.h>  
    #include <MySensor.h>  
    #include <stdarg.h>
    #include <PinChangeInt.h>
    #include "GatewayUtil.h"
    
    
    // Use this if you have attached a Ethernet ENC28J60 shields  
    // #include <UIPEthernet.h>  
    
    // Use this for WizNET W5100 module and Arduino Ethernet Shield 
    #include <Ethernet.h>   
    
    
    #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
    #define INCLUSION_MODE_PIN  3 // Digital pin used for inclusion mode button
    
    #define RADIO_CE_PIN        3  // radio chip enable
    #define RADIO_SPI_SS_PIN    8  // radio SPI serial select
    
    #define RADIO_ERROR_LED_PIN 7  // Error led pin
    #define RADIO_RX_LED_PIN    6  // Receive led pin
    #define RADIO_TX_LED_PIN    9  // the PCB, on board LED
    
    
    // NRFRF24L01 radio driver (set low transmit power by default) 
    MyTransportNRF24 transport(RADIO_CE_PIN, RADIO_SPI_SS_PIN, RF24_PA_LEVEL_GW);  
    //MyTransportRFM69 transport;
    
    // Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
    //MySigningNone signer;
    //MySigningAtsha204Soft signer;
    //MySigningAtsha204 signer;
    
    // Hardware profile 
    MyHwATMega328 hw;
    
    // Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
    // To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h
    #ifdef WITH_LEDS_BLINKING
    MySensor gw(transport, hw /*, signer*/, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
    #else
    MySensor gw(transport, hw /*, signer*/);
    #endif
    
    
    #define IP_PORT 5003        // The port you want to open 
    IPAddress myIp (192, 168, 2, 62);  // Configure your static ip-address here    COMPILE ERROR HERE? Use Arduino IDE 1.5.7 or later!
    
    // The MAC address can be anything you want but should be unique on your network.
    // Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
    // Note that most of the Ardunio examples use  "DEAD BEEF FEED" for the MAC address.
    byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  // DEAD BEEF FEED
    
    // a R/W server on the port
    EthernetServer server = EthernetServer(IP_PORT);
    // handle to open connection
    EthernetClient client = EthernetClient();
    
    char inputString[MAX_RECEIVE_LENGTH] = "";    // A string to hold incoming commands from serial/ethernet interface
    int inputPos = 0;
    bool sentReady = false;
    
    void output(const char *fmt, ... ) {
       va_list args;
       va_start (args, fmt );
       vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args);
       va_end (args);
       Serial.print(serialBuffer);
       server.write(serialBuffer);
    }
    
    void setup()  
    { 
      Ethernet.begin(mac, myIp);
    
      setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
    
      // Add interrupt for inclusion button to pin
      PCintPort::attachInterrupt(pinInclusion, startInclusionInterrupt, RISING);
    
      // give the Ethernet interface a second to initialize
      delay(1000);
    
      // Initialize gateway at maximum PA level, channel 70 and callback for write operations 
      gw.begin(incomingMessage, 0, true, 0);
    
      
      // start listening for clients
      server.begin();
    
    }
    
    
    void loop() {
      gw.process();  
      
      checkButtonTriggeredInclusion();
      checkInclusionFinished();
      
      // if an incoming client connects, there will be
      // bytes available to read via the client object
      EthernetClient newclient = server.available();
      // if a new client connects make sure to dispose any previous existing sockets
      if (newclient) {
          if (client != newclient) {
           client.stop();
           client = newclient;
           output(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"),  C_INTERNAL, I_GATEWAY_READY);
         }
       }
            
       if (client) {
         if (!client.connected()) {
           client.stop();
         } else if (client.available()) { 
           // read the bytes incoming from the client
           char inChar = client.read();
           if (inputPos<MAX_RECEIVE_LENGTH-1) { 
             // if newline then command is complete
             if (inChar == '\n') {  
               Serial.println("Finished");
                // a command was issued by the client
                // we will now try to send it to the actuator
                inputString[inputPos] = 0;
          
                // echo the string to the serial port
                Serial.print(inputString);
          
                parseAndSend(gw, inputString);
          
                // clear the string:
                inputPos = 0;
             } else {  
               // add it to the inputString:
               inputString[inputPos] = inChar;
               inputPos++;
             }
          } else {
             // Incoming message too long. Throw away 
             inputPos = 0;
          }
        }
      }
    }
    
    

    Sensor:
    Arduino Nano
    NRF24L01+ (Added 4.7u Decoupling Capacitor)
    Dallas Waterproof Temperature Sensor
    DHT II (temp/humidity)
    AC/DC Converter - https://www.itead.cc/power/ac-dc-power-module-5v-700ma-v2.html
    Sketch:

    #include <SPI.h>
    #include <MySensor.h>  
    #include <DHT.h>
    #include <DallasTemperature.h>
    #include <OneWire.h>
    
    #define CHILD_ID_HUM 1
    #define CHILD_ID_TEMP 2
    #define CHILD_ID_HTTEMP 3
    #define HUMIDITY_SENSOR_DIGITAL_PIN 3
    //Waterproof Sensor addition
    #define ONE_WIRE_BUS 4 //Pin where waterproof temp sensor is connected
    #define MAX_ATTACHED_DS18B20 16
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    OneWire oneWire(ONE_WIRE_BUS);
    DallasTemperature sensors(&oneWire);
    
    MySensor gw;
    DHT dht;
    float lastTemperature[MAX_ATTACHED_DS18B20];
    int numSensors=0;
    boolean receivedConfig = false;
    float lastTemp;
    float lastHum;
    boolean metric = false; 
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgHumLCD(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgTempLCD(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgHTTemp(CHILD_ID_HTTEMP, V_TEMP);
    MyMessage msgHTTempLCD(CHILD_ID_HTTEMP, V_TEMP);
    
    void setup()  
    { 
      // Startup OneWire
      sensors.begin();
    
      gw.begin();
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
      //Send Child Sensors to node 11
      msgHumLCD.setDestination(11);
      msgTempLCD.setDestination(11);
      msgHTTempLCD.setDestination(11);
    
      // Send the Sketch Version Information to the Gateway
      gw.sendSketchInfo("Hot Tub Monitor", "2.4");
    
      // Fetch the number of attached temperature sensors
      numSensors = sensors.getDeviceCount();
    
      // Present all sensors to controller
      for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
        gw.present(i, S_TEMP);
      }
    
      // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID_HUM, S_HUM);
      gw.present(CHILD_ID_TEMP, S_TEMP);
    
      metric = gw.getConfig().isMetric;
    }
    
    void loop()      
    {  
      // Process incoming messages (like config from server)
      gw.process();
    
      //Fetch temperatures from Dallas sensors
      sensors.requestTemperatures();
    
      // Red temperatures and send them to the controller
      for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
    
        // Fetch and round temperature to one decimal
        float temperature = static_cast<float>(static_cast<int>((sensors.getTempFByIndex(i)) * 10.)) / 10.;
    
        //Only send data if temperature has changed and no error
        if (lastTemperature[i] != temperature && temperature != -127.00) {
    
          // Send in the new temperature
          delay(100);
          gw.send(msgHTTemp.setSensor(i).set(temperature,1));
          gw.send(msgHTTempLCD.set(static_cast<int>(temperature)));
          Serial.print("T2: ");
          Serial.println(temperature);
          lastTemperature[i]=temperature;
        }
      }
    
      delay(dht.getMinimumSamplingPeriod());
    
      //float temperature = dht.getTemperature();
      float temperature = dht.getTemperature()*9/5 + 32;
      if (isnan(temperature)) {
        Serial.println("Failed reading temperature from DHT");
      } 
      else if (temperature != lastTemp) {
        lastTemp = temperature;
        if (!metric) {
          //temperature = dht.toFahrenheit(temperature);
          temperature = dht.getTemperature()*9/5 + 32;
        }
        delay(100);
        gw.send(msgTemp.set(temperature, 1));
        gw.send(msgTempLCD.set(static_cast<int>(temperature)));
        Serial.print("T: ");
        Serial.println(temperature);
      }
    
      float humidity = dht.getHumidity();
      if (isnan(humidity)) {
        Serial.println("Failed reading humidity from DHT");
      } 
      else if (humidity != lastHum) {
        lastHum = humidity;
        delay(100);
        gw.send(msgHum.set(humidity, 1));
        gw.send(msgHumLCD.set(static_cast<int>(humidity)));
        Serial.print("H: ");
        Serial.println(humidity);
      }
    
      gw.sleep(SLEEP_TIME); //sleep a bit
    }
    

    Debug Log from Sensor:

    send: 1-1-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=fail:1.5.1
    send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=fail:0
    sensor started, id=1, parent=0, distance=1
    send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=15,sg=0,st=fail:Hot Tub Monitor
    send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=fail:2.4
    send: 1-1-0-0 s=0,c=0,t=6,pt=0,l=0,sg=0,st=fail:
    send: 1-1-0-0 s=1,c=0,t=7,pt=0,l=0,sg=0,st=fail:
    find parent
    send: 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
    send: 1-1-0-0 s=2,c=0,t=6,pt=0,l=0,sg=0,st=fail:
    send: 1-1-0-0 s=0,c=1,t=0,pt=7,l=5,sg=0,st=fail:96.1
    send: 1-1-0-11 s=3,c=1,t=0,pt=2,l=2,sg=0,st=fail:96
    T2: 96.10
    send: 1-1-0-0 s=2,c=1,t=0,pt=7,l=5,sg=0,st=fail:71.6
    send: 1-1-0-11 s=2,c=1,t=0,pt=2,l=2,sg=0,st=fail:71
    T: 71.60
    send: 1-1-0-0 s=1,c=1,t=1,pt=7,l=5,sg=0,st=fail:39.0
    find parent
    send: 1-1-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,st=bc:
    send: 1-1-0-11 s=1,c=1,t=1,pt=2,l=2,sg=0,st=fail:39
    H: 39.00
    
    

    I have changed the wireless channel to 120, this didn't make any difference. I have also increased the power levels in myconfig.h to the following:

    #define RF24_PA_LEVEL 	   RF24_PA_MAX
    #define RF24_PA_LEVEL_GW   RF24_PA_MAX
    

    Didn't help so I then changed them to:

    #define RF24_PA_LEVEL 	   RF24_PA_HIGH
    #define RF24_PA_LEVEL_GW   RF24_PA_HIGH
    

    At this point I am not sure what to try. The sensor is inside of my Hot Tub Cabinet, doesn't have any metal around it but the signal does need to go around or through the 400 gallons of water.

    Troubleshooting

  • Last Update Date
    C cleight

    Hello, I am running a Vera Lite running on UI5. Is it possible to somehow get the last update date along with the time? I have issues were sensors sometimes hang and I'm not sure exactly when the hang occured.

    Vera

  • Node to Node Communication
    C cleight

    @Chaotic Sorry for not getting back sooner on this, but I did confirm that your solution does indeed work and works very well. I can't wait to finish this project up and be able to post the Pictures/Sketch to share with the community.

    Development

  • Node to Node Communication
    C cleight

    Ok last issue to be worked out and I think I am good to go, thanks again to @Chaotic and @hek for there assistance with my project.

    Last issue is with the sensor node, it sends the data to the LCD Node (node 11) but only sends the data to the gateway on boot, it will not send it to the gateway after it starts sending to Node 11. I would like it to send to both the Node and the Gateway all the time, that way Vera see the information as well as my LCD.

    Here is the output of the Serial Monitor, also for some reason on each temp update it sends to node 11 twice for some reason:
    sensor started, id 1
    send: 1-1-0-0 s=255,c=0,t=17,pt=0,l=5,st=ok:1.4.1
    send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
    read: 0-0-1 s=255,c=3,t=6,pt=0,l=1:I
    send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=15,st=ok:Hot Tub Monitor
    send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:2.0
    send: 1-1-0-0 s=0,c=0,t=6,pt=0,l=5,st=ok:1.4.1
    send: 1-1-0-0 s=1,c=0,t=7,pt=0,l=5,st=ok:1.4.1
    send: 1-1-0-0 s=2,c=0,t=6,pt=0,l=5,st=ok:1.4.1
    send: 1-1-0-0 s=0,c=1,t=0,pt=7,l=5,st=ok:67.2
    send: 1-1-0-11 s=0,c=1,t=0,pt=2,l=2,st=ok:67
    T2: 67.20
    send: 1-1-0-0 s=2,c=1,t=0,pt=7,l=5,st=ok:66.2
    T: 66.20
    send: 1-1-0-0 s=1,c=1,t=1,pt=7,l=5,st=ok:36.0
    send: 1-1-0-11 s=1,c=1,t=1,pt=2,l=2,st=ok:36
    H: 36.00
    send: 1-1-0-11 s=0,c=1,t=0,pt=7,l=5,st=ok:75.7
    send: 1-1-0-11 s=0,c=1,t=0,pt=2,l=2,st=ok:75
    T2: 75.70
    send: 1-1-0-11 s=0,c=1,t=0,pt=7,l=5,st=ok:80.1
    send: 1-1-0-11 s=0,c=1,t=0,pt=2,l=2,st=ok:80
    T2: 80.10
    send: 1-1-0-11 s=0,c=1,t=0,pt=7,l=5,st=ok:81.6
    send: 1-1-0-11 s=0,c=1,t=0,pt=2,l=2,st=ok:81
    T2: 81.60
    send: 1-1-0-11 s=0,c=1,t=0,pt=7,l=5,st=ok:81.7
    send: 1-1-0-11 s=0,c=1,t=0,pt=2,l=2,st=ok:81
    T2: 81.70
    send: 1-1-0-11 s=0,c=1,t=0,pt=7,l=5,st=ok:79.8
    send: 1-1-0-11 s=0,c=1,t=0,pt=2,l=2,st=ok:79
    T2: 79.80
    send: 1-1-0-11 s=0,c=1,t=0,pt=7,l=5,st=ok:78.1
    send: 1-1-0-11 s=0,c=1,t=0,pt=2,l=2,st=ok:78
    T2: 78.10
    send: 1-1-0-11 s=0,c=1,t=0,pt=7,l=5,st=ok:76.7
    send: 1-1-0-11 s=0,c=1,t=0,pt=2,l=2,st=ok:76
    T2: 76.70
    send: 1-1-0-11 s=0,c=1,t=0,pt=7,l=5,st=ok:75.5
    send: 1-1-0-11 s=0,c=1,t=0,pt=2,l=2,st=ok:75
    T2: 75.50

    Here is the sketch:

    #include <SPI.h>
    #include <MySensor.h>  
    #include <DHT.h>
    #include <DallasTemperature.h>
    #include <OneWire.h>
    
    #define CHILD_ID_HUM 1
    #define CHILD_ID_TEMP 2
    #define CHILD_ID_HTTEMP 3
    #define HUMIDITY_SENSOR_DIGITAL_PIN 3
    //Waterproof Sensor addition
    #define ONE_WIRE_BUS 4 //Pin where waterproof temp sensor is connected
    #define MAX_ATTACHED_DS18B20 16
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    OneWire oneWire(ONE_WIRE_BUS);
    DallasTemperature sensors(&oneWire);
    
    MySensor gw;
    DHT dht;
    float lastTemperature[MAX_ATTACHED_DS18B20];
    int numSensors=0;
    boolean receivedConfig = false;
    float lastTemp;
    float lastHum;
    boolean metric = false; 
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgHTTemp(CHILD_ID_HTTEMP, V_TEMP);
    
    void setup()  
    { 
      // Startup OneWire
      sensors.begin();
    
      gw.begin();
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
    
      // Send the Sketch Version Information to the Gateway
      gw.sendSketchInfo("Hot Tub Monitor", "2.0");
    
      // Fetch the number of attached temperature sensors
      numSensors = sensors.getDeviceCount();
    
      // Present all sensors to controller
      for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
        gw.present(i, S_TEMP);
      }
    
      // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID_HUM, S_HUM);
      gw.present(CHILD_ID_TEMP, S_TEMP);
    
      metric = gw.getConfig().isMetric;
    }
    
    void loop()      
    {  
      // Process incoming messages (like config from server)
      gw.process();
    
      //Fetch temperatures from Dallas sensors
      sensors.requestTemperatures();
    
      // Red temperatures and send them to the controller
      for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
    
        // Fetch and round temperature to one decimal
        float temperature = static_cast<float>(static_cast<int>((sensors.getTempFByIndex(i)) * 10.)) / 10.;
    
        //Only send data if temperature has changed and no error
        if (lastTemperature[i] != temperature && temperature != -127.00) {
    
          // Send in the new temperature
          delay(100);
          gw.send(msgHTTemp.setSensor(i).set(temperature,1));
          gw.send(msgHTTemp.setDestination(11).set(static_cast<int>(temperature)));
          Serial.print("T2: ");
          Serial.println(temperature);
          lastTemperature[i]=temperature;
        }
      }
    
      delay(dht.getMinimumSamplingPeriod());
    
      //float temperature = dht.getTemperature();
      float temperature = dht.getTemperature()*9/5 + 32;
      if (isnan(temperature)) {
        Serial.println("Failed reading temperature from DHT");
      } 
      else if (temperature != lastTemp) {
        lastTemp = temperature;
        if (!metric) {
          //temperature = dht.toFahrenheit(temperature);
          temperature = dht.getTemperature()*9/5 + 32;
        }
        delay(100);
        gw.send(msgTemp.set(temperature, 1));
        Serial.print("T: ");
        Serial.println(temperature);
      }
    
      float humidity = dht.getHumidity();
      if (isnan(humidity)) {
        Serial.println("Failed reading humidity from DHT");
      } 
      else if (humidity != lastHum) {
        lastHum = humidity;
        delay(100);
        gw.send(msgHum.set(humidity, 1));
        gw.send(msgHum.setDestination(11).set(static_cast<int>(humidity)));
        Serial.print("H: ");
        Serial.println(humidity);
      }
    
      gw.sleep(SLEEP_TIME); //sleep a bit
    }
    
    Development

  • Node to Node Communication
    C cleight

    @Chaotic Thank you, I knew it had to be something simple.

    Development

  • Node to Node Communication
    C cleight

    @Chaotic I missed your code earlier, thank you for this, although while compiling is it saying I am missing a colon before knhum for some reason, need to dig deeper.

    Development

  • Node to Node Communication
    C cleight

    @hek said:

    declare the variable you're sending as int or convert it by casting

    gw.send (msgHum.set(static_cast<int>(humidity)));

    http://www.learncpp.com/cpp-tutorial/44-type-conversion-and-casting/

    @hek Converting my sensor to send the data as an Integer worked and it is now parsing correctly, however I also have a humidity child sensor on that node I would like to send to node 11 as well, how would I capture that in the case statement?

    Development

  • Node to Node Communication
    C cleight

    @hek How do I send it as an integer?

    Development

  • Node to Node Communication
    C cleight

    @hek said:

    @cleight said:

    gw.begin();

    You forgot to initialize begin like you were told above.

    I have this in my gateway.begin

    gw.begin(getVariables, RADIO_ID);
    

    I seem to need to have it this way or Vera doesn't get Node ID 11 anymore and it gets a random generated ID. So then I put the Case statement at the bottom of my getVariables Function.

    Development

  • Node to Node Communication
    C cleight

    @hek This is the code I am using on the sensor side to send to LCD Node (Node 11)

    gw.send(msgHTTemp.setDestination(11).setSensor(i).set(temperature,1));
    

    And in serial monitor on node 11 I see the data being captured correctly, so I believe my issue still lies in my code on the LCD Screen side.

    read: 1-0-11 s=0,c=1,t=0,pt=7,l=5:66.2

    Here is my latest Sketch after I made changes again per Hek's suggestion, only thing is I couldn't use float as I am out of room in my sketch to hard to use INT instead for testTemp

    #define STATES 9
    #define HUMIDITY_SENSOR_DIGITAL_PIN 4
    #define DEBUG
    
    #ifdef DEBUG
    #define DEBUG_SERIAL(x) Serial.begin(x)
    #define DEBUG_PRINT(x) Serial.print(x)
    #define DEBUG_PRINTLN(x) Serial.println(x)
    #else
    #define DEBUG_SERIAL(x)
    #define DEBUG_PRINT(x) 
    #define DEBUG_PRINTLN(x) 
    #endif
    
    #include <avr/pgmspace.h>
    #include <Wire.h>
    #include <Time.h>
    #include <SPI.h>
    #include <MySensor.h>
    #include <LiquidCrystal_I2C.h>
    #include <DS3232RTC.h> 
    //
    #define RADIO_ID 11
    #define CHILD_ID_SCENE 3
    #define CHILD_ID_LED 4
    #define BACKLIGHT 6 //available PWM capable pin
    //Define Additional Nodes that I would like to pull data from
    #define HOTTUB_NODE_ID 1
    //
    LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // set the LCD address to 0x27 for a 16 chars and 2 line display
    //
    void (*lcdDisplay[STATES])();
    //
    byte state = 0;
    byte lastState;
    byte timeCounter = 0;
    int ledStatus = 1;// to toggle LCD backlight led
    int ledLevel = 254;
    unsigned long lastTime;
    unsigned long refreshInterval = 3000UL;
    unsigned long lastClockSet;
    boolean isMessage = false;
    float insideTemperature;
    float humidity;
    int OutdoorTemp = -99;
    int OutdoorHumidity = -99;
    int todayHigh = -99; 
    int todayLow = -99;
    int HotTubTemp = -99;
    int KWH = -99;
    int testTemp = -99;
    String conditions = "Not yet Reported";
    String tomorrowWeather = "Not yet Reported";
    String messageOfTheDay = "**Hello There!**";
    String AlarmStatus = "No Data";
    unsigned long motdTimer;
    boolean buttonPushed = false;
    //
    MySensor gw;
    //
    MyMessage msgOn(CHILD_ID_SCENE, V_SCENE_ON);
    MyMessage msgOff(CHILD_ID_SCENE, V_SCENE_OFF);
    MyMessage msgVAR1(CHILD_ID_SCENE, V_VAR1);// outdoor temperature
    MyMessage msgVAR2(CHILD_ID_SCENE, V_VAR2);// outdoor humidity
    MyMessage msgVAR3(CHILD_ID_SCENE, V_VAR3);//today's low
    MyMessage msgVAR4(CHILD_ID_SCENE, V_VAR4);// today's high
    MyMessage msgVAR5(CHILD_ID_SCENE, V_VAR5);//conditions
    //
    MyMessage lightMsg(CHILD_ID_LED, V_DIMMER);
    MyMessage msgMOTD(CHILD_ID_LED, V_VAR1); // Hot Tub KWH
    MyMessage msgAlarm(CHILD_ID_LED, V_VAR2); // Tomorrow Forecast
    MyMessage msgBrite(CHILD_ID_LED, V_VAR3); 
    MyMessage msgHTTemp(CHILD_ID_LED, V_VAR4); // Hot Tub Temp
    MyMessage msgALARMSTATUS (CHILD_ID_LED, V_VAR5);// Alarm System Status
    void setup()  
    { 
      DEBUG_SERIAL(115200);
      DEBUG_PRINTLN(F("Serial started"));
      //
      lcdDisplay[0] = lcdDisplay0;
      lcdDisplay[1] = lcdDisplay1;
      lcdDisplay[2] = lcdDisplay2;
      lcdDisplay[3] = lcdDisplay3;
      lcdDisplay[4] = lcdDisplay4;
      lcdDisplay[5] = lcdDisplay5;
      lcdDisplay[6] = lcdDisplay6;
      lcdDisplay[7] = lcdDisplay7;
      lcdDisplay[8] = lcdDisplay8;
      //
      pinMode(BACKLIGHT, OUTPUT);
      gw.begin(getVariables, RADIO_ID);
      //gw.begin(NULL, AUTO, true);
      gw.sendSketchInfo("Home Status Panel", "2.1");
      setSyncProvider (RTC.get);
      gw.present(CHILD_ID_SCENE, S_SCENE_CONTROLLER);
      gw.present( CHILD_ID_LED, S_DIMMER);
      //
      analogWrite(BACKLIGHT, 200); //LCD Backlight
      //
      lcd.begin(20,4);
      lcd.clear();
      lcd.backlight();
      lcd.setCursor(0, 0);
      lcd.print("Syncing Time");
      lcd.setCursor(0, 1);
      int clockCounter = 0;
      while(timeStatus() == timeNotSet && clockCounter < 60)
      {
        gw.process();
        gw.requestTime(receiveTime);
        Serial.println("getting Time");
        delay(1000);
        lcd.print(".");
        clockCounter++;
        if (clockCounter > 16)
        {
          lcd.clear();
          lcd.print(F("**Failed Clock**"));
          lcd.setCursor(0,1);
          lcd.print(F("*Syncronization*"));
          delay(2000);
          break;
        }
      }
      lcd.clear();
      lastTime = millis();
    }
    void loop()      
    {
      gw.process();
      if (millis() - lastClockSet >= 60000UL)
      {
        gw.requestTime(receiveTime);
        lastClockSet = millis();
      }
      if (millis() - lastTime >= refreshInterval)
      {
        state++;
        if (state > STATES - 1) state = 0;
        DEBUG_PRINTLN(F("State:")); 
        DEBUG_PRINTLN(state);
        lastTime += refreshInterval;
        getTempHumidity();
      }
      if (state != lastState) 
      {
        fastClear();
        lcdDisplay[state]();
      }
      lastState = state;
      if (isMessage)
      {
        if (millis() - motdTimer > 86400 * 1000UL)
        {
          isMessage = false;
        }
      }
    }
    void fastClear() //Clear LCD Screen
    {
      lcd.setCursor(0,0);
      lcd.clear();
      lcd.setCursor(0,1);
      lcd.clear();
      lcd.setCursor(0,2);
      lcd.clear();
      lcd.setCursor(0,3);
      lcd.clear();
    }
    //
    void lcdDisplay0()
    {
      lcd.setCursor(0,0);
      lcd.print(F("Time: "));
      if (hourFormat12() < 10) lcd.print("0");
      lcd.print(hourFormat12());
      lcd.print(":");
      if (minute() < 10) lcd.print("0");
      lcd.print(minute());
      if (isAM()) lcd.print(F("am"));
      else lcd.print(F("pm"));
      DEBUG_PRINT(F("Time:"));
      DEBUG_PRINTLN(hourFormat12());
      lcd.setCursor(0,1);
      lcd.print(F("Date: "));
      if (month() < 10) lcd.print("0");
      lcd.print(month());
      lcd.print("/");
      if (day() < 10) lcd.print("0");
      lcd.print(day());
      lcd.print("/");
      lcd.print(year());
      DEBUG_PRINTLN(F("Date: ")); 
      DEBUG_PRINT(month()); 
      DEBUG_PRINT("/"); 
      DEBUG_PRINT(day()); 
      DEBUG_PRINT("/"); 
      DEBUG_PRINTLN(year());
    }
    void lcdDisplay1()
    {
      lcd.setCursor(0,0);
      lcd.print(F(" Indoor Temp:"));
      lcd.print(int(round(insideTemperature)));
      lcd.print(char(223));
      DEBUG_PRINT(F("Indoor Temp:")); 
      DEBUG_PRINT(int(round(insideTemperature))); 
      DEBUG_PRINTLN(F("F"));
     }
    void lcdDisplay2()
    {
      lcd.setCursor(0,0);
      lcd.print("Outdoor Temp:"); 
      lcd.print(OutdoorTemp); 
      lcd.print(char(223));
      DEBUG_PRINT(F("Outdoor Temp:"));
      DEBUG_PRINTLN(OutdoorTemp);
      lcd.setCursor(0,1);
      lcd.print(F("    Humidity:")); 
      lcd.print(OutdoorHumidity); 
      lcd.print(F("%"));
      DEBUG_PRINT(F("    Humidity:"));
      DEBUG_PRINTLN(OutdoorHumidity);
    }
    void lcdDisplay3()
    {
      lcd.setCursor(0,0);
      lcd.print(F("Today's High:"));
      lcd.print(todayHigh); 
      lcd.print(char(223));
      DEBUG_PRINT(F("Today's High: "));
      DEBUG_PRINTLN(todayHigh);
      lcd.setCursor(0,1);
      lcd.print(F("         Low:"));
      lcd.print(todayLow); 
      lcd.print(char(223));
      DEBUG_PRINT(F("Today's Low: "));
      DEBUG_PRINTLN(todayLow);
    }
    void lcdDisplay4()
    {
      lcd.setCursor(0,0);
      lcd.print(F("Today's Weather"));
      DEBUG_PRINTLN(F("Today's Weather: "));
      lcd.setCursor(0,1);
      lcd.print(conditions);
      DEBUG_PRINTLN(conditions);
    }
    void lcdDisplay5()
    {
      lcd.setCursor(0,0);
      lcd.print(F("Forcast Tomorrow"));
      DEBUG_PRINTLN(F("Tomorrow's Forecast: "));
      lcd.setCursor(0,1);
      lcd.print(tomorrowWeather);
      DEBUG_PRINTLN(tomorrowWeather);
    }
    void lcdDisplay6()
    {
      if (isMessage)
      {
        lcd.setCursor(0,0);
        lcd.print(F("**NEW  MESSAGE**"));
        DEBUG_PRINTLN(F("****Message****"));
        lcd.setCursor(0,1);
        lcd.print(messageOfTheDay);
        DEBUG_PRINTLN(messageOfTheDay);
        motdTimer = millis();
      }
      else
      {
        lcd.setCursor(0,0);
        lcd.print(F("****Welcome!****"));
        DEBUG_PRINTLN(F("****Message****"));
        lcd.setCursor(0,1);
        lcd.print(F("Have a Nice Day!"));
        DEBUG_PRINTLN(F("Have a Nice Day"));
      }
    }
    void lcdDisplay7()
    {
      lcd.setCursor(0,1);
      lcd.print("Alarm Status:");  
      DEBUG_PRINT("Alarm Status:");
      DEBUG_PRINTLN(AlarmStatus);
      lcd.setCursor(0,2);
      lcd.print(AlarmStatus);
    }
    void lcdDisplay8()
    {
      lcd.setCursor(0,0);
      lcd.print("Hot Tub KWH:");
      lcd.print(KWH);
      DEBUG_PRINT("Hot Tub KWH:");
      DEBUG_PRINTLN(KWH);
      lcd.setCursor(0,1);
      lcd.print(F(" Hot Tub:"));
      lcd.print(HotTubTemp);
      lcd.print(char(223));
      DEBUG_PRINT(F("Hot Tub:"));
      DEBUG_PRINT(HotTubTemp);
      DEBUG_PRINT(F("F"));
      lcd.setCursor(3,0);
      lcd.print("Test Temp:");
      lcd.print(testTemp);
      lcd.print(char(223));
      DEBUG_PRINT(F("Test Temp:"));
      DEBUG_PRINTLN(testTemp);
    }
    //
    void getTempHumidity()
    {
      insideTemperature = ((RTC.temperature()/4*9/5 + 32));
      if (isnan(insideTemperature)) 
      {
        DEBUG_PRINTLN(F("Failed reading temperature from RTC"));
      } 
    }
    //
    void receiveTime(unsigned long controllerTime)
    {
      // Ok, set imcoming time
      DEBUG_PRINTLN(F("Time value received: "));
      DEBUG_PRINTLN(controllerTime);
      RTC.set(controllerTime);
      controllerTime = true;
    }
    //
    void getVariables(const MyMessage &message)
    {
      if (message.sensor == CHILD_ID_SCENE)
      { 
        if (message.type == V_VAR1) //Outdoor temp pulled from Weather Underground Vera Plugin
        {
          OutdoorTemp = atoi(message.data);
          DEBUG_PRINTLN(F("OutdoorTemp recieved:"));
          DEBUG_PRINTLN(OutdoorTemp);
        }
        if (message.type == V_VAR2) //Outdoor Humidity pulled from Weather Underground Vera Plugin
        {
          OutdoorHumidity = atoi(message.data);
          DEBUG_PRINT(F("OutdoorHumidity recieved:"));
          DEBUG_PRINTLN(OutdoorHumidity);
        }
        if (message.type == V_VAR3) //pulled from Weather Underground Vera Plugin
        {
          todayLow = atoi(message.data);
          DEBUG_PRINT(F("Received Today's LOW:"));
          DEBUG_PRINTLN(todayLow);
        }
    
        if (message.type == V_VAR4) //pulled from Weather Underground Vera Plugin
        {
          todayHigh = atoi(message.data);
          DEBUG_PRINT(F("Received Today's HIGH:"));
          DEBUG_PRINTLN(todayHigh);
        }
        if (message.type == V_VAR5) //pulled from Weather Underground Vera Plugin
        {
          String newMessage = String(message.data);
          int locator = newMessage.indexOf("@");
          newMessage = newMessage.substring(0, locator);
          conditions = newMessage;
          DEBUG_PRINT(F("Received today's Conditions:"));
          DEBUG_PRINTLN(conditions);
        }
      }
        if (message.sensor == CHILD_ID_LED)
      {
        if (message.type == V_DIMMER) //Set LCD Brightness from Dimmer Device in Vera
        {
          ledLevel = message.getByte();
          		lcd.setBacklight(ledLevel);
    		Serial.print("Brightness Level recieved:");
    		Serial.println(ledLevel);
                    analogWrite(BACKLIGHT, (int)(ledLevel / 100. * 255) );                
        }
        if (message.type == V_VAR1) //Hot Tub KWN Hours
        {
          KWH = atoi(message.data);
          DEBUG_PRINT("Hot Tub KWH recieved:");
          DEBUG_PRINTLN(KWH);
        }
        if (message.type == V_VAR2) //pulled from Weather Underground Vera Plugin
        {
          // Extended Forecast
          String newMessage = String(message.data);
          int locator = newMessage.indexOf("@");
          newMessage = newMessage.substring(0, locator);
          tomorrowWeather = newMessage;
          DEBUG_PRINT(F("Received Two Day Forecast:"));
          DEBUG_PRINTLN(tomorrowWeather);
        }
        if (message.type == V_VAR3) //Not sure what this will be used for just yet
        {
          // message of the day
          String newMessage = String(message.data);
          int locator = newMessage.indexOf("@");
          newMessage = newMessage.substring(0, locator);
          messageOfTheDay = newMessage;
          DEBUG_PRINT(F("Received Message of the Day:"));
          DEBUG_PRINTLN(messageOfTheDay);
          isMessage = true;
        }
        if (message.type == V_VAR4) //Hot Tub Temp from Vera which comes from an Arduino
        {
          HotTubTemp = atoi(message.data);
          DEBUG_PRINT(F("Received HotTubTemp:"));
          DEBUG_PRINTLN(HotTubTemp);
        }
        if (message.type == V_VAR5) //Check on Alarm status
        {
        String newMessage = String(message.data);
          int locator = newMessage.indexOf("@");
          newMessage = newMessage.substring(0, locator);
          AlarmStatus = newMessage;
          DEBUG_PRINT(F("Received Alarm Status:"));
          DEBUG_PRINTLN(AlarmStatus); 
        } 
      }
       switch (message.sender) {
            case HOTTUB_NODE_ID:
                 testTemp = atoi(message.data);
                 break;
          }
    }
    

    Node ID 1 - Temperature Sensor that is sending to Node 11 (LCD Screen)

    #include <SPI.h>
    #include <MySensor.h>  
    #include <DHT.h>
    #include <DallasTemperature.h>
    #include <OneWire.h>
    
    #define CHILD_ID_HUM 1
    #define CHILD_ID_TEMP 2
    #define CHILD_ID_HTTEMP 3
    #define HUMIDITY_SENSOR_DIGITAL_PIN 3
    //Waterproof Sensor addition
    #define ONE_WIRE_BUS 4 //Pin where waterproof temp sensor is connected
    #define MAX_ATTACHED_DS18B20 16
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    OneWire oneWire(ONE_WIRE_BUS);
    DallasTemperature sensors(&oneWire);
    
    MySensor gw;
    DHT dht;
    float lastTemperature[MAX_ATTACHED_DS18B20];
    int numSensors=0;
    boolean receivedConfig = false;
    float lastTemp;
    float lastHum;
    boolean metric = false; 
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgHTTemp(CHILD_ID_HTTEMP, V_TEMP);
    
    void setup()  
    { 
      // Startup OneWire
      sensors.begin();
    
      gw.begin();
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
    
      // Send the Sketch Version Information to the Gateway
      gw.sendSketchInfo("Hot Tub Monitor", "2.0");
    
      // Fetch the number of attached temperature sensors
      numSensors = sensors.getDeviceCount();
    
      // Present all sensors to controller
      for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
        gw.present(i, S_TEMP);
      }
    
      // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID_HUM, S_HUM);
      gw.present(CHILD_ID_TEMP, S_TEMP);
    
      metric = gw.getConfig().isMetric;
    }
    
    void loop()      
    {  
      // Process incoming messages (like config from server)
      gw.process();
    
      //Fetch temperatures from Dallas sensors
      sensors.requestTemperatures();
    
      // Red temperatures and send them to the controller
      for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
    
        // Fetch and round temperature to one decimal
        float temperature = static_cast<float>(static_cast<int>((sensors.getTempFByIndex(i)) * 10.)) / 10.;
    
        //Only send data if temperature has changed and no error
        if (lastTemperature[i] != temperature && temperature != -127.00) {
    
          // Send in the new temperature
          delay(100);
          gw.send(msgHTTemp.setSensor(i).set(temperature,1));
          gw.send(msgHTTemp.setDestination(11).setSensor(i).set(temperature,1));
          Serial.print("T2: ");
          Serial.println(temperature);
          lastTemperature[i]=temperature;
        }
      }
    
      delay(dht.getMinimumSamplingPeriod());
    
      //float temperature = dht.getTemperature();
      float temperature = dht.getTemperature()*9/5 + 32;
      if (isnan(temperature)) {
        Serial.println("Failed reading temperature from DHT");
      } 
      else if (temperature != lastTemp) {
        lastTemp = temperature;
        if (!metric) {
          //temperature = dht.toFahrenheit(temperature);
          temperature = dht.getTemperature()*9/5 + 32;
        }
        delay(100);
        gw.send(msgTemp.set(temperature, 1));
        Serial.print("T: ");
        Serial.println(temperature);
      }
    
      float humidity = dht.getHumidity();
      if (isnan(humidity)) {
        Serial.println("Failed reading humidity from DHT");
      } 
      else if (humidity != lastHum) {
        lastHum = humidity;
        delay(100);
        gw.send(msgHum.set(humidity, 1));
        Serial.print("H: ");
        Serial.println(humidity);
      }
    
      gw.sleep(SLEEP_TIME); //sleep a bit
    }
    
    Development

  • Node to Node Communication
    C cleight

    @Chaotic I understand what you are saying and have the concept down of the message being sent to the gateway. What I don't understand is the code that Hek provided and how I seperate Node ID 1 Child Sensor 0 (temp Sensor) from Node ID 1 Child Sensor 1 (Humidity Sensor)

    Also I tried the code Hek provided but I cannot use Float to store the variable as I am out of room in my sketch, I tried changing to message.getInt(); without luck.

    Development

  • Node to Node Communication
    C cleight

    @hek Thank you for the example, one thing I am still confused on though is if all my nodes have child ID's of 0 and 1 that the code you presented above doesn't care about the Child sensor only the Node ID correct?

    @Chaotic: I have read the API documentation about 100 times and I don't correlate it to what I want, I unfortunately do not have a programming background and what I have learned so far is by other users examples or trial and error.

    Development

  • Node to Node Communication
    C cleight

    @Chaotic I understand what your saying as well as what @AWI is saying but I don't think everyone understands what I am trying to do. I would like to capture several node's child sensors data and use it on my LCD Screen to show me instant status of sensors. If I use code like the relay example how do I tell it which node and child sensor I want to capture the data from?

    void incomingMessage(const MyMessage &message) {
          if (message.type == V_TEMP)
          {
            testTemp = atoi(message.data);
          DEBUG_PRINTLN(F("Test Temp recieved:"));
          DEBUG_PRINTLN(testTemp);
          }
      }
    

    ^That code, per the relay sketch example doesn't allow me to specify I want data from Node 1, Child Sensor 0.

    Here is my full sketch I am currently working on:

    #define STATES 9
    #define HUMIDITY_SENSOR_DIGITAL_PIN 4
    #define DEBUG
    
    #ifdef DEBUG
    #define DEBUG_SERIAL(x) Serial.begin(x)
    #define DEBUG_PRINT(x) Serial.print(x)
    #define DEBUG_PRINTLN(x) Serial.println(x)
    #else
    #define DEBUG_SERIAL(x)
    #define DEBUG_PRINT(x) 
    #define DEBUG_PRINTLN(x) 
    #endif
    
    #include <avr/pgmspace.h>
    #include <Wire.h>
    #include <Time.h>
    #include <SPI.h>
    #include <MySensor.h>
    #include <LiquidCrystal_I2C.h>
    #include <DS3232RTC.h> 
    //
    #define RADIO_ID 11
    #define CHILD_ID_SCENE 3
    #define CHILD_ID_LED 4
    #define BACKLIGHT 6 //available PWM capable pin
    
    //
    LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // set the LCD address to 0x27 for a 16 chars and 2 line display
    //
    void (*lcdDisplay[STATES])();
    //
    byte state = 0;
    byte lastState;
    byte timeCounter = 0;
    int ledStatus = 1;// to toggle LCD backlight led
    int ledLevel = 254;
    unsigned long lastTime;
    unsigned long refreshInterval = 3000UL;
    unsigned long lastClockSet;
    boolean isMessage = false;
    float insideTemperature;
    float humidity;
    int OutdoorTemp = -99;
    int OutdoorHumidity = -99;
    int todayHigh = -99; 
    int todayLow = -99;
    int HotTubTemp = -99;
    int KWH = -99;
    int testTemp = -99;
    String conditions = "Not yet Reported";
    String tomorrowWeather = "Not yet Reported";
    String messageOfTheDay = "**Hello There!**";
    String AlarmStatus = "No Data";
    unsigned long motdTimer;
    boolean buttonPushed = false;
    //
    MySensor gw;
    //
    MyMessage msgOn(CHILD_ID_SCENE, V_SCENE_ON);
    MyMessage msgOff(CHILD_ID_SCENE, V_SCENE_OFF);
    MyMessage msgVAR1(CHILD_ID_SCENE, V_VAR1);// outdoor temperature
    MyMessage msgVAR2(CHILD_ID_SCENE, V_VAR2);// outdoor humidity
    MyMessage msgVAR3(CHILD_ID_SCENE, V_VAR3);//today's low
    MyMessage msgVAR4(CHILD_ID_SCENE, V_VAR4);// today's high
    MyMessage msgVAR5(CHILD_ID_SCENE, V_VAR5);//conditions
    //
    MyMessage lightMsg(CHILD_ID_LED, V_DIMMER);
    MyMessage msgMOTD(CHILD_ID_LED, V_VAR1); // Hot Tub KWH
    MyMessage msgAlarm(CHILD_ID_LED, V_VAR2); // Tomorrow Forecast
    MyMessage msgBrite(CHILD_ID_LED, V_VAR3); 
    MyMessage msgHTTemp(CHILD_ID_LED, V_VAR4); // Hot Tub Temp
    MyMessage msgALARMSTATUS (CHILD_ID_LED, V_VAR5);// Alarm System Status
    void setup()  
    { 
      DEBUG_SERIAL(115200);
      DEBUG_PRINTLN(F("Serial started"));
      //
      lcdDisplay[0] = lcdDisplay0;
      lcdDisplay[1] = lcdDisplay1;
      lcdDisplay[2] = lcdDisplay2;
      lcdDisplay[3] = lcdDisplay3;
      lcdDisplay[4] = lcdDisplay4;
      lcdDisplay[5] = lcdDisplay5;
      lcdDisplay[6] = lcdDisplay6;
      lcdDisplay[7] = lcdDisplay7;
      lcdDisplay[8] = lcdDisplay8;
      //
      pinMode(BACKLIGHT, OUTPUT);
      gw.begin(getVariables, RADIO_ID);
      //gw.begin(NULL, AUTO, true);
      gw.sendSketchInfo("Home Status Panel", "2.1");
      setSyncProvider (RTC.get);
      gw.present(CHILD_ID_SCENE, S_SCENE_CONTROLLER);
      gw.present( CHILD_ID_LED, S_DIMMER);
      //
      analogWrite(BACKLIGHT, 200); //LCD Backlight
      //
      lcd.begin(20,4);
      lcd.clear();
      lcd.backlight();
      lcd.setCursor(0, 0);
      lcd.print("Syncing Time");
      lcd.setCursor(0, 1);
      int clockCounter = 0;
      while(timeStatus() == timeNotSet && clockCounter < 60)
      {
        gw.process();
        gw.requestTime(receiveTime);
        Serial.println("getting Time");
        delay(1000);
        lcd.print(".");
        clockCounter++;
        if (clockCounter > 16)
        {
          lcd.clear();
          lcd.print(F("**Failed Clock**"));
          lcd.setCursor(0,1);
          lcd.print(F("*Syncronization*"));
          delay(2000);
          break;
        }
      }
      lcd.clear();
      lastTime = millis();
    }
    void loop()      
    {
      gw.process();
      if (millis() - lastClockSet >= 60000UL)
      {
        gw.requestTime(receiveTime);
        lastClockSet = millis();
      }
      if (millis() - lastTime >= refreshInterval)
      {
        state++;
        if (state > STATES - 1) state = 0;
        DEBUG_PRINTLN(F("State:")); 
        DEBUG_PRINTLN(state);
        lastTime += refreshInterval;
        getTempHumidity();
      }
      if (state != lastState) 
      {
        fastClear();
        lcdDisplay[state]();
      }
      lastState = state;
      if (isMessage)
      {
        if (millis() - motdTimer > 86400 * 1000UL)
        {
          isMessage = false;
        }
      }
    }
    void fastClear() //Clear LCD Screen
    {
      lcd.setCursor(0,0);
      lcd.clear();
      lcd.setCursor(0,1);
      lcd.clear();
      lcd.setCursor(0,2);
      lcd.clear();
      lcd.setCursor(0,3);
      lcd.clear();
    }
    //
    void lcdDisplay0()
    {
      lcd.setCursor(0,0);
      lcd.print(F("Time: "));
      if (hourFormat12() < 10) lcd.print("0");
      lcd.print(hourFormat12());
      lcd.print(":");
      if (minute() < 10) lcd.print("0");
      lcd.print(minute());
      if (isAM()) lcd.print(F("am"));
      else lcd.print(F("pm"));
      DEBUG_PRINT(F("Time:"));
      DEBUG_PRINTLN(hourFormat12());
      lcd.setCursor(0,1);
      lcd.print(F("Date: "));
      if (month() < 10) lcd.print("0");
      lcd.print(month());
      lcd.print("/");
      if (day() < 10) lcd.print("0");
      lcd.print(day());
      lcd.print("/");
      lcd.print(year());
      DEBUG_PRINTLN(F("Date: ")); 
      DEBUG_PRINT(month()); 
      DEBUG_PRINT("/"); 
      DEBUG_PRINT(day()); 
      DEBUG_PRINT("/"); 
      DEBUG_PRINTLN(year());
    }
    void lcdDisplay1()
    {
      lcd.setCursor(0,0);
      lcd.print(F(" Indoor Temp:"));
      lcd.print(int(round(insideTemperature)));
      lcd.print(char(223));
      DEBUG_PRINT(F("Indoor Temp:")); 
      DEBUG_PRINT(int(round(insideTemperature))); 
      DEBUG_PRINTLN(F("F"));
     }
    void lcdDisplay2()
    {
      lcd.setCursor(0,0);
      lcd.print("Outdoor Temp:"); 
      lcd.print(OutdoorTemp); 
      lcd.print(char(223));
      DEBUG_PRINT(F("Outdoor Temp:"));
      DEBUG_PRINTLN(OutdoorTemp);
      lcd.setCursor(0,1);
      lcd.print(F("    Humidity:")); 
      lcd.print(OutdoorHumidity); 
      lcd.print(F("%"));
      DEBUG_PRINT(F("    Humidity:"));
      DEBUG_PRINTLN(OutdoorHumidity);
    }
    void lcdDisplay3()
    {
      lcd.setCursor(0,0);
      lcd.print(F("Today's High:"));
      lcd.print(todayHigh); 
      lcd.print(char(223));
      DEBUG_PRINT(F("Today's High: "));
      DEBUG_PRINTLN(todayHigh);
      lcd.setCursor(0,1);
      lcd.print(F("         Low:"));
      lcd.print(todayLow); 
      lcd.print(char(223));
      DEBUG_PRINT(F("Today's Low: "));
      DEBUG_PRINTLN(todayLow);
    }
    void lcdDisplay4()
    {
      lcd.setCursor(0,0);
      lcd.print(F("Today's Weather"));
      DEBUG_PRINTLN(F("Today's Weather: "));
      lcd.setCursor(0,1);
      lcd.print(conditions);
      DEBUG_PRINTLN(conditions);
    }
    void lcdDisplay5()
    {
      lcd.setCursor(0,0);
      lcd.print(F("Forcast Tomorrow"));
      DEBUG_PRINTLN(F("Tomorrow's Forecast: "));
      lcd.setCursor(0,1);
      lcd.print(tomorrowWeather);
      DEBUG_PRINTLN(tomorrowWeather);
    }
    void lcdDisplay6()
    {
      if (isMessage)
      {
        lcd.setCursor(0,0);
        lcd.print(F("**NEW  MESSAGE**"));
        DEBUG_PRINTLN(F("****Message****"));
        lcd.setCursor(0,1);
        lcd.print(messageOfTheDay);
        DEBUG_PRINTLN(messageOfTheDay);
        motdTimer = millis();
      }
      else
      {
        lcd.setCursor(0,0);
        lcd.print(F("****Welcome!****"));
        DEBUG_PRINTLN(F("****Message****"));
        lcd.setCursor(0,1);
        lcd.print(F("Have a Nice Day!"));
        DEBUG_PRINTLN(F("Have a Nice Day"));
      }
    }
    void lcdDisplay7()
    {
      lcd.setCursor(0,1);
      lcd.print("Alarm Status:");  
      DEBUG_PRINT("Alarm Status:");
      DEBUG_PRINTLN(AlarmStatus);
      lcd.setCursor(0,2);
      lcd.print(AlarmStatus);
    }
    void lcdDisplay8()
    {
      lcd.setCursor(0,0);
      lcd.print("Hot Tub KWH:");
      lcd.print(KWH);
      DEBUG_PRINT("Hot Tub KWH:");
      DEBUG_PRINTLN(KWH);
      lcd.setCursor(0,1);
      lcd.print(F(" Hot Tub:"));
      lcd.print(HotTubTemp);
      lcd.print(char(223));
      DEBUG_PRINT(F("Hot Tub:"));
      DEBUG_PRINT(HotTubTemp);
      DEBUG_PRINT(F("F"));
      lcd.setCursor(3,0);
      lcd.print("Test Temp:");
      lcd.print(testTemp);
      lcd.print(char(223));
      DEBUG_PRINT(F("Test Temp:"));
      DEBUG_PRINTLN(testTemp);
    }
    //
    void getTempHumidity()
    {
      insideTemperature = ((RTC.temperature()/4*9/5 + 32));
      if (isnan(insideTemperature)) 
      {
        DEBUG_PRINTLN(F("Failed reading temperature from RTC"));
      } 
    }
    //
    void receiveTime(unsigned long controllerTime)
    {
      // Ok, set imcoming time
      DEBUG_PRINTLN(F("Time value received: "));
      DEBUG_PRINTLN(controllerTime);
      RTC.set(controllerTime);
      controllerTime = true;
    }
    //
    void incomingMessage(const MyMessage &message) {
          if (message.type == V_TEMP)
          {
            testTemp = atoi(message.data);
          DEBUG_PRINTLN(F("Test Temp recieved:"));
          DEBUG_PRINTLN(testTemp);
          }
      }
    
    void getVariables(const MyMessage &message)
    {
      if (message.sensor == CHILD_ID_SCENE)
      { 
        if (message.type == V_VAR1) //Outdoor temp pulled from Weather Underground Vera Plugin
        {
          OutdoorTemp = atoi(message.data);
          DEBUG_PRINTLN(F("OutdoorTemp recieved:"));
          DEBUG_PRINTLN(OutdoorTemp);
        }
        if (message.type == V_VAR2) //Outdoor Humidity pulled from Weather Underground Vera Plugin
        {
          OutdoorHumidity = atoi(message.data);
          DEBUG_PRINT(F("OutdoorHumidity recieved:"));
          DEBUG_PRINTLN(OutdoorHumidity);
        }
        if (message.type == V_VAR3) //pulled from Weather Underground Vera Plugin
        {
          todayLow = atoi(message.data);
          DEBUG_PRINT(F("Received Today's LOW:"));
          DEBUG_PRINTLN(todayLow);
        }
    
        if (message.type == V_VAR4) //pulled from Weather Underground Vera Plugin
        {
          todayHigh = atoi(message.data);
          DEBUG_PRINT(F("Received Today's HIGH:"));
          DEBUG_PRINTLN(todayHigh);
        }
        if (message.type == V_VAR5) //pulled from Weather Underground Vera Plugin
        {
          String newMessage = String(message.data);
          int locator = newMessage.indexOf("@");
          newMessage = newMessage.substring(0, locator);
          conditions = newMessage;
          DEBUG_PRINT(F("Received today's Conditions:"));
          DEBUG_PRINTLN(conditions);
        }
      }
        if (message.sensor == CHILD_ID_LED)
      {
        if (message.type == V_DIMMER) //Set LCD Brightness from Dimmer Device in Vera
        {
          ledLevel = message.getByte();
          		lcd.setBacklight(ledLevel);
    		Serial.print("Brightness Level recieved:");
    		Serial.println(ledLevel);
                    analogWrite(BACKLIGHT, (int)(ledLevel / 100. * 255) );                
        }
        if (message.type == V_VAR1) //Hot Tub KWN Hours
        {
          KWH = atoi(message.data);
          DEBUG_PRINT("Hot Tub KWH recieved:");
          DEBUG_PRINTLN(KWH);
        }
        if (message.type == V_VAR2) //pulled from Weather Underground Vera Plugin
        {
          // Extended Forecast
          String newMessage = String(message.data);
          int locator = newMessage.indexOf("@");
          newMessage = newMessage.substring(0, locator);
          tomorrowWeather = newMessage;
          DEBUG_PRINT(F("Received Two Day Forecast:"));
          DEBUG_PRINTLN(tomorrowWeather);
        }
        if (message.type == V_VAR3) //Not sure what this will be used for just yet
        {
          // message of the day
          String newMessage = String(message.data);
          int locator = newMessage.indexOf("@");
          newMessage = newMessage.substring(0, locator);
          messageOfTheDay = newMessage;
          DEBUG_PRINT(F("Received Message of the Day:"));
          DEBUG_PRINTLN(messageOfTheDay);
          isMessage = true;
        }
        if (message.type == V_VAR4) //Hot Tub Temp from Vera which comes from an Arduino
        {
          HotTubTemp = atoi(message.data);
          DEBUG_PRINT(F("Received HotTubTemp:"));
          DEBUG_PRINTLN(HotTubTemp);
        }
        if (message.type == V_VAR5) //Check on Alarm status
        {
        String newMessage = String(message.data);
          int locator = newMessage.indexOf("@");
          newMessage = newMessage.substring(0, locator);
          AlarmStatus = newMessage;
          DEBUG_PRINT(F("Received Alarm Status:"));
          DEBUG_PRINTLN(AlarmStatus); 
        } 
      }
    }
    
    Development
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular