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
D

Dawidi

@Dawidi
About
Posts
5
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Disable restarting arduino after connect to serial gateway.
    D Dawidi

    @yveaux Thank you man so much. I wrote topics on gateway's github, here in cotroller section, OH forum and no one knows how to fix that. I cut jumper on RESET EN and it works. TY!

    Troubleshooting

  • Disable restarting arduino after connect to serial gateway.
    D Dawidi

    @mfalkvidd I do not find any information sending by gateway to restart arduino. It looks like that:

    [log] system start
    [log] some relays state changed from null to ON (restored states)
    [log] some relays state changed from null to OFF
    [log] MySensors bridge is changed from OFFLINE (COMMUNICATION_ERROR)  to OFFLINE
    [log] MySensors bridge is changed from OFFLINE (COMMUNICATION_ERROR)  to OFFLINE
    [log] MySensors bridge is changed from OFFLINE to ONLINE (finnaly)
    [log] all relays changed from OFFLINE to ONLINE
    

    And then arduino restarting. So if i restart OH, arduino keep states until it connect again.

    @Yveaux How can i do that?

    Troubleshooting

  • Disable restarting arduino after connect to serial gateway.
    D Dawidi

    Arduino is restarting after connect to controler (Serial Gateway - OpenHab). But this is not gateway issue. I think it is quite natural, because arduino had to run presentation, but I wondering is it possible to not restarting arduino? It is very important because i have to controll critical relays by it. And i wont turn it off after gateway restart by any reason.

    Troubleshooting

  • Loosing relays state after OH restart
    D Dawidi

    Thanks. I have just made persist. Looks like that:
    config:

    # configure specific rrd properties for given items in this file.
    # please refer to the documentation available at
    # https://www.openhab.org/addons/persistence/rrd4j/
    #
    # default_numeric and default_other are internally defined defnames and are used as
    # defaults when no other defname applies
    
    relpols.def=GAUGE,60,U,U,30
    relpols.archives=LAST,0.5,1,365:LAST,0.5,7,300
    relpols.items= relay_leda, relay_ledb, relay_ledc, ... , relay_custom5
    

    persist:

    Strategies {
        // for rrd charts, we need a cron strategy
        everyMinute : "0 * * * * ?"
    }
    
    Items {
        // persist items on every change and every minute
        relay_leda, relay_ledb, ... , relay_custom4, relay_custom5 : strategy = everyChange, everyMinute, restoreOnStartup
    }
    

    And it looks quite good. Because after restart, states are restored, but it looks like MySensors are not connected in time. And logs looks like (pseudocode):

    [log] system start
    [log] some relays state changed from null to ON (restored states)
    [log] some relays state changed from null to OFF
    [log] MySensors bridge is changed from OFFLINE (COMMUNICATION_ERROR)  to OFFLINE
    [log] MySensors bridge is changed from OFFLINE (COMMUNICATION_ERROR)  to OFFLINE
    [log] MySensors bridge is changed from OFFLINE to ONLINE (finnaly)
    [log] all relays changed from OFFLINE to ONLINE
    

    and then all relays are turning OFF (physicaly) but in OH they have god states. For example relay_ao1 is physicaly off but in OH it is on, so to turn it ON i have to click it 2 time (first time it is switching to OFF).

    Any idea to fix it?

    edit:
    Now i think arduino is restarting after it connect with OH. Can it be true?

    OpenHAB

  • Loosing relays state after OH restart
    D Dawidi

    Hi. I connect Arduino with MySensors to server machine with linux by serial gateway. Everything is working fine, but when I restart OH process, or machine, all relays are turning off. When i had only lights it wan snot big problem. But now i have some important things that i really won't turning off. Is there possibility to keep relays status when OH is restarting?

    My codes:
    things

    Bridge mysensors:bridge-ser:gateway3 "Gateway Przekaźniki RelPol" [ serialPort="/dev/ttyACM4", sendDelay=50, networkSanCheckEnabled=true ]
    {
      light relay_0 'przekaźnik_00' [ nodeId=0, childId=0 ]
      light relay_1 'przekaźnik_01' [ nodeId=0, childId=1 ]
      light relay_2 'przekaźnik_02' [ nodeId=0, childId=2 ]
      light relay_3 'przekaźnik_03' [ nodeId=0, childId=3 ]
      light relay_4 'przekaźnik_04' [ nodeId=0, childId=4 ]
      light relay_5 'przekaźnik_05' [ nodeId=0, childId=5 ]
    }
    

    items

    Switch relay_0 "stan" (relpols) { channel="mysensors:light:gateway3:relay_0:status" }
    Switch relay_1 "stan" (relpols) { channel="mysensors:light:gateway3:relay_1:status" }
    Switch relay_2 "stan" (relpols) { channel="mysensors:light:gateway3:relay_2:status" }
    Switch relay_3 "stan" (relpols) { channel="mysensors:light:gateway3:relay_3:status" }
    Switch relay_4 "stan" (relpols) { channel="mysensors:light:gateway3:relay_4:status" }
    Switch relay_5 "stan" (relpols) { channel="mysensors:light:gateway3:relay_5:status" }
    

    arduino

    
    // Enable debug prints to serial monitor
    #define MY_DEBUG
    
    
    // Enable and select radio type attached
    //#define MY_RADIO_RF24
    //#define MY_RADIO_NRF5_ESB
    //#define MY_RADIO_RFM69
    //#define MY_RADIO_RFM95
    
    // 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 Arduinos running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
    #if F_CPU == 8000000L
    #define MY_BAUD_RATE 38400
    #endif
    
    // 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
    
    // Set blinking period
    #define MY_DEFAULT_LED_BLINK_PERIOD 300
    
    #define MY_NODE_ID 1
    
    // Inverses the behavior of leds
    //#define MY_WITH_LEDS_BLINKING_INVERSE
    
    // Flash leds on rx/tx/err
    // 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 <MySensors.h>
    
    class Relay {
      const int pin;
      int state;
    
      public:
        Relay(int attachTo) :
          pin(attachTo)
        {
        }
    
        void setup() {
          pinMode(pin, OUTPUT);
        }
        void on() {
          state = 1;
        }
        void off() {
          state = 0;
        }
        void setState() {
          digitalWrite(pin, state);
        }
    };
    
    
    Relay relay0(8);
    Relay relay1(9);
    Relay relay2(10);
    Relay relay3(11);
    Relay relay4(12);
    
    
    Relay relays[] = {relay0, relay1, relay2, relay3, relay4,};
    
    void presentation () {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("relays", "0.4");
    
      for(int i = 0; i < 5; i++){
        present(i, S_BINARY);
      }
    }
    
    void setup()
    {
      Serial.begin(115200);
    
    	presentation();
    
      for(int i = 0; i < 5; i++){
        relays[i].setup();
      }
    }
    
    void loop()
    {
      for(int i = 0; i < 5; i++){
        relays[i].setState();
      }
      wait(20);
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
        if(message.type==V_LIGHT && message.getInt() == 0){
          relays[(message.sensor)].off();
        }
        if(message.type==V_LIGHT && message.getInt() == 1){
          relays[(message.sensor)].on();
        }
    }
    
    
    OpenHAB
  • Login

  • Don't have an account? Register

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