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
  1. Home
  2. My Project
  3. [n00b]]Ethernet GW - without NF24

[n00b]]Ethernet GW - without NF24

Scheduled Pinned Locked Moved My Project
31 Posts 4 Posters 15.2k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brix7be
    wrote on last edited by
    #14

    You are right, it blocks when i call sendSketchInfo directly (without to be an attribute of gw) !?!

    1 Reply Last reply
    0
    • B Offline
      B Offline
      brix7be
      wrote on last edited by brix7be
      #15

      Here is the merged code
      Thanks for the advices

      // BELOW the gateway W5100 sketch
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      // Enable and select radio type attached
      //#define MY_RADIO_NRF24 
      //#define MY_RADIO_RFM69 // I DONT WANT TO USE THE RADIO MODULE
      
      // Enable gateway ethernet module type 
      #define MY_GATEWAY_W5100
      
      // 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)
      //  #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
      //#define MY_RF24_CE_PIN 5
      //#define MY_RF24_CS_PIN 6
      
      // Enable to UDP          
      //#define MY_USE_UDP
      
      //#define MY_IP_ADDRESS 192,168,1,100   // If this is disabled, DHCP is used to retrieve address
      // Renewal period if using DHCP
      //#define MY_IP_RENEWAL_INTERVAL 60000
      // The port to keep open on node server mode / or port to contact in client mode
      //#define MY_PORT 5003 
           
      #define IP_PORT 5003        // The port you want to open 
      IPAddress myIp (192, 168, 1, 100);  // Configure your static ip-address here    COMPILE ERROR HERE? Use Arduino IDE 1.5.7 or later!
      
      // Controller ip address. Enables client mode (default is "server" mode). 
      // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. 
      //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254   
       
      // 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.
      //#define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
      
      // 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();
      
      // 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 
      
      //#define MY_DEFAULT_ERR_LED_PIN 7  // Error led pin
      //#define MY_DEFAULT_RX_LED_PIN  8  // Receive led pin
      //#define MY_DEFAULT_TX_LED_PIN  9  // the PCB, on board LED
      
      #include <SPI.h>
      
      #if defined(MY_USE_UDP)
        #include <EthernetUdp.h>
      #endif
      #include <Ethernet.h>
      #include <MySensor.h>
      
      
      //-------------------------------------------------------------
      //Below the Dallas temp sketch
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      // Enable and select radio type attached
      //#define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      
      #include <SPI.h>
      #include <MySensor.h>  
      #include <DallasTemperature.h>
      #include <OneWire.h>
      
      #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
      
      #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
      #define MAX_ATTACHED_DS18B20 16
      unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
      OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
      DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. 
      float lastTemperature[MAX_ATTACHED_DS18B20];
      int numSensors=0;
      boolean receivedConfig = false;
      boolean metric = true; 
      // Initialize temperature message
      MyMessage msg(0,V_TEMP);
      
      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()  
      { 
        // ////Prepare the ethernet connection 
        Ethernet.begin(mac, myIp);
      
        // Startup up the OneWire library
        sensors.begin();
        // requestTemperatures() will not block current thread
        sensors.setWaitForConversion(false);
      }
      
      void presentation() {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Temperature Sensor", "1.1");
      
        // 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++) {   
           present(i, S_TEMP);
        }
      }
      
      void loop()     
      {     
        // Fetch temperatures from Dallas sensors
        sensors.requestTemperatures();
      
        // query conversion time and sleep until conversion completed
        int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
        // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
        sleep(conversionTime);
      
        // Read temperatures and send them to 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>((getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
       
          // Only send data if temperature has changed and no error
          #if COMPARE_TEMP == 1
          if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
          #else
          if (temperature != -127.00 && temperature != 85.00) {
          #endif
       
            // Send in the new temperature
            send(msg.setSensor(i).set(temperature,1));
            // Save new temperatures for next compare
            lastTemperature[i]=temperature;
          }
        }
        sleep(SLEEP_TIME);
      }
      
      1 Reply Last reply
      0
      • hekH Offline
        hekH Offline
        hek
        Admin
        wrote on last edited by
        #16

        Looks like you added your own stuff..

        @brix7be said:

        IPAddress myIp (192, 168, 1, 100); // Configure your static ip-address here COMPILE ERROR HERE? Use Arduino IDE 1.5.7 or later!

        Should simply be
        #define MY_IP_ADDRESS 192, 168, 1, 100 // If this is disabled, DHCP is used to retrieve address

        And what the following doing here?

        // a R/W server on the port
        EthernetServer server = EthernetServer(IP_PORT);
        // handle to open connection
        EthernetClient client = EthernetClient();
        

        And you include <SPI.h> and <MySensor.h> twice.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          brix7be
          wrote on last edited by
          #17

          to be honnest, i don't know ...

          1 Reply Last reply
          0
          • B Offline
            B Offline
            brix7be
            wrote on last edited by
            #18

            With the #define MY_IP_ADDRESS i can't compile the projet.
            With the arduino command it works now, i can ping it on 192.168.1.100.
            But still nothing in domoticz.
            Am I on the right way?
            thanks again :-)

            // BELOW the gateway W5100 sketch
            
            // Enable debug prints to serial monitor
            #define MY_DEBUG 
            
            // Enable gateway ethernet module type 
            #define MY_GATEWAY_W5100
            
            // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
            //#define MY_W5100_SPI_EN 4  
            
            // Enable to UDP          
            //#define MY_USE_UDP
            
            //#define MY_IP_ADDRESS 192,168,1,100   // If this is disabled, DHCP is used to retrieve address
            byte ip[] = { 192, 168, 1, 100 }; 
            // Renewal period if using DHCP
            //#define MY_IP_RENEWAL_INTERVAL 60000
            // The port to keep open on node server mode / or port to contact in client mode
            #define MY_PORT 5003 
            
            // Controller ip address. Enables client mode (default is "server" mode). 
            // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. 
            //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254   
             
            // 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.
            //#define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
            byte mac [] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
            
            #include <SPI.h>
            #if defined(MY_USE_UDP)
              #include <EthernetUdp.h>
            #endif
            #include <Ethernet.h>
            #include <MySensor.h>
            
            //-------------------------------------------------------------
            //Below the Dallas temp sketch
            
            #include <DallasTemperature.h>
            #include <OneWire.h>
            
            #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
            
            #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
            #define MAX_ATTACHED_DS18B20 16
            unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
            OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
            DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. 
            float lastTemperature[MAX_ATTACHED_DS18B20];
            int numSensors=0;
            boolean receivedConfig = false;
            boolean metric = true; 
            // Initialize temperature message
            MyMessage msg(0,V_TEMP);
            
            void setup()  
            { 
              // ////Prepare the ethernet connection 
              Ethernet.begin(mac , ip);
              wait(1000);
              
                // Startup up the OneWire library
              sensors.begin();
              // requestTemperatures() will not block current thread
              sensors.setWaitForConversion(false);
            
            }
            
            void presentation() {
              // Send the sketch version information to the gateway and Controller
              sendSketchInfo("Temperature Sensor", "1.1");
            
              // 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++) {   
                 present(i, S_TEMP);
              }
            }
            
            void loop()     
            {     
              // Fetch temperatures from Dallas sensors
              sensors.requestTemperatures();
            
              // query conversion time and sleep until conversion completed
              int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
              // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
              sleep(conversionTime);
            
              // Read temperatures and send them to 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>((getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
             
                // Only send data if temperature has changed and no error
                #if COMPARE_TEMP == 1
                if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
                #else
                if (temperature != -127.00 && temperature != 85.00) {
                #endif
             
                  // Send in the new temperature
                  send(msg.setSensor(i).set(temperature,1));
                  // Save new temperatures for next compare
                  lastTemperature[i]=temperature;
                }
              }
              sleep(SLEEP_TIME);
            }
            
            1 Reply Last reply
            0
            • hekH Offline
              hekH Offline
              hek
              Admin
              wrote on last edited by
              #19

              I don't understand.. why do you declare ip and mac like that? It most surely isn't picked up by the library. You're probably just getting an ip from your DHCP server.

              What compile error do you get when using the defines?

              1 Reply Last reply
              0
              • B Offline
                B Offline
                brix7be
                wrote on last edited by brix7be
                #20

                i've changed as before and it won't compile.
                The error is:
                no matching function for call to 'EthernetClass::begin(int, int, int, int, int, int, int, int, int, int)'
                No it takes the ip I put on the code before, cause the ping respond at this one.
                Thks

                // BELOW the gateway W5100 sketch
                
                // Enable debug prints to serial monitor
                #define MY_DEBUG 
                
                // Enable gateway ethernet module type 
                #define MY_GATEWAY_W5100
                
                // W5100 Ethernet module SPI enable (optional if using a shield/module that manages SPI_EN signal)
                //#define MY_W5100_SPI_EN 4  
                
                // Enable to UDP          
                //#define MY_USE_UDP
                
                #define MY_IP_ADDRESS 192,168,1,100   // If this is disabled, DHCP is used to retrieve address
                //byte ip[] = { 192, 168, 1, 100 }; 
                // Renewal period if using DHCP
                //#define MY_IP_RENEWAL_INTERVAL 60000
                // The port to keep open on node server mode / or port to contact in client mode
                #define MY_PORT 5003 
                
                // Controller ip address. Enables client mode (default is "server" mode). 
                // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. 
                //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254   
                 
                // 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.
                #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
                //byte mac [] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
                
                #include <SPI.h>
                #if defined(MY_USE_UDP)
                  #include <EthernetUdp.h>
                #endif
                #include <Ethernet.h>
                #include <MySensor.h>
                
                //-------------------------------------------------------------
                //Below the Dallas temp sketch
                
                #include <DallasTemperature.h>
                #include <OneWire.h>
                
                #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
                
                #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
                #define MAX_ATTACHED_DS18B20 16
                unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
                OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
                DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. 
                float lastTemperature[MAX_ATTACHED_DS18B20];
                int numSensors=0;
                boolean receivedConfig = false;
                boolean metric = true; 
                // Initialize temperature message
                MyMessage msg(0,V_TEMP);
                
                void setup()  
                { 
                  // ////Prepare the ethernet connection 
                  Ethernet.begin(MY_MAC_ADDRESS , MY_IP_ADDRESS);
                  wait(1000);
                  
                    // Startup up the OneWire library
                  sensors.begin();
                  // requestTemperatures() will not block current thread
                  sensors.setWaitForConversion(false);
                
                }
                
                void presentation() {
                  // Send the sketch version information to the gateway and Controller
                  sendSketchInfo("Temperature Sensor", "1.1");
                
                  // 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++) {   
                     present(i, S_TEMP);
                  }
                }
                
                void loop()     
                {     
                  // Fetch temperatures from Dallas sensors
                  sensors.requestTemperatures();
                
                  // query conversion time and sleep until conversion completed
                  int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
                  // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
                  sleep(conversionTime);
                
                  // Read temperatures and send them to 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>((getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
                 
                    // Only send data if temperature has changed and no error
                    #if COMPARE_TEMP == 1
                    if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
                    #else
                    if (temperature != -127.00 && temperature != 85.00) {
                    #endif
                 
                      // Send in the new temperature
                      send(msg.setSensor(i).set(temperature,1));
                      // Save new temperatures for next compare
                      lastTemperature[i]=temperature;
                    }
                  }
                  sleep(SLEEP_TIME);
                }
                
                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  brix7be
                  wrote on last edited by
                  #21

                  The final goal for me is the build ethernet sensor(s) (2 or 3 one each arduino board) connected to domoticz by lan gw.

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    brix7be
                    wrote on last edited by
                    #22

                    Is there anyone who have done a sketch to connect sensor directly on an ethernet gateway ?
                    Iam searching a working exemple or a working draft to see the process to build my own code.
                    Thank everyone for your advices.

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      brix7be
                      wrote on last edited by brix7be
                      #23

                      Hi Hek, Everyone,

                      I've clean the approximative sketch I've made before to simply try to see the value of a DS18b20 sensor trough a serial gw in domoticz.
                      So i've placed the merged code below to have your advices.
                      In domoticz's log i can see the declaration of the gw but neither the dallas sensor!?

                      Does someone could check my sketch please?
                      To be sure that the arduino see the dallas, i've tested a sketch wich send the value to the serial terminal (it works properly :-).

                      Thank you in advance for your help.
                      Have a nice sunday all. (clouday in belgium today ;-)).

                      // Enable debug prints to serial monitor
                      #define MY_DEBUG 
                      
                      // Enable serial gateway
                      #define MY_GATEWAY_SERIAL
                      
                      // 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 
                      
                      //#define MY_DEFAULT_ERR_LED_PIN 7  // Error led pin
                      //#define MY_DEFAULT_RX_LED_PIN  8  // Receive led pin
                      //#define MY_DEFAULT_TX_LED_PIN  9  // the PCB, on board LED
                      
                      #include <SPI.h>
                      #include <MySensor.h>  
                      #include <DallasTemperature.h>
                      #include <OneWire.h>
                      
                      #define COMPARE_TEMP 1 // Send temperature only if changed? 1 = Yes 0 = No
                      
                      #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected 
                      #define MAX_ATTACHED_DS18B20 16
                      unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
                      OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
                      DallasTemperature sensors(&oneWire); // Pass the oneWire reference to Dallas Temperature. 
                      float lastTemperature[MAX_ATTACHED_DS18B20];
                      int numSensors=0;
                      boolean receivedConfig = false;
                      boolean metric = true; 
                      // Initialize temperature message
                      MyMessage msg(0,V_TEMP);
                      
                      void setup() { 
                        // Setup locally attached sensors
                        
                        // Startup up the OneWire library
                        sensors.begin();
                        // requestTemperatures() will not block current thread
                        sensors.setWaitForConversion(false);
                      }
                      
                      void presentation() {
                       // Present locally attached sensors 
                       
                        // Send the sketch version information to the gateway and Controller
                        sendSketchInfo("Temperature Sensor", "1.1");
                      
                        // 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++) {   
                           present(i, S_TEMP);
                        }
                      }
                      
                      void loop() { 
                        // Send locally attached sensor data here
                      
                        // Fetch temperatures from Dallas sensors
                        sensors.requestTemperatures();
                      
                        // query conversion time and sleep until conversion completed
                        int16_t conversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
                        // sleep() call can be replaced by wait() call if node need to process incoming messages (or if node is repeater)
                        sleep(conversionTime);
                      
                        // Read temperatures and send them to 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>((getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
                       
                          // Only send data if temperature has changed and no error
                          #if COMPARE_TEMP == 1
                          if (lastTemperature[i] != temperature && temperature != -127.00 && temperature != 85.00) {
                          #else
                          if (temperature != -127.00 && temperature != 85.00) {
                          #endif
                       
                            // Send in the new temperature
                            send(msg.setSensor(i).set(temperature,1));
                            // Save new temperatures for next compare
                            lastTemperature[i]=temperature;
                          }
                        }
                        sleep(SLEEP_TIME);
                      }
                      

                      To be complete, there is the domoticz log.

                      2015-10-25 10:44:40.157 MySensors: Using serial port: COM3
                      2015-10-25 10:44:41.892 MySensors: Gateway Ready...
                      2015-10-25 10:44:41.892 MySensors: Node: 0, Sketch Name: Temperature Sensor
                      2015-10-25 10:44:41.946 MySensors: Node: 0, Sketch Version: 1.1
                      
                      1 Reply Last reply
                      0
                      • B Offline
                        B Offline
                        brix7be
                        wrote on last edited by
                        #24

                        No idea?

                        1 Reply Last reply
                        0
                        • hekH Offline
                          hekH Offline
                          hek
                          Admin
                          wrote on last edited by
                          #25

                          Sensors attached to gateway (node id=0) is a new feature.
                          Might be Domoticz filtering these type of messages perhaps?

                          @GizMoCuz might know if this is the case.

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            afick
                            wrote on last edited by
                            #26

                            Hello,
                            I have created ethernet gateway :) with 2 sensors :) (DHT11, and door/windows sensor) all data are send to domoticz without problem.But when i adds "przekaznik" - one channel relay - i can't send/receive data about this relay. Can anyone check why ?

                            sorry for mess in code

                            // Enable debug prints to serial monitor
                            #define MY_DEBUG
                            
                            // Enable gateway ethernet module type
                            #define MY_GATEWAY_W5100
                            
                            // 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.
                            #define MY_SOFTSPI
                            #define MY_SOFT_SPI_SCK_PIN 14
                            #define MY_SOFT_SPI_MISO_PIN 16
                            #define MY_SOFT_SPI_MOSI_PIN 15
                            
                            // When W5100 is connected we have to move CE/CSN pins for NRF radio
                            #define MY_RF24_CE_PIN 5
                            #define MY_RF24_CS_PIN 6
                            
                            // Enable to UDP
                            //#define MY_USE_UDP
                            
                            #define MY_IP_ADDRESS 192,168,0,250   // If this is disabled, DHCP is used to retrieve address
                            // Renewal period if using DHCP
                            //#define MY_IP_RENEWAL_INTERVAL 60000
                            // The port to keep open on node server mode / or port to contact in client mode
                            #define MY_PORT 5003
                            
                            // Controller ip address. Enables client mode (default is "server" mode).
                            // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere.
                            //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 254
                            
                            // 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.
                            #define MY_MAC_ADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
                            
                            // 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
                            
                            #define MY_DEFAULT_ERR_LED_PIN 7  // Error led pin
                            #define MY_DEFAULT_RX_LED_PIN  8  // Receive led pin
                            #define MY_DEFAULT_TX_LED_PIN  9  // the PCB, on board LED
                            
                            //Przekaznik
                            #define MY_REPEATER_FEATURE
                            
                            #define RELAY_1  22  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
                            #define NUMBER_OF_RELAYS 1 // Total number of attached relays
                            #define RELAY_ON 1  // GPIO value to write to turn on attached relay
                            #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
                            
                            #include <SPI.h>
                            
                            #if defined(MY_USE_UDP)
                            #include <EthernetUdp.h>
                            #endif
                            
                            
                            #include <Ethernet.h>
                            #include <MySensor.h>
                            #include <DHT.h>   //dodany czujnik
                            
                            //czujnik temp i wilgotnosci
                            #define CHILD_ID_HUM 0
                            #define CHILD_ID_TEMP 1
                            #define HUMIDITY_SENSOR_DIGITAL_PIN 3
                            #define DOOR_ID1 4
                            #define DOOR_ID1_PIN A0
                            
                            unsigned long SLEEP_TIME = 300; // 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);
                            
                            MyMessage msgDOOR_ID1(DOOR_ID1, V_TRIPPED);
                            int old_DOOR_ID1_STATE = -1;
                            
                            
                            void setup()
                            {
                            
                              //temp + hum
                              dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
                              metric = getConfig().isMetric;
                            
                              //  kontaktron DOOR_ID1
                              pinMode(DOOR_ID1_PIN, INPUT);
                            
                              //  //przekaznik
                              for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
                              //    // Then set relay pins in output mode
                                  pinMode(pin, OUTPUT);
                              //    // Set relay to last known state (using eeprom storage)
                                  digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
                                }
                            
                            }
                            
                            void presentation()
                            {
                            
                              //temp + hum
                              // Send the Sketch Version Information to the Gateway
                              sendSketchInfo("Humidity", "1.0");
                              // Register all sensors to gw (they will be created as child devices)
                              present(CHILD_ID_HUM, S_HUM);
                              present(CHILD_ID_TEMP, S_TEMP);
                              present(DOOR_ID1, S_DOOR);
                            
                              //przekaznik
                              // Send the sketch version information to the gateway and Controller
                              sendSketchInfo("Relay", "1.0");
                            
                              for (int sensor = 1, pin = RELAY_1; sensor <= NUMBER_OF_RELAYS; sensor++, pin++) {
                                // Register all sensors to gw (they will be created as child devices)
                                present(sensor, S_LIGHT);
                                Serial.print("Petla presentation");
                              }
                            
                            }
                            
                            void loop()
                            {
                              //temp + hum
                              delay(dht.getMinimumSamplingPeriod());
                              float temperature = dht.getTemperature();
                              if (isnan(temperature)) {
                                Serial.println("Failed reading temperature from DHT");
                              } else if (temperature != lastTemp) {
                                lastTemp = temperature;
                                if (!metric) {
                                  temperature = dht.toFahrenheit(temperature);
                                }
                                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;
                                send(msgHum.set(humidity, 1));
                                Serial.print("H: ");
                                Serial.println(humidity);
                              }
                            
                            
                              int DOOR_ID1_STATE = analogRead(DOOR_ID1_PIN);
                              Serial.print("Analog= ");
                              Serial.println(DOOR_ID1_STATE);
                              Serial.println(old_DOOR_ID1_STATE);
                            
                              if (DOOR_ID1_STATE == 0) {
                                DOOR_ID1_STATE = 0;
                                send(msgDOOR_ID1.set(DOOR_ID1_STATE));
                                old_DOOR_ID1_STATE = DOOR_ID1_STATE;
                                Serial.print("drzwi_1=");
                                Serial.println(DOOR_ID1_STATE);
                            
                              } else {
                                DOOR_ID1_STATE = 1;
                                send(msgDOOR_ID1.set(DOOR_ID1_STATE));
                                old_DOOR_ID1_STATE = DOOR_ID1_STATE;
                                Serial.print("drzwi_2=");
                                Serial.println(DOOR_ID1_STATE);
                              }
                            }
                            
                            void receive(const MyMessage &message) {
                              // We only expect one type of message from controller. But we better check anyway.
                              if (message.type == V_LIGHT) {
                                // Change relay state
                                digitalWrite(message.sensor - 1 + RELAY_1, message.getBool() ? RELAY_ON : RELAY_OFF);
                                // Store state in eeprom
                                saveState(message.sensor, message.getBool());
                                // Write some debug info
                                Serial.print("Incoming change for sensor:");
                                Serial.print(message.sensor);
                                Serial.print(", New status: ");
                                Serial.println(message.getBool());
                              }
                            }
                            
                            
                            1 Reply Last reply
                            0
                            • hekH Offline
                              hekH Offline
                              hek
                              Admin
                              wrote on last edited by
                              #27

                              Just did some verification of message receiving in gateway on the ESP8266 sent from my shell (using netcat). Messages is showing up in receive() just fine here.

                              Are you sending to node 0 from Domoticz? What does the log say in the gateway?

                              1 Reply Last reply
                              0
                              • A Offline
                                A Offline
                                afick
                                wrote on last edited by afick
                                #28

                                Nothing special

                                0;0;3;0;9;Starting...
                                IP: 192.168.0.250
                                0;0;3;0;9;gateway started, id=0, parent=0, distance=0
                                

                                Domoticz log

                                 2015-11-09 23:09:50.588 (GW) Temp + Humidity (TempHum)
                                2015-11-09 23:09:53.599 (GW) Temp + Humidity (TempHum)
                                2015-11-09 23:09:56.614 (GW) Temp + Humidity (TempHum)
                                2015-11-09 23:09:56.620 (GW) Temp + Humidity (TempHum)
                                2015-11-09 23:10:00.632 (GW) Temp + Humidity (TempHum)
                                2015-11-09 23:10:00.680 (GW) Lighting 2 (Security Sensor)
                                2015-11-09 23:10:03.706 (GW) Temp + Humidity (TempHum)
                                2015-11-09 23:10:07.718 (GW) Temp + Humidity (TempHum)
                                2015-11-09 23:10:12.730 (GW) Temp + Humidity (TempHum)
                                2015-11-09 23:10:17.745 (GW) Temp + Humidity (TempHum)
                                2015-11-09 23:10:21.762 (GW) Temp + Humidity (TempHum)
                                2015-11-09 23:10:22.770 (GW) Lighting 2 (Security Sensor)
                                2015-11-09 23:10:27.791 (GW) Temp + Humidity (TempHum)
                                2015-11-09 23:10:31.805 (GW) Temp + Humidity (TempHum)
                                2015-11-09 23:10:32.812 (GW) Temp + Humidity (TempHum) 
                                

                                I'm receiving only this kind of information.

                                How can i send "0" from domoticz to GW ?

                                1 Reply Last reply
                                0
                                • hekH Offline
                                  hekH Offline
                                  hek
                                  Admin
                                  wrote on last edited by
                                  #29

                                  Your have messed up the presentation of your S_LIGHT devices in the loop. They start with id 1 in the loop. But that id has already been used by CHILD_ID_TEMP.

                                  1 Reply Last reply
                                  0
                                  • A Offline
                                    A Offline
                                    afick
                                    wrote on last edited by
                                    #30

                                    Even if i change CHILD_ID_RELAY (to 5 or 6 ) sill the same.

                                    1 Reply Last reply
                                    0
                                    • zaphodusZ Offline
                                      zaphodusZ Offline
                                      zaphodus
                                      wrote on last edited by
                                      #31

                                      I had the same problem as you and I have found a possible solution. The arduino has default auto reset on serial connection. So when you connect gateway to controller trough USB, the gateway is rebooting immediately and processing presentation(). In case of wireless gateway (esp8266) this does not happen. The presentation() runs only on startup of the gateway. I made little change in MyGatewayTransportEthernet.cpp and now the gateway processes presentation() when the controller is connecting to it.

                                      You can find here my solution:
                                      https://github.com/zaphodus/Arduino/commit/ce93db73513f1da45637b186787c9b2501e5d882

                                      1 Reply Last reply
                                      0
                                      Reply
                                      • Reply as topic
                                      Log in to reply
                                      • Oldest to Newest
                                      • Newest to Oldest
                                      • Most Votes


                                      8

                                      Online

                                      11.7k

                                      Users

                                      11.2k

                                      Topics

                                      113.0k

                                      Posts


                                      Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                      • Login

                                      • Don't have an account? Register

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