Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. tonin
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by tonin

    • RE: [SOLVED ... partially] Ethernet gateway without radio don't present local sensors to domoticz

      This code

      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      
      // Enable and select radio type attached
      //Comento la siguiente linea para que no necesite radio
      //#define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      
      // Set LOW transmit power level as default, if you have an amplified NRF-module and
      // power your radio separately with a good regulator you can turn up PA level. 
      #define MY_RF24_PA_LEVEL RF24_PA_LOW
      
      // Enable serial gateway
      #define MY_GATEWAY_SERIAL
      
      // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
      #if F_CPU == 8000000L
      #define MY_BAUD_RATE 38400
      #endif
      
      // Flash leds on rx/tx/err
      #define MY_LEDS_BLINKING_FEATURE
      // Set blinking period
      #define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Inverses the behavior of leds
      //#define MY_WITH_LEDS_BLINKING_INVERSE
      
      // Enable inclusion mode
      #define MY_INCLUSION_MODE_FEATURE
      // Enable Inclusion mode button on gateway
      #define MY_INCLUSION_BUTTON_FEATURE
      
      // Inverses behavior of inclusion button (if using external pullup)
      //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
      
      // Set inclusion mode duration (in seconds)
      #define MY_INCLUSION_MODE_DURATION 60 
      // Digital pin used for inclusion mode button
      #define MY_INCLUSION_MODE_BUTTON_PIN  3 
      
      // Uncomment to override default HW configurations
      //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
      //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
      //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
      
      #include <SPI.h>
      #include <MySensors.h>  
      
      //Para el sensor de temperatura
      #ifdef TEMP
       #include <DallasTemperature.h>
       #include <OneWire.h>
       #define ONE_WIRE_BUS 2
       OneWire oneWire(ONE_WIRE_BUS);
       DallasTemperature sensors(&oneWire);
       MyMessage msg(0,V_TEMP);
      #endif
      
      //Structura de reles
      typedef struct  {
       int  pin;
       char desc[20];
       bool ON;
       bool OFF;
      } sRELE;
      
      sRELE Rele [] = { {13 , "LED", HIGH, LOW},
                       {31 , "RELE ASPERSOR PORCHE", LOW, HIGH},
                       {33 , "RELE TURBINAS", LOW, HIGH},
                       {35 , "RELE GOTEROS BAJOS", LOW, HIGH}
                     };
      
      #define NUMBER_OF_RELAYS 4 // Total number of attached relays
      
      void setup() { 
       // Setup locally attached sensors
      #ifdef TEMP
       //Para el sensor de temperatura
       sensors.begin();
      #endif
       //Para los reles
         Serial.println("start call Setup");
       for (int sensor=0 ; sensor<NUMBER_OF_RELAYS;sensor++) {
         // Poner el rele en output mode
         pinMode(Rele[sensor].pin, OUTPUT);   
         // Poner el rele en el ultimo estado conocido (usando eeprom storage) 
         digitalWrite(Rele[sensor].pin, loadState(sensor)?Rele[sensor].ON:Rele[sensor].OFF);
       }
         Serial.println("End call Setup");
         presentation();
      }
      
      void presentation() {
       // Presentar los sensores y actuadores locales 
       Serial.println("start call presentation");
       // Mandar la info del sketch
       sendSketchInfo("Arduino USB", "1.0");
      
       //Presentar los reles
       for (int rele=0; rele<NUMBER_OF_RELAYS;rele++) {
         // Registrar todos los reles al gw
         present(rele, S_LIGHT,Rele[rele].desc);
       }
       Serial.println("End call presentation");
      #ifdef TEMP
       //Presento el sensor de temperatura
       present(9,S_TEMP,"SENSOR_TEMP");
      #endif
      }
      bool STATUS;
      void loop() { 
       // Send locally attached sensor data here 
      #ifdef TEMP
       Serial.print("Solicitando temperaturas...");
       sensors.requestTemperatures(); // Send the command to get temperatures
       float temperatura = sensors.getTempCByIndex(0);
       send(msg.setSensor(9).set(temperatura,1));
       Serial.println("DONE");
       sleep(2000);
      #endif
      }
      
      
      void receive(const MyMessage &message) {
       // Solo esperamos mensajes V_LIGTH de momento, pero lo chequeamos por si acaso.
       if (message.type==V_LIGHT) {
          // Cambiar estado del rele
          digitalWrite(Rele[message.sensor].pin, message.getBool()?Rele[message.sensor].ON:Rele[message.sensor].OFF);
          // Almacenar estado en la eeprom
          saveState(message.sensor, message.getBool());
          // Escribir informacion de debug
          Serial.print("Cambio entrante para sensor:");
          Serial.print(message.sensor);
          Serial.print(", Nuevo status: ");
          Serial.println(message.getBool());
        } 
      }
      

      works ok for me. As you can see I define the relays in an structure to do it configurable. The only trick for me is to call the presentation function in the setup function. In the ethernet gateway it isn't needed.

      A note for the structure sRELE. yo can see the pin, description and the state of the pin that mean ON or OFF. It's so because my relay boards have an inverse logic. When the pin is in low state, the relay is on. This relay boards are opto coupled and have an isolated circuit between arduino pins and relays, this is the reason for that.

      The sample code also have some lines to read temperature from a dallas sensor.

      I hope that this help you.

      posted in Troubleshooting
      tonin
      tonin
    • RE: [SOLVED ... partially] Ethernet gateway without radio don't present local sensors to domoticz

      Try to call the presentation function in setup. I remembered that i needed to do it on usb gateway, the ethernet gateway has a patched code to call presentation after connection to the controller.

      posted in Troubleshooting
      tonin
      tonin
    • RE: [SOLVED ... partially] Ethernet gateway without radio don't present local sensors to domoticz

      @TheoL No, in mysensors 2.0 you can have gateways with local sensors or relays without radio only commenting all radio #define's

      posted in Troubleshooting
      tonin
      tonin
    • RE: [SOLVED ... partially] Ethernet gateway without radio don't present local sensors to domoticz

      Mystery solved ....

      I was using client mode gateway because in server mode my arduino mega reset every time that send an ethernet packet. In client mode as I say, domoticz connect to the arduino but there is no traffic from arduino to RPI domoticz presenting my relays. I read that client mode is buggy at this time, so I try to get server mode without the resets.

      To avoid resets in my chinese arduino mega 2560 & chinese w5100 I need to downgrade de AVR library from 1.6.13 to 1.6.11. So all works Ok with my to gateways (usb & ethernet() connected to my RPI domoticz controller.

      posted in Troubleshooting
      tonin
      tonin
    • RE: [SOLVED ... partially] Ethernet gateway without radio don't present local sensors to domoticz

      I do some tests. In the serial console of the usb gateway, after sendSketch and calls to present functions, with MY_DEBUG defined I see the message sent to the controller.

      In the ethernet gateway sample I can do a telnet to the ip and port of the gateway, type anything and I see the "connect" message in the serial console. But the sendSketch and present functions don't show anything in the serial console and of course nothing in the telnet session.

      Also if I call a send function with any arbitrary message, I can't see anything in the serial or the telnet. It seems that the send function or any function that it calls isn't working right in ethernet gateway.

      I cleared the eprom of the arduino but no way. I'm trying to put more debug code in the core library to see what is happening.

      posted in Troubleshooting
      tonin
      tonin
    • RE: [SOLVED ... partially] Ethernet gateway without radio don't present local sensors to domoticz

      I don't think so because a relay is an s_switch than don't send data, only receive orders from the controller to switch on or off.
      Also in the usb gateway i get the registration of relays. Anyway i'll try to put one temp sensor in the ethernet gateway to see if it appear in domoticz.

      posted in Troubleshooting
      tonin
      tonin
    • [SOLVED ... partially] Ethernet gateway without radio don't present local sensors to domoticz

      First of all, as this is my first message, regards to all people that are working in this nice project. I hope to collaborate from now because I have decided to use this project with domoticz to make my projects.

      My project have a RPI controller with domoticz, and two arduino mega 2560 compatible board, one using USB gateway directly attached to the RPI and other with w5100 compatible shield in a remote site. using mysensors V2 library with the Ethernet gateway sketch (not the MTQQ variant). Now the RPI and the W5100 are plugged to a local switch, in the future I'll use two PLC to connect them.

      When I put this code in presentation function in the Ethernet Gateway sample sketch:

      void presentation(){
          sendSketchInfo("Arduino Ethernet", "1.0");
          present(15, S_LIGHT,"My test relay");
      }
      

      I don't get any registration in domoticz. Using the same code in gateway USB the sketch info and the test relay device are registered ok.
      In my test I:

      • Commented all #define of MY_RADIO_XXXX to use only local sensors and relays an avoid radio errors.
      • Define the IP of the gateway, the IP of the controller, the MAC, the port, etc and add the gateway in the hardware of domotiz. I can ping the gateway from my network, domoticz show in the log that is connected and in the serial console of the gateway I receive the PING messages that I suppose tha come from the controller.

      But there is no way to get the test relay and the sketch name registered in domotixz. With the USB gateway I have now a sketch tha present 8 relays and one temperature sensor that works fine, I can turn on/off all relays, read the temperature, etc.

      Anyone have a idea that which is the problem?

      Regards.

      posted in Troubleshooting
      tonin
      tonin