Navigation

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

    thierryd

    @thierryd

    3
    Reputation
    15
    Posts
    315
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    thierryd Follow

    Best posts made by thierryd

    • RE: Relay doesn't show up in devices

      Apologies, I posted in troubleshooting as I didn't get hits on domoticz section. I will pay attention not to cross post again.

      posted in Domoticz
      thierryd
      thierryd
    • RE: Domoticz: Relay node doesn't show up in "devices"

      Hello, Tried presenting as S_Light, doesn't work, but the piece of code in the loop() work great!
      Nice workaround!
      Thank you very much!

      posted in Troubleshooting
      thierryd
      thierryd
    • RE: Domoticz: Relay node doesn't show up in "devices"

      Guys I'm confused as @gohan suggested I tried again with a "blank" node (eeprom clearded, etc...) with 2 relays: worked. Then I cleared it again and tried with one: worked also. It's like Domoticz's bouncer now thinks relays are nice lads, everybody gets accepted!
      So thank you all, and for people having the issue, there's some stuff:
      1- clear node ID, and try again
      2- Add a button (or simulate one with a wire, just for the sake of pairing)
      3- Add a piece of code to send data to domoticz, as per @mfalkvidd 's code.
      All those worked a some point 🙂
      Thank you again guys, I promise my next post will not be a cry for help (more likely improvement for battery percentage reporting - LiPo -, and/or improvement of BME280 handling - avoid sending data every minute -)

      posted in Troubleshooting
      thierryd
      thierryd

    Latest posts made by thierryd

    • RE: Better battery reporting

      Thank you for your answer, indeed there's a mistake in the comment, I'll edit that right away!
      Yes for AA i mean Alkaline, I implemented the "battery type" feature even if I'm not yet using it, as I currently only power my gadget with LiPo cells. But as it is explained well enough (I hope), anybody can add his battery type in the code! I guess for NiMH boundaries would be 0.9v to 1.3v

      posted in Development
      thierryd
      thierryd
    • RE: Multiple Relays + Motion sketch, fully customizable, optional timer, manual override

      @Ben-Andrewes My domoticz instance behaves weirdly with relay sketches too. Maybe you can find some help here: https://forum.mysensors.org/topic/7101/domoticz-relay-node-doesn-t-show-up-in-devices/21

      posted in Development
      thierryd
      thierryd
    • Better battery reporting

      Hello,
      A modification I implemented starting from the "battery sensor" sketch, in order to improve battery % reporting; wrapped up in a small library. Please be kind with my code, I'm merely a hobbyist.
      Why:
      1- LiPo cells can't get under 3.3v without damage risk, AA cells are leak proof down to 0.7v, I wanted my battery reporting to implement this: LiPo: 100% = 4.15v, 0% = 3.3v // AA: 100% = 1.5v, 0% = 0.8v
      2 - Voltage divider precision relies on resistors accuracy, I wanted a way to "calibrate" my divider in order to get proper battery reporting
      3 - For fun 🙂
      Please note that the voltage divider is not the same for LiPo and AA battery (explained in cpp's comments)

      Feel free to copy, paste, modify, criticize!

      Test sketch

      #include <BatteryManager.h>
      
      const int BatteryType = 1; // 1 for 1S LiPo, 2 for 2xAA
      const uint8_t BatterySensorPin = A0;
      const float VoltageDividerCalibration = 1; // default 1, can be calibrated by measurement
      
      BatteryManager bms;
      
      void setup() {
        // put your setup code here, to run once:
        Serial.begin(115200);
        bms.begin(BatteryType, BatterySensorPin,VoltageDividerCalibration);
      }
      
      void loop() {
        // put your main code here, to run repeatedly:
        Serial.print("Voltage: ");
        Serial.println(bms.reportVoltage());
        Serial.print("Percent: ");
        Serial.println(bms.reportPercent());
        delay(3000);
      }
      

      header:

      /*
      * Battery Manager
      */
      
      #ifndef BatteryManager_h
      #define BatteryManager_h
      
      #include <Arduino.h>
      
      class BatteryManager {
      	public:
              BatteryManager();
                      void begin(int BatteryType, uint8_t SensePin, float Compensation);
      		int reportPercent();
      		float reportVoltage();
      	private:
      		int _BatteryType; //1 for 1S LiPO, 2 for 2x AA
      		uint8_t _SensePin;
                      float _Compensation;
      		float Battery_Min_V;
      		float Battery_Max_V;
      		float Battery_Sense_Pin_Resolution;
      };
      #endif
      

      cpp

      #include <Arduino.h>
      #include <BatteryManager.h>
      
      BatteryManager::BatteryManager() { }
      
      void BatteryManager::begin(int BatteryType, uint8_t SensePin, float Compensation)
      {
          _SensePin = SensePin;
          _Compensation = Compensation;
          pinMode(_SensePin, INPUT);
          // Battery use the 1.1 V internal reference
          #if defined(__AVR_ATmega2560__)
              analogReference(INTERNAL1V1);
          #else
              analogReference(INTERNAL);
          #endif
          int firstRead = analogRead(_SensePin);
          // check battery type and feed related variables
          if (BatteryType == 1) {
                  /* LiPo voltage need to be measured up to 4.2V hence using internal ADC ref of 1.1V,
                  *  divider across battery needs to be 1M, 330K, 
                  *  which allows a range of 0 to ((1e6+330e3)/330e3)*1.1 = 4.433 Volts
                  *  resolution: 4.4333/1023 = Volts per bit = 0.004333659
                  *  sense point can be bypassed with 0.1 uF cap to reduce noise at that point
                  *  LiPo is full @ 4.2V and risks damage below 3.3v
                  *  => LiPo usable range is 3.3 to 4.2 volts so the goal is to report
                  *  100% @ 4.2 volts
                  *  0% @ 3.3 volts
                  */
                  Battery_Min_V = 3.3;
                  Battery_Max_V = 4.15;
                  Battery_Sense_Pin_Resolution = 4.333659; //mv per bit
          }
           if (BatteryType == 2) {
                  /* 2 x AA Alkaline voltage need to be measured up to 3V hence using internal ADC ref of 1.1V,
                  *  divider across battery needs to be 1M, 470K, 
                  *  which allows a range of 0 to ((1e6+470e3)/470e3)*1.1 = 3.44 Volts
                  *  resolution: 3.44/1023 = Volts per bit = 0.003363075
                  *  sense point can be bypassed with 0.1 uF cap to reduce noise at that point
                  *  AA is normally leak proof down to 0.7V, I add an extra 0.1V to avoid any issue
                  *  => AA usable range is 1.5 to 0.8 volts so the goal is to report
                  *  100% @ 2x1.5 = 3 volts
                  *  0% @ 2x0.8 = 1.6 volts
                  */
                  Battery_Min_V = 1.6;
                  Battery_Max_V = 3;
                  Battery_Sense_Pin_Resolution = 3.363075; //mv per bit
          }
      }
      
      int BatteryManager::reportPercent() {
          // get the battery Voltage
          int sensorValue = analogRead(_SensePin);
          Serial.println(sensorValue);
      	float batteryV  = sensorValue * Battery_Sense_Pin_Resolution * _Compensation / 1000;
      	// map to 0 -- 100 according to boundaries
      	// need to multiply voltages by 10 as map function processes long variables
      	return map(10*batteryV,10*Battery_Min_V, 10*Battery_Max_V, 0, 100);;
      }
      
      float BatteryManager::reportVoltage() {
          // get the battery Voltage
          int sensorValue = analogRead(_SensePin);
          Serial.println(sensorValue);
      	return sensorValue * Battery_Sense_Pin_Resolution * _Compensation / 1000;
      }
      
      posted in Development
      thierryd
      thierryd
    • RE: Domoticz: Relay node doesn't show up in "devices"

      Guys I'm confused as @gohan suggested I tried again with a "blank" node (eeprom clearded, etc...) with 2 relays: worked. Then I cleared it again and tried with one: worked also. It's like Domoticz's bouncer now thinks relays are nice lads, everybody gets accepted!
      So thank you all, and for people having the issue, there's some stuff:
      1- clear node ID, and try again
      2- Add a button (or simulate one with a wire, just for the sake of pairing)
      3- Add a piece of code to send data to domoticz, as per @mfalkvidd 's code.
      All those worked a some point 🙂
      Thank you again guys, I promise my next post will not be a cry for help (more likely improvement for battery percentage reporting - LiPo -, and/or improvement of BME280 handling - avoid sending data every minute -)

      posted in Troubleshooting
      thierryd
      thierryd
    • RE: Domoticz: Relay node doesn't show up in "devices"

      Thank you all for your answers. @gohan : I'll try changing node ID tomorrow, it's bed time in France 🙂

      posted in Troubleshooting
      thierryd
      thierryd
    • RE: Relay doesn't show up in devices

      Apologies, I posted in troubleshooting as I didn't get hits on domoticz section. I will pay attention not to cross post again.

      posted in Domoticz
      thierryd
      thierryd
    • RE: Domoticz: Relay node doesn't show up in "devices"

      Ok I did try something else: in void presentation i replaced S_BINARY by pin (of course I deleted the piece of code in the loop()

      I deleted the device and the node from domotics, cleared eeprom and tried. It works, the relay gets paired and is presented in devices... and works. does it make sense?

      void presentation()
      {
      // 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, pin);
      }
      }

      posted in Troubleshooting
      thierryd
      thierryd
    • RE: Domoticz: Relay node doesn't show up in "devices"

      Hello, Tried presenting as S_Light, doesn't work, but the piece of code in the loop() work great!
      Nice workaround!
      Thank you very much!

      posted in Troubleshooting
      thierryd
      thierryd
    • RE: Domoticz: Relay node doesn't show up in "devices"

      So I repeated the whole procedure:
      --> Relay sketch: never appears in devices
      --> Relay with button. pairs fine with the GW, appear in GW setup page, but not in devices. UNTIL... button is pressed. (i waited a few minutes to confirm). Afterwards the relay works as expected.
      I'm 100% sure of the behavior, I reproduced the scenario several times.
      So there's my way of getting a relay to show up in devices, even if it's not straightforward.
      So I guess the "simple relay" sketch needs to send something after it is paired with the GW in order to appear in "Devices". Any piece of code I should try?
      Topic half solved?

      posted in Troubleshooting
      thierryd
      thierryd
    • RE: Domoticz: Relay node doesn't show up in "devices"

      @gohan Thank for taking some time. I did that already, and the output seemed ok, but I'll try again when I get back home. But I guess the presentation is well received, as the node appears properly in the gateway setup page (see screenshot a few posts above).
      Just to specify my setup: RPI running Domoticz, with RFLink GW & devices, some wifi devices (ESP8266 based) & now MySensors V2.1.1 Serial GW & nodes. At the moment I didn't yet tinker with the MySensors sketches: I'm running everything with sample sketches

      posted in Troubleshooting
      thierryd
      thierryd