Navigation

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

    Best posts made by Clone Tv

    • Gateway - I2C Advanced button and led

      I have a gate based on esp2866, wemos mini board. There are few gpio outputs on it. To implement additional features, such as an inclusive button and status LEDs, I had to connect a gpio expansion board via I2C. I took a PCF8574 based board. For the operation of the button and indication through it, the sources had to be slightly changed, the patch for version 2.4.0 is attached in gist.

      Example sketch code:

      #define MY_DEFAULT_LED_EXT 1
      #define MY_INCLUSION_MODE_FEATURE
      #define MY_INCLUSION_BUTTON_FEATURE
      #define MY_INCLUSION_MODE_DURATION 10
      
      #include <MySensors.h>
      #include <core/MyInclusionMode.h>
      #include <PCF8574.h>
      
      const uint8_t scl_PIN = D1;
      const uint8_t sda_PIN = D2;
      const uint8_t led_device[4] { 2U, 3U, 6U, 4U };
      const uint8_t btn_device[4] { 0U, 1U, 5U, 7U };
      PCF8574 expander(0x22, sda_PIN, scl_PIN);
      
      void setup() {
        Wire.begin(sda_PIN, scl_PIN);
        Serial.begin(115200);
        while (!Serial) delay(50);
        
        for (uint8_t i = 0; i < 4U; i++) {
          expander.pinMode(led_device[i], OUTPUT);
          expander.digitalWrite(led_device[i], HIGH);
          Serial.printf("Init LED expander: %u/%u\n", (uint16_t)i, (uint16_t)led_device[i]);
      
          expander.pinMode(btn_device[i], INPUT);
          expander.digitalWrite(btn_device[i], HIGH);
          Serial.printf("Init BTN expander: %u/%u\n", (uint16_t)i, (uint16_t)btn_device[i]);
        }
        expander.begin();
        ledsSetCb(
          [=](uint8_t & state) { expander.digitalWrite(led_device[1], state); },
          [=](uint8_t & state) { expander.digitalWrite(led_device[2], state); },
          [=](uint8_t & state) { expander.digitalWrite(led_device[3], state); }
        );
        inclusionSetCb(
          [=]() { return (expander.digitalRead(btn_device[0], true) == LOW); },
          [=](uint8_t & state) { expander.digitalWrite(led_device[0], state); }
        );
      }
      
      void loop() {}
      
      
      

      I2C extender
      PCF8574-module-type2-800x800.jpg

      posted in My Project
      Clone Tv
      Clone Tv
    • RE: Where to send messages about battery charge and signal strength?

      C ++ templates work great, the main thing is not to use class->virtual and RTTI. I write C ++ fluently, it's easier for me.
      Thanks for your reply and sorry for my "bad" english.

      posted in MyController.org
      Clone Tv
      Clone Tv
    • RE: Where to send messages about battery charge and signal strength?

      Yes, I found 🙂
      It may be useful for those who might come across this issue later:

      Git MYCONTROLLER repo

      Code for sending RSSI from loop function.
      It is not necessary to announce (present) the RSSI sensor.

                          MY_CRITICAL_SECTION {
                              char *buff = new char[18]{};
                              (void) snprintf(buff, 17, "rssi:%d", rssi);
                              reportMsg(getId(), V_VAR5, buff);
                              delete [] buff;
                          }
      
      
      posted in MyController.org
      Clone Tv
      Clone Tv