Navigation

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

    el tigro

    @el tigro

    2
    Reputation
    28
    Posts
    469
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    el tigro Follow

    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

    Latest posts made by el tigro

    • RE: HA not seeing sensors.

      SOLVED..... Such a mug, such a small error. One character missing in wireless key.

      posted in Home Assistant
      el tigro
      el tigro
    • RE: HA not seeing sensors.

      NODE CODE
      #define MY_DEBUG
      #define MY_RADIO_NRF24
      #define MY_NODE_ID 66
      #include <SPI.h>
      #include <MySensors.h>
      #include <Bounce2.h>
      #define RELAY_PIN 7
      #define BUTTON_PIN 6
      #define CHILD_ID 2
      #define RELAY_ON 1
      #define RELAY_OFF 0
      #include <SPI.h>
      #include <avr/wdt.h>
      #include <Wire.h>
      #define RESETWATCHDOG
      Bounce debouncer = Bounce();
      bool state = false;
      bool initialValueSent = false;

      MyMessage msg(CHILD_ID, V_STATUS);

      void setup()
      {
      Serial.begin(115200);
      pinMode(BUTTON_PIN, INPUT_PULLUP);
      debouncer.attach(BUTTON_PIN);
      debouncer.interval(10);
      digitalWrite(RELAY_PIN, RELAY_ON);
      pinMode(RELAY_PIN, OUTPUT);
      }

      void presentation() {
      sendSketchInfo("Grey Lamp", "1.0");
      present(CHILD_ID, S_BINARY);
      }

      void loop()
      {
      wdt_reset();
      if (!initialValueSent) {
      Serial.println("Sending initial value");
      send(msg.set(state ? RELAY_ON : RELAY_OFF));
      Serial.println("Requesting initial value from controller");
      request(CHILD_ID, V_STATUS);
      wait(2000, C_SET, V_STATUS);
      }

      if (debouncer.update()) {
      if (debouncer.read() == LOW) {
      state = !state;
      send(msg.set(state ? RELAY_ON : RELAY_OFF), true);
      }
      }

      }

      void receive(const MyMessage &message) {
      if (message.isAck()) {
      Serial.println("This is an ack from gateway");
      }

      if (message.type == V_STATUS) {
      if (!initialValueSent) {
      Serial.println("Receiving initial value from controller");
      initialValueSent = true;
      }
      state = (bool)message.getInt();
      digitalWrite(RELAY_PIN, !state ? RELAY_ON : RELAY_OFF);
      send(msg.set(state ? RELAY_ON : RELAY_OFF));
      }
      }

      posted in Home Assistant
      el tigro
      el tigro
    • RE: HA not seeing sensors.

      @el-tigro
      I have other nodes / devices and they all do the same.
      HA config

      mysensors:
      gateways:
      - device: '/dev/ttyUSB0'
      persistence_file: '/config/myhouse/mysensors.json'
      - device: mqtt
      persistence_file: '/config/myhouse/mysensors4.json'
      topic_in_prefix: 'mygateway1-out'
      topic_out_prefix: 'mygateway1-in'
      optimistic: false
      persistence: true
      retain: true
      version: '2.0'

      mqtt:
      broker: 192.168.1.***
      port: 1883
      client_id: home-assistant-1
      keepalive: 60

      Gateway code

      #define MY_DEBUG
      #define MY_BAUD_RATE 115200
      #define MY_RADIO_NRF24
      #define MY_GATEWAY_MQTT_CLIENT
      #define MY_GATEWAY_ESP8266
      #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
      #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
      #define MY_MQTT_CLIENT_ID "Gateway"
      #define MY_ESP8266_SSID "BTHub6-36PM"
      #define MY_ESP8266_PASSWORD "88888888"
      #define MY_ESP8266_HOSTNAME "Gateway node"
      #define MY_CONTROLLER_IP_ADDRESS 192, 168, 1,***
      #define MY_IP_GATEWAY_ADDRESS 192,168,1,***
      #define MY_IP_SUBNET_ADDRESS 255,255,255,0
      #define MY_PORT 1883
      #include <ESP8266WiFi.h>
      #include <MySensors.h>

      void setup() {
      }

      void presentation() {
      // Present locally attached sensors here
      }

      void loop() {
      // Send locally attech sensors data here
      }

      posted in Home Assistant
      el tigro
      el tigro
    • RE: HA not seeing sensors.

      @monte
      Node debug. Appears to register but then no response to initial value request.
      0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
      3 TSM:INIT
      4 TSF:WUR:MS=0
      11 TSM:INIT:TSP OK
      12 TSM:INIT:STATID=66
      15 TSF:SID:OK,ID=66
      16 TSM:FPAR
      53 TSF:MSG:SEND,66-66-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      192 TSF:MSG:READ,0-0-66,s=255,c=3,t=8,pt=1,l=1,sg=0:0
      197 TSF:MSG:FPAR OK,ID=0,D=1
      2060 TSM:FPAR:OK
      2061 TSM:ID
      2062 TSM:ID:OK
      2064 TSM:UPL
      2069 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      2082 TSF:MSG:READ,0-0-66,s=255,c=3,t=25,pt=1,l=1,sg=0:1
      2086 TSF:MSG:PONG RECV,HP=1
      2089 TSM:UPL:OK
      2092 TSM:READY:ID=66,PAR=0,DIS=1
      2096 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
      2103 TSF:MSG:READ,0-0-66,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
      2110 TSF:MSG:SEND,66-66-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
      2118 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
      4127 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=11,pt=0,l=9,sg=0,ft=0,st=OK:Grey Lamp
      4135 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
      4144 TSF:MSG:SEND,66-66-0-0,s=2,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
      4150 MCO:REG:REQ
      4153 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
      4176 TSF:MSG:READ,0-0-66,s=255,c=3,t=27,pt=1,l=1,sg=0:1
      4182 MCO:PIM:NODE REG=1
      4184 MCO:BGN:STP
      4185 MCO:BGN:INIT OK,TSP=1
      Sending initial value
      4190 TSF:MSG:SEND,66-66-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
      Requesting initial value from controller
      4198 TSF:MSG:SEND,66-66-0-0,s=2,c=2,t=2,pt=0,l=0,sg=0,ft=0,st=OK:
      Sending initial value
      6207 TSF:MSG:SEND,66-66-0-0,s=2,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:0
      Requesting initial value from controller

      posted in Home Assistant
      el tigro
      el tigro
    • HA not seeing sensors.

      I'm going crazy, any help appreciated.

      My setup.
      Pi 3 controller on ethernet.
      HASSOS recently installed.
      MQTT.
      NodeMCU 09 wifi gateway.
      My sensors switch / lamp.

      Nodes and gateway talking fine. Controller and gateway register with MQTT server on HA (mosquitto).

      Nodes are registering with gateway but not getting 'initial value' back from HA and repeats request.

      This happened after I updated HA. Any help appreciated.

      posted in Home Assistant
      el tigro
      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
    • combining button with dht11 issue

      Hi.
      I have put a dht11 sensor on my arduino nano light switch. The hardware switch is incase no UI or ALEXA down. I don't need the humidity component so I removed it.

      
      #define MY_DEBUG
      #define MY_RADIO_NRF24
      #define MY_REPEATER_FEATURE
      #define MY_NODE_ID 5
      #include <SPI.h>
      #include <MySensors.h> 
      #include <elapsedMillis.h> 
      #include <Bounce2.h>
      #include <DHT.h>
      #define DHT_DATA_PIN 7
      #define RELAY_PIN  5
      #define BUTTON_PIN  3
      #define CHILD_ID 1
      #define RELAY_ON 1
      #define RELAY_OFF 0
      #define SENSOR_TEMP_OFFSET 0
      static const uint64_t UPDATE_INTERVAL = 5000;
      static const uint8_t FORCE_UPDATE_N_READS = 1;
      Bounce debouncer = Bounce();
      bool state = false;
      bool initialValueSent = false;
      #define CHILD_ID_TEMP 3
      unsigned long interval=10000; // the time we need to wait
      unsigned long previousMillis=0; // millis() returns an unsigned long.
      float lastTemp;
      
      uint8_t nNoUpdatesTemp;
      bool metric = true;
      MyMessage msg(CHILD_ID, V_STATUS);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      DHT dht;
      
      
      void presentation()  
      { 
        sendSketchInfo("kitchen switch", "1.1");
        
        present(CHILD_ID, S_BINARY);
       present(CHILD_ID_TEMP, S_TEMP);
        metric = getConfig().isMetric;
      }
      
      void setup()
      {
        pinMode(BUTTON_PIN, INPUT_PULLUP);
        debouncer.attach(BUTTON_PIN);
        debouncer.interval(10);
        digitalWrite(RELAY_PIN, RELAY_OFF);
        pinMode(RELAY_PIN, OUTPUT);
        
        dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
        if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
          Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
        }
      }
      
      void loop()      
      {  
       
      if (!initialValueSent) {
          Serial.println("Sending initial value");
          send(msg.set(state?RELAY_ON:RELAY_OFF));
          Serial.println("Requesting initial value from controller");
          request(CHILD_ID, V_STATUS);
          wait(5000, C_SET, V_STATUS);
          presentation();
        }
        if (debouncer.update()) {
          if (debouncer.read()==LOW) {
            state = !state;
          send(msg.set(state?RELAY_ON:RELAY_OFF), true);   
          }
        }
      
       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();
       }}
      void receive(const MyMessage &message) {
        if (message.isAck()) {
           Serial.println("This is an ack from gateway");
        }
        if (message.type == V_STATUS) {
          if (!initialValueSent) {
            Serial.println("Receiving initial value from controller");
            initialValueSent = true;
          }
          state = (bool)message.getInt();
          digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF);
          send(msg.set(state?RELAY_ON:RELAY_OFF));
        }
      }
      

      my problem is that the temp shows ok, the switch sends commands when tripped but is not on the Home Assistant UI or in entities. I need this switch to show up to set triggers.

      Any help appreciated

      Pi3 Home assistant + mosquitto
      esp8266 wireless gateway
      nano nodes Nrf2401 radios

      posted in My Project
      el tigro
      el tigro
    • RE: A Basic domestic 240v light and switch.
      1485777547: Sending PINGRESP to mysensors-1
      1485777562: Received PINGREQ from mysensors-1
      1485777562: Sending PINGRESP to mysensors-1
      1485777563: Received PUBLISH from mysensors-1 (d0, q0, r0, m0, 'mygateway1-out/5/25/1/0/16', ... (1 bytes))
      1485777563: Sending PUBLISH to home-assistant-1 (d0, q0, r0, m0, 'mygateway1-out/5/25/1/0/16', ... (1 bytes))
      1485777565: Received PUBLISH from mysensors-1 (d0, q0, r0, m0, 'mygateway1-out/5/25/1/0/16', ... (1 bytes))
      1485777565: Sending PUBLISH to home-assistant-1 (d0, q0, r0, m0, 'mygateway1-out/5/25/1/0/16', ... (1 bytes))
      
      

      This is the mqtt log for one on / off cycle.

      posted in Development
      el tigro
      el tigro
    • RE: A Basic domestic 240v light and switch.

      Here is the most basic sketch I could find and tweaked the code to run as a toggle on a domestic light switch.

      #define MY_RADIO_NRF24
      #include <MySensors.h>
      #include <SPI.h>
      #define MY_NODE_ID 25
      #define OPEN 1
      #define CLOSE 0
      #define switchpin 3
      int oldvalue = OPEN;
      MyMessage msg(MY_NODE_ID, V_TRIPPED);
      uint8_t value = OPEN;
      
      void setup()
      {
        pinMode (switchpin, INPUT_PULLUP);
      }
      
      void presentation()
      {
        sendSketchInfo("TESTER", "");
        present(MY_NODE_ID, S_DOOR);
      }
      
      void loop()
      {
        if (digitalRead(switchpin) == !oldvalue)
        {
          value = value == OPEN ? CLOSE : OPEN;
          send(msg.set(value));
          oldvalue = value;
        }
      }
      

      With this code alone,no yaml entry, the node is found by HA and shows accordingly as triggered if the switch is flicked. mqtt all good, gateway happy.

      How the fook do I attach switch result to the intended node?
      Do I need a yaml entry for the physical switch? I tried but failed.
      Do I then need to set up a trigger?

      switch:
        - platform: mqtt
          name: "TESTER"
          command_topic: "mygateway1-in/2/2/1/0/2"
          payload_on: "1"
          payload_off: "0"
          optimistic: false
          qos: 0
          retain: true
      
      

      This just gives me a new (software) switch in my dash and controls the light but physical switch (node 2 child 2) doesn't work.

      posted in Development
      el tigro
      el tigro
    • RE: A Basic domestic 240v light and switch.

      Hello mate and thanks for chirping in. I realised a while ago that this project was well above my current knowledge base but thats like a red rag to bull, stubborn old git that I am.

      After I got my HA, mqtt, MySensors and the gateway talking, my first few nodes found and set themselves up pretty much. I didn't have to jump into message construction, pub/sub, complex yaml code and that's the bit I'm stuck on. Once I get it, I'm away, the penny just hasn't dropped yet.

      I think I need a night in, just me and mqtt, a nice meal, a bottle of soco, a few cuddles and really get to know each other. I guess thats true cyber sex, i do have a wife and kids.... honest.

      Any reccommended sites, tutorials will be appreciated.

      Cheers

      posted in Development
      el tigro
      el tigro