Navigation

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

    Best posts made by el tigro

    • RE: combining button with dht11 issue

      sorted works a treat now. My bad, used a sketch I had tinkered with in the past. sketches melded now. Finished sketch below for them that might need. The sketch is for domestic light swith.

      #define MY_NODE_ID 5
      #define MY_DEBUG
      #define MY_RADIO_NRF24
      #include <SPI.h>
      #include <MySensors.h>
      #include <Bounce2.h>
      #include <DHT.h>
      #define DHT_DATA_PIN 7
      #define CHILD_ID 3
      #define BUTTON_PIN  3
      #define SENSOR_TEMP_OFFSET 0
      #define CHILD_ID_TEMP 1
      Bounce debouncer = Bounce();
      static const uint64_t UPDATE_INTERVAL = 5000;
      static const uint8_t FORCE_UPDATE_N_READS = 2;
      float lastTemp;
      unsigned long interval = 5000;
      unsigned long previousMillis = 0;
      uint8_t nNoUpdatesTemp;
      int oldValue = -1;
      bool metric = true;
      MyMessage msg(CHILD_ID, V_LIGHT);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      DHT dht;
      
      
      void presentation()
      {
        sendSketchInfo("kitchen Lights", "1.1");
        present(CHILD_ID, S_LIGHT);
        present(CHILD_ID_TEMP, S_TEMP);
        metric = getConfig().isMetric;
      }
      
      void setup()
      {
        pinMode(BUTTON_PIN, INPUT);
        digitalWrite(BUTTON_PIN, HIGH);
        debouncer.attach(BUTTON_PIN);
        debouncer.interval(5);
        dht.setup(DHT_DATA_PIN);
        if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
          Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
        }
      }
      
      void loop()
      {
        debouncer.update();
        int value = debouncer.read();
        if (value != oldValue) {
          send(msg.set(value == HIGH ? 1 : 0));
          oldValue = value;
        }
        unsigned long currentMillis = millis();
        if ((unsigned long)(currentMillis - previousMillis) >= interval) {
          dht.readSensor(true);
          float temperature = dht.getTemperature();
          if (isnan(temperature)) {
            Serial.println("Failed reading temperature from DHT!");
          } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
            lastTemp = temperature;
            if (!metric) {
              temperature = dht.toFahrenheit(temperature);
            }
            nNoUpdatesTemp = 0;
            temperature += SENSOR_TEMP_OFFSET;
            send(msgTemp.set(temperature, 1));
      #ifdef MY_DEBUG
            Serial.print("T: ");
            Serial.println(temperature);
      #endif
          } else {
            nNoUpdatesTemp++;
          }
          previousMillis = millis();
        }
      }
      
      posted in My Project
      el tigro
      el tigro
    • RE: Struggling with configure.yaml

      Well, the sun shines on a dogs arse some days.

      We've only gone and done it, HA dash with relay sw. can controll led from dash. I honestly have sticky stuff running down my leg. You have no idea how happy I am.

      For future reference.
      I was flicking the power to reset pi in between config changes. My mosquitto was not starting from boot, so nothing to connect to, hence the errors when the code was right.
      Also reset your nodes after a change.

      This my yaml for the following setup

      nodes are arduino nanos with nrf2401+ radio. (mysensors 2.0)

      gateway is esp8266 NodeMCU 1.09. Wifi with NRF2401+

      Pi 3 hosts Home Assistant and Mosquitto broker. Installed with All in one image.

      mysensors:
        gateways:
          - device: mqtt
            persistence_file: '/home/homeassistant/mysensors4.json'
            topic_in_prefix: 'mygateway1-out'
            topic_out_prefix: 'mygateway1-in'
        debug: true
        optimistic: false
        persistence: true
        retain: true
        version: 2.0
      
      mqtt:
        broker: localhost
        port: 1883
        client_id: home-assistant-1
        keepalive: 60
      

      Righty. I'm off to play. Be back very soon when i get stuck.

      Cheers for now fella, thank you for all your help.

      posted in Home Assistant
      el tigro
      el tigro