Navigation

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

    Eduard Iten

    @eiten

    23
    Reputation
    67
    Posts
    46
    Profile views
    0
    Followers
    2
    Following
    Joined Last Online
    Location Mannenbach, Switzerland Age 45

    eiten Follow

    Best posts made by eiten

    • RE: CubeCell HAL anyone?

      New status update: IT WORKS!
      I have to implement sleep and ATC, then I will upload it to GitHub for testing, if anyone is iterested...

      posted in Hardware
      eiten
      eiten
    • RE: CNC PCB milling

      @NeverDie Did you check out the assembly instructions? There they use a fuse with a rather high current in this place 🤣 🤣 🤣
      The explanation why it is polarized is because in fact, it used to be a diode in older revisions, check out Step 7 here.

      posted in General Discussion
      eiten
      eiten
    • CubeCell reloaded: the SX126x hal drivers, please test

      Hi everyone,
      After the good comments by @Yveaux and @mfalkvidd in this thread i started over again. After some sleepless nights, a SSD-crash destroying about 12h of coding 😢 and tons of soft drinks, I just uploadated my github repository with the SX126x drivers and the ASR650x hal.
      What is different to the things I mentioned in the thread above:

      • Everything is rebased to the developement branch as suggested by @mfalkvidd
      • CubeCell hal byebye, welcome SX126x hal. As inspired by @Yveaux, I abandoned the CubeCell drivers in favor of SX126x drivers which should work on other SX126x based modules as well. Feel free to test. The code should work for the SX1261 as well as the SX1262, but as I only have CubeCell boards, only SX1262 is tested.
      • ATM, I really dont feel like writing down all the defines, but everything is documented in MyConfig.hand in ```SX126x.h`` If you got questions. please ask.

      During developement, I found another nasty bug in ASR650x Arduino regarding IRQ handling. You should take the latest version from ASR650x github if you encounter strange freezes on a CellCube board.

      Have fun, I gotta get some sleep 😝 😴

      posted in Hardware
      eiten
      eiten
    • RE: Does a Bluetooth controller/gateway exist?

      Hello Henrik,

      In your scenario, I would not use a RPi. Maybe a ESP32 with BLE is already enough as a controler, if you don't need to log too much data or add an SD card. You could even combine two NRF52 (see below) and use one for BLE and the other for MySensors.
      For your sensoirs, you could use a Keywish RF Nano or an NRF52 module like (this one)[https://www.aliexpress.com/item/32974237147.html] which combines a NRF24L01 and an ARM cortex M cpu and have very low sleep current.
      Maybe it's best for you to use passive nodes when not using the RPi, so you don't have to care about address management and so on on the gateway.

      Regards, Edi

      posted in Controllers
      eiten
      eiten
    • RE: Node with only sendBatteryLevel into Home Assistant

      Well, battery level is an attribute in Home Assistant, so you can only see it as a byproduct of a reading. Workaround is to open the persistence file, there, you can see the battery level even in no reading is shown in the frontend: Bildschirmfoto vom 2023-04-02 23-18-02.png

      posted in Hardware
      eiten
      eiten
    • Jenkin erros I do not understand

      Can anybody help me? I made a pull request which results in Jenkin errors, I do not understand the output/what's wrong. Can anyone please help me out? It would be great to have the SX126x support, as I am working on the STM32WLE integration for MySensors.

      Sorry, I forgot the link to the PR: https://github.com/mysensors/MySensors/pull/1547

      eiten created this issue in mysensors/MySensors

      closed Added support for ASR650x and SX126x #1547

      posted in Development
      eiten
      eiten
    • RE: Possible flaw in RFM95 driver

      Oh sorry, my fault. It was a bit late. We have a return true in there, where we exit the loop as soon as we got an ack. You are right!

      posted in Bug Reports
      eiten
      eiten
    • RE: CubeCell HAL anyone?

      Yes, exactly.

      Well, I think we would have to write the HAL functions (which is not too hard as I imagine) as a first step. I hope we could use the RFM95 drivers in a first step, but the Framework compiles with a LoRa and a LoRaWAN app. If we have luck, we have no collisions.
      In a further step, I would test if it is worth while to implement a new transport and use the native LoRa-stack.

      Well, I think I fork the github-repository and start to play around...

      posted in Hardware
      eiten
      eiten
    • RE: CNC PCB milling

      @NeverDie and for reverse polarity protection, you could just use a FET, a resistor and a Zener (only necessary if reversed voltage is breaking the FET, which is cheaper if you have some amps and has loooots of less power dissipation:
      mist.png
      I use this on all my PCBs with removable batterys. Luxury upgrade: a reverse voltage indicator:
      mist.png
      Add a Zener parallel to the LED if you have a wide expectet input voltage range.

      posted in General Discussion
      eiten
      eiten
    • RE: [SOLVED] MySensors Raspberry Pi Gateway + Domotics Controller

      @Eme said in MySensors Raspberry Pi Gateway + Domotics Controller:

      TSF:CKU:OK,FCTRL

      Uplink OK, flood control prevents pinging GW in too short intervals

      posted in Domoticz
      eiten
      eiten

    Latest posts made by eiten

    • RE: Send 2x relay states to Home Assistant to make them visible?

      @Matt Yes, the landscape there is incredible. Unfortunately, I mostly have to work when I'm there 🙂
      Where are you from?

      posted in Troubleshooting
      eiten
      eiten
    • RE: Send 2x relay states to Home Assistant to make them visible?

      Ah that's good.
      Yes, bring the battery inside over winter. For my all year outdoor thingies, I changed now to SoIon, let's se how they do in cold times.
      Ah cool! Did you ride the train? If so, you rode on my work, I do electrical engineering for cog wheel trains!

      posted in Troubleshooting
      eiten
      eiten
    • RE: Send 2x relay states to Home Assistant to make them visible?

      Hey Matt, no problem, that's what the community is here for. But if we meet, I'd love to have a beer with you! I'm from switzerland, so chances may not be too high.

      Some other thoughts:
      For SLA, you can estimate the SOC by measuring the voltage, but only if you have no load an no charging. If you want to do it really good, you also take the non-linearity into account. The SLA is full, if the open circuit voltage (no load, no charging) is at about 12.8V. 11V for empty is ok. But I would add some code that the relays don't switch if you are under 11V or so, because this can damage the battery.

      Do you use a charger, or is the panel directly connected to the battery? In the second case, you should add a diode so the battery does not reverse feed the panel when it's dark. And you should switch of (short circuit) the panel if the battery voltage is at 14.4V or above. This will also help for a longer battery life.

      posted in Troubleshooting
      eiten
      eiten
    • RE: Send 2x relay states to Home Assistant to make them visible?

      Hello again!

      Turns out that:

      1. I suppose you are on an AVR. They don't seem to like PSTR(). I changed them to F() and now there are no more hieroglyphs.
      2. You have to send the sensor values before any other messages (in this case the sendBatteryLevel(battPct); for HA to be happy.
      3. I forgot to set the lastSend = now;, so it repeatedly sent temp and batt.
      4. I forgot to set changeRelay1 = true; and changeRelay2 = true;.

      For me, it works now: Bildschirmfoto vom 2023-09-20 09-53-50.png

      Here is the code:

      // Configure MySensors
      #define MY_DEBUG
      #define MY_RADIO_RF24 // MY_RADIO_NRF24 is deprecated
      #define MY_RF24_PA_LEVEL RF24_PA_HIGH
      #define MY_REPEATER_FEATURE
      
      // Configure Firmware
      #define FW_NAME F("Relay+Temp")             // Firmware name
      #define FW_VERSION F("2.0")                 // Firmware version
      #define MEASURE_INTERVAL (10 * 60 * 1000ul) // Measuring interval in ms
      
      #define CHILD_ID_TEMP (1)   // Child ID temperature
      #define CHILD_ID_RELAY1 (2) // Child ID relay 1
      #define CHILD_ID_RELAY2 (13) // Child ID relay 2
      #define CHILD_ID_BATT (4)   // Child ID battery voltage
      
      #define ONE_WIRE_BUS_PIN (3)       // OneWire bus pin
      #define RELAY1_PIN (4)             // DIO of relay 1
      #define RELAY2_PIN (5)             // DIO of relay 2
      #define BATT_SENSE_PIN (A0)        // Analog pin for battery voltage
      #define BATT_MAX_V (14.5)          // Battery maximum voltage
      #define BATT_MIN_V (11.0)          // Battery minimum voltage
      #define BATT_LSB_VALUE (0.0139644) // Battery LSB voltage
      #define RELAY_ON HIGH              // GPIO state for relay ON
      #define RELAY_OFF LOW              // GPIO state for relay OFF
      
      // Includes
      #include <MySensors.h>
      #include <DallasTemperature.h>
      
      // Globals
      OneWire oneWire(ONE_WIRE_BUS_PIN);   // OneWire bus
      DallasTemperature sensors(&oneWire); // Temperature Sensors
      
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      MyMessage msgRelay1(CHILD_ID_RELAY1, V_STATUS);
      MyMessage msgRelay2(CHILD_ID_RELAY2, V_STATUS);
      MyMessage msgBatt(CHILD_ID_BATT, V_VOLTAGE);
      
      uint32_t lastSend = -MEASURE_INTERVAL; // When did we last send temperature and voltage?
                                             // We set it to -MEASURE_INTERVAL in case first send goes wrong it will be retried
      bool firstRun = true;                  // Are we in the first loop? Used to send inital values of all sensors
      uint32_t conversationTime;             // ms the sensor needs after measure command
      bool changeRelay1 = true;              // State of relay 1 changed
      bool changeRelay2 = true;              // State of relay 2 changed
      
      void before()
      {
        // set relay pins as output and switch of relays
        pinMode(RELAY1_PIN, OUTPUT);
        pinMode(RELAY2_PIN, OUTPUT);
        digitalWrite(RELAY1_PIN, RELAY_OFF);
        digitalWrite(RELAY2_PIN, RELAY_OFF);
      }
      
      void setup()
      {
        analogReference(INTERNAL);           // Use internal Vref
        sensors.begin();                     // start DS temperature sensors
        sensors.setWaitForConversion(false); // Do not wait for converstation to finish
      
        // Get the conversation time here, so you don't need the time and ram for the
        // function call every loop. Yo don't change resolution, so this stays constant
        conversationTime = sensors.millisToWaitForConversion(sensors.getResolution());
      }
      
      void presentation()
      {
        sendSketchInfo(FW_NAME, FW_VERSION);
        present(CHILD_ID_TEMP, S_TEMP, F("Air temperature"));
        present(CHILD_ID_RELAY1, S_BINARY, F("Relay 1"));
        present(CHILD_ID_RELAY2, S_BINARY, F("Relay 2"));
        present(CHILD_ID_BATT, S_MULTIMETER, F("Battery voltage"));
      }
      
      void loop()
      {
        uint32_t now = millis();
      
        // Send relay state whenever they changed (or on first loop)
        if (changeRelay1 || firstRun)
        {
          bool relayState = (digitalRead(RELAY1_PIN) == RELAY_ON) ? true : false;
          send(msgRelay1.set(relayState));
          changeRelay1 = false;
      #ifdef MY_DEBUG
          Serial.print(F("Sent relay 1 status: "));
          Serial.println(relayState ? F("ON") : F("OFF"));
      #endif
        }
        if (changeRelay2 || firstRun)
        {
          bool relayState = (digitalRead(RELAY2_PIN) == RELAY_ON) ? true : false;
          send(msgRelay2.set(relayState));
          changeRelay2 = false;
      #ifdef MY_DEBUG
          Serial.print(F("Sent relay 2 status: "));
          Serial.println(relayState ? F("ON") : F("OFF"));
      #endif
        }
      
        // Temperature and battery voltage are sent only every MEASURE_INTERVAL ms
        // or if it is the first run of the loop, as HA else does not show them
        if (firstRun || (now - lastSend > MEASURE_INTERVAL))
        {
          // Trigger temperature measurement and wait for it to finish. Use wait()
          // and not delay so you don't miss incoming relay commands during this time
          // and keep the repeater function working
          sensors.requestTemperatures();
          wait(conversationTime);
      
          // Get the temperature in °C to check if it is valid
          float temperature = sensors.getTempCByIndex(0);
      
          // If temperature is valid, process and send it
          temperature = 12.55;
          if (temperature != -127.0 && temperature != 85.0)
          {
            // Get imperial units if controller is not set to metric system
            if (!getControllerConfig().isMetric)
            {
              temperature = sensors.getTempFByIndex(0);
            }
            // round to one digit
            temperature = static_cast<float>(static_cast<int>(temperature) * 10.) / 10.;
            send(msgTemp.set(temperature, 1));
      #ifdef MY_DEBUG
            Serial.print(F("Sent temperature: "));
            Serial.print(temperature);
            Serial.println(getControllerConfig().isMetric ? F("C") : F("F"));
      #endif
          }
      
          float battVolt = analogRead(BATT_SENSE_PIN) * BATT_LSB_VALUE;
          int battPct = static_cast<int>(((battVolt - BATT_MIN_V) / (BATT_MAX_V - BATT_MIN_V)) * 100.);
          battPct = constrain(battPct, 0, 100); // Avoid battery percentage outside 0-100%
          sendBatteryLevel(battPct);
          send(msgBatt.set(battVolt, 2));
      #ifdef MY_DEBUG
          Serial.print(F("Sent battery status: "));
          Serial.print(battVolt, 2);
          Serial.print(F("V, "));
          Serial.print(battPct);
          Serial.println("%");
      #endif
          lastSend = now;
        }
        firstRun = false; // after the first loop, set firstRun to false;
      }
      
      void receive(const MyMessage &message)
      {
      #ifdef MY_DEBUG
        Serial.print(F("Incomming message: "));
      #endif
        // V_STATUS messages are expected for relay commands
        if (message.type == V_STATUS)
        {
          // Check which relay should be switched
          switch (message.sensor)
          {
          case CHILD_ID_RELAY1:
            digitalWrite(RELAY1_PIN, message.getBool() ? RELAY_ON : RELAY_OFF);
            changeRelay1 = true;
      #ifdef MY_DEBUG
            Serial.print(F("switched relay 1 "));
            Serial.println(message.getBool() ? F("ON") : F("OFF"));
      #endif
            break;
          case CHILD_ID_RELAY2:
            digitalWrite(RELAY2_PIN, message.getBool() ? RELAY_ON : RELAY_OFF);
            changeRelay2 = true;
      #ifdef MY_DEBUG
            Serial.print(F("switched relay 2 "));
            Serial.println(message.getBool() ? F("ON") : F("OFF"));
      #endif
            break;
          default:
      #ifdef MY_DEBUG
            Serial.print(F(" unknown child ID "));
            Serial.println(message.sensor);
      #endif
          }
        }
        else
        {
      #ifdef MY_DEBUG
          Serial.print(F(" unknown message type "));
          Serial.println(message.type);
      #endif
        }
      }
      

      And the monitor output (Link to the log parser) :

       __  __       ____
      |  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
      | |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
      | |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
      |_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
              |___/                      2.3.2
      
      16 MCO:BGN:INIT REPEATER,CP=RNNRA---,FQ=8,REL=255,VER=2.3.2
      28 MCO:BGN:BFR
      30 TSM:INIT
      30 TSF:WUR:MS=0
      38 TSM:INIT:TSP OK
      40 TSF:SID:OK,ID=1
      43 TSM:FPAR
      47 ?TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      167 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
      174 TSF:MSG:FPAR OK,ID=0,D=1
      2056 TSM:FPAR:OK
      2056 TSM:ID
      2058 TSM:ID:OK
      2060 TSM:UPL
      2066 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      2084 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
      2091 TSF:MSG:PONG RECV,HP=1
      2093 TSM:UPL:OK
      2095 TSM:READY:ID=1,PAR=0,DIS=1
      2103 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
      2117 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
      2125 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=18,pt=0,l=5,sg=0,ft=0,st=OK:2.3.2
      2136 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
      2177 TSF:MSG:READ,0-0-1,s=255,c=3,t=6,pt=0,l=1,sg=0:M
      2185 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=10,sg=0,ft=0,st=OK:Relay+Temp
      2195 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
      2215 TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=6,pt=0,l=15,sg=0,ft=0,st=OK:Air temperature
      2228 TSF:MSG:SEND,1-1-0-0,s=2,c=0,t=3,pt=0,l=7,sg=0,ft=0,st=OK:Relay 1
      2242 TSF:MSG:SEND,1-1-0-0,s=13,c=0,t=3,pt=0,l=7,sg=0,ft=0,st=OK:Relay 2
      2254 TSF:MSG:SEND,1-1-0-0,s=4,c=0,t=30,pt=0,l=15,sg=0,ft=0,st=OK:Battery voltage
      2263 MCO:REG:REQ
      2269 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
      2279 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
      2285 MCO:PIM:NODE REG=1
      2287 MCO:BGN:STP
      2289 MCO:BGN:INIT OK,TSP=1
      2297 TSF:MSG:SEND,1-1-0-0,s=2,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:0
      Sent relay 1 status: OFF
      2308 TSF:MSG:SEND,1-1-0-0,s=13,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:0
      Sent relay 2 status: OFF
      2357 TSF:MSG:READ,0-0-1,s=255,c=3,t=6,pt=0,l=1,sg=0:M
      2428 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:12.0
      Sent temperature: 12.00C
      2441 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=0,pt=1,l=1,sg=0,ft=0,st=OK:0
      2451 TSF:MSG:SEND,1-1-0-0,s=4,c=1,t=38,pt=7,l=5,sg=0,ft=0,st=OK:2.67
      Sent battery status: 2.67V, 0%
      18446 TSF:MSG:READ,0-0-1,s=13,c=1,t=2,pt=0,l=1,sg=0:1
      18452 TSF:MSG:ECHO REQ
      18458 TSF:MSG:SEND,1-1-0-0,s=13,c=1,t=2,pt=0,l=1,sg=0,ft=0,st=OK:1
      Incomming message: switched relay 2 ON
      18468 TSF:MSG:SEND,1-1-0-0,s=13,c=1,t=2,pt=1,l=1,sg=0,ft=0,st=OK:1
      Sent relay 2 status: ON
      
      posted in Troubleshooting
      eiten
      eiten
    • RE: Send 2x relay states to Home Assistant to make them visible?

      No problem Matt, as I said, I had a looong train ride. Just got home, I'll try it myself now. May I ask you which controller you use?
      And the battery type would also be interesting. Lead Acid?

      posted in Troubleshooting
      eiten
      eiten
    • RE: Send 2x relay states to Home Assistant to make them visible?

      Hi Matt,

      try this one:

      // Configure MySensors
      #define MY_DEBUG
      #define MY_RADIO_RF24 // MY_RADIO_NRF24 is deprecated
      #define MY_RF24_PA_LEVEL RF24_PA_HIGH
      #define MY_REPEATER_FEATURE
      
      // Configure Firmware
      #define FW_NAME PSTR("Relay+Temp")          // Firmware name
      #define FW_VERSION PSTR("1.0")              // Firmware version
      #define MEASURE_INTERVAL (10 * 60 * 1000ul) // Measuring interval in ms
      
      #define CHILD_ID_TEMP (1)   // Child ID temperature
      #define CHILD_ID_RELAY1 (2) // Child ID relay 1
      #define CHILD_ID_RELAY2 (3) // Child ID relay 2
      #define CHILD_ID_BATT (4)   // Child ID battery voltage
      
      #define ONE_WIRE_BUS_PIN (3)       // OneWire bus pin
      #define RELAY1_PIN (4)             // DIO of relay 1
      #define RELAY2_PIN (5)             // DIO of relay 2
      #define BATT_SENSE_PIN (A0)        // Analog pin for battery voltage
      #define BATT_MAX_V (14.5)          // Battery maximum voltage
      #define BATT_MIN_V (11.0)          // Battery minimum voltage
      #define BATT_LSB_VALUE (0.0139644) // Battery LSB voltage
      #define RELAY_ON HIGH              // GPIO state for relay ON
      #define RELAY_OFF LOW              // GPIO state for relay OFF
      
      // Includes
      #include <MySensors.h>
      #include <DallasTemperature.h>
      
      // Globals
      OneWire oneWire(ONE_WIRE_BUS_PIN);   // OneWire bus
      DallasTemperature sensors(&oneWire); // Temperature Sensors
      
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      MyMessage msgRelay1(CHILD_ID_RELAY1, V_STATUS);
      MyMessage msgRelay2(CHILD_ID_RELAY2, V_STATUS);
      MyMessage msgBatt(CHILD_ID_BATT, V_VOLTAGE);
      
      uint32_t lastSend = -MEASURE_INTERVAL; // When did we last send temperature and voltage?
                                             // We set it to -MEASURE_INTERVAL in case first send goes wrong it will be retried
      bool firstRun = true;                  // Are we in the first loop? Used to send inital values of all sensors
      uint32_t conversationTime;             // ms the sensor needs after measure command
      bool changeRelay1 = true;              // State of relay 1 changed
      bool changeRelay2 = true;              // State of relay 2 changed
      
      void before()
      {
        // set relay pins as output and switch of relays
        pinMode(RELAY1_PIN, OUTPUT);
        pinMode(RELAY2_PIN, OUTPUT);
        digitalWrite(RELAY1_PIN, RELAY_OFF);
        digitalWrite(RELAY2_PIN, RELAY_OFF);
      }
      
      void setup()
      {
        analogReference(INTERNAL);           // Use internal Vref
        sensors.begin();                     // start DS temperature sensors
        sensors.setWaitForConversion(false); // Do not wait for converstation to finish
      
        // Get the conversation time here, so you don't need the time and ram for the
        // function call every loop. Yo don't change resolution, so this stays constant
        conversationTime = sensors.millisToWaitForConversion(sensors.getResolution());
      }
      
      void presentation()
      {
        sendSketchInfo(FW_NAME, FW_VERSION);
        present(CHILD_ID_TEMP, S_TEMP, PSTR("Air temperature"));
        present(CHILD_ID_RELAY1, S_BINARY, PSTR("Relay 1"));
        present(CHILD_ID_RELAY2, S_BINARY, PSTR("Relay 2"));
        present(CHILD_ID_BATT, S_MULTIMETER, PSTR("Battery voltage"));
      }
      
      void loop()
      {
        // Temperature and battery voltage are sent only every MEASURE_INTERVAL ms
        // or if it is the first run of the loop, as HA else does not show them
        uint32_t now = millis();
        if (firstRun || (now - lastSend > MEASURE_INTERVAL))
        {
          // Trigger temperature measurement and wait for it to finish. Use wait()
          // and not delay so you don't miss incoming relay commands during this time
          // and keep the repeater function working
          sensors.requestTemperatures();
          wait(conversationTime);
      
          // Get the temperature in °C to check if it is valid
          float temperature = sensors.getTempCByIndex(0);
      
          // If temperature is valid, process and send it
          if (temperature != -127.0 && temperature != 85.0)
          {
            // Get imperial units if controller is not set to metric system
            if (!getControllerConfig().isMetric)
            {
              temperature = sensors.getTempFByIndex(0);
            }
            // round to one digit
            temperature = static_cast<float>(static_cast<int>(temperature) * 10.) / 10.;
            send(msgTemp.set(temperature, 1));
      #ifdef MY_DEBUG
            Serial.print(PSTR("Sent temperature: "));
            Serial.print(temperature);
            Serial.println(getControllerConfig().isMetric ? PSTR("C") : PSTR("F"));
      #endif
          }
      
          float battVolt = analogRead(BATT_SENSE_PIN) * BATT_LSB_VALUE;
          int battPct = static_cast<int>(((battVolt - BATT_MIN_V) / (BATT_MAX_V - BATT_MIN_V)) * 100.);
          battPct = constrain(battPct, 0, 100); // Avoid battery percentage outside 0-100%
          sendBatteryLevel(battPct);
          send(msgBatt.set(battVolt, 2));
      #ifdef MY_DEBUG
          Serial.print(PSTR("Sent battery status: "));
          Serial.print(battVolt, 2);
          Serial.print(PSTR("V, "));
          Serial.print(battPct);
          Serial.println("%");
      #endif
        }
      
        // Send relay state whenever they changed (or on first loop)
        if (changeRelay1 || firstRun)
        {
          bool relayState = (digitalRead(RELAY1_PIN) == RELAY_ON) ? true : false;
          send(msgRelay1.set(relayState));
          changeRelay1 = false;
      #ifdef MY_DEBUG
          Serial.print(PSTR("Sent relay 1 status: "));
          Serial.println(relayState ? PSTR("ON") : PSTR("OFF"));
      #endif
        }
        if (changeRelay2 || firstRun)
        {
          bool relayState = (digitalRead(RELAY2_PIN) == RELAY_ON) ? true : false;
          send(msgRelay2.set(relayState));
          changeRelay2 = false;
      #ifdef MY_DEBUG
          Serial.print(PSTR("Sent relay 2 status: "));
          Serial.println(relayState ? PSTR("ON") : PSTR("OFF"));
      #endif
        }
        firstRun = false; // after the first loop, set firstRun to false;
      }
      
      void receive(const MyMessage &message)
      {
      #ifdef MY_DEBUG
        Serial.print(PSTR("Incomming message: "));
      #endif
        // V_STATUS messages are expected for relay commands
        if (message.type == V_STATUS)
        {
          // Check which relay should be switched
          switch (message.sensor)
          {
          case CHILD_ID_RELAY1:
            digitalWrite(RELAY1_PIN, message.getBool() ? RELAY_ON : RELAY_OFF);
      #ifdef MY_DEBUG
            Serial.print(PSTR(" switched relay 1 "));
            Serial.println(message.getBool() ? PSTR("ON") : PSTR("OFF"));
      #endif
            break;
          case CHILD_ID_RELAY2:
            digitalWrite(RELAY2_PIN, message.getBool() ? RELAY_ON : RELAY_OFF);
      #ifdef MY_DEBUG
            Serial.print(PSTR(" switched relay 2 "));
            Serial.println(message.getBool() ? PSTR("ON") : PSTR("OFF"));
      #endif
            break;
          default:
      #ifdef MY_DEBUG
            Serial.print(PSTR(" unknown child ID "));
            Serial.println(message.sensor);
      #endif
          }
        }
        else
        {
      #ifdef MY_DEBUG
          Serial.print(PSTR(" unknown message type "));
          Serial.println(message.type);
      #endif
        }
      }
      

      I have to admit, I did not test it, but it compiles. I'm in the train ATM and do not have hardware. But I'll test it later.
      To keep it simple there are things missing like resending and things like that.

      Regards, Edi

      posted in Troubleshooting
      eiten
      eiten
    • RE: Send 2x relay states to Home Assistant to make them visible?

      Hi Matt,

      you don't send the state of your relays at all! So you need to add

      MyMessage msgRelay1(CHILD_ID_RELAY1, V_STATUS);
      MyMessage msgRelay2(CHILD_ID_RELAY2, V_STATUS);
      

      objects. The presentation is OK. Then, you need a globale variable

      bool firstRun=true;
      

      before the void loop().
      Inside the loop, i would put it in the begining, you need a

      if (firstRun) {
        send(msgRelay1.set(digitalRead(RELAY_1));
        send(msgRelay1.set(digitalRead(RELAY_1+1));
        firstRun == false;
      }
      

      But your code is too complicated, and setting is not handled in the receive. If you give me some minutes, I'll post you a complete example.

      posted in Troubleshooting
      eiten
      eiten
    • RE: Send timer program to pool filter controller

      @Vasilis-Vlachoudis well, normally, I would realize this by a timer in HA and just sending the ON and OFF commands to the switch.
      Alternatively, you could use a custom variable and use a format like this in your message: +0800-1000+1400-1900. On your arduino, you need to write an interpreter for this format and see if your output matches the requirement of the current time frame.
      If you want to controll it from the Arduino, be sure to often request time from the controller. I already got some cheep Arduino Nanos from Ali with a 1% clock accuracy... This may not sound like much but in worst case, this is a quarter of an hour per day!
      Regards, Edi

      posted in General Discussion
      eiten
      eiten
    • RE: Help me build a 6-light-sensor & 2 ch relay node.

      Hi @airmedic79
      I see several problems in your code. Here, you redefine RELAY_PIN:

      #define RELAY_PIN 3 // Arduino Digital I/O pin number for power relay (connected to D3)
      #define RELAY_PIN 4 // Arduino Digital I/O pin number for mode relay (connected to D4)
      

      Its both times RELAY_PIN, the same name for the define, so you will end up with RELAY_PIN equals 4. This should yield a warning.

      You never present the binary sensors, because in this line:

      for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
      

      RELAY_PIN is 4, and NUMBER_OF_RELAYS is 2, so the for loop is never executed.
      Also, I think you got a problem with your sensor IDs, i think id 2 and 4 are doubled.

      Regards, Edi

      posted in Troubleshooting
      eiten
      eiten
    • RE: Error when restarting Homeassistant (mysensors-error)

      Hey @Branther

      Cool it works again. Regarding your question:

      Short answer:
      You can't. Thats what I ment when I said I didn't like the change to the UI config in my last post.

      Experimental answer:

      • Create a backup
      • Delete the gateway device
      • Create a new gateway device, enter the name of the old persistence file

      If you are lucky enough, all your devices will continue to work.

      Risky answer:
      YOU ARE NOT SUPPOSED TO EDIT THESE FILES, BUT IT WORKED FOR ME

      • Create a backup
      • in your config directory, you'll find a hidden folder .storage
      • in this folder, you'll find the json file core.config_entries
      • search for "domain": "mysensors", in this section you can change the settings

      With this method, I successfully changed the IP address and the API version of a gateway.

      A kind request Could you do us a favor and include things like the config excerpt in your last post into code tags (```... your code here ...```)? This makes things easier to read.
      A hint It's a good idea to use the serial devices by the symlinks in /dev/serial like you do. It's even a better idea to use a symlink to this device like ln -s /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0 /mydev/mysensors. Then, you can change the device and recreate the symlink without changing the configuration.

      Regards, Edi

      posted in Troubleshooting
      eiten
      eiten