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
C

Clone Tv

@Clone Tv
About
Posts
16
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Gateway - I2C Advanced button and led
    C Clone Tv

    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

    My Project httpsgist.github.comclclon

  • Where to send messages about battery charge and signal strength?
    C Clone Tv

    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.

    MyController.org

  • Where to send messages about battery charge and signal strength?
    C Clone Tv

    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;
                        }
    
    
    MyController.org
  • Login

  • Don't have an account? Register

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