Navigation

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

    Best posts made by ehome

    • [SOLVED] ESP8266 MySensors 2.2.0 problem with static ip configuration

      Hi all,

      EDIT 2018/06/10: Solution:
      It seems that some old wifi settings on my ESP8266 module has conflicted with the MySensors gateway sketch. I was able to set an static ip address after an complete erase of sketch and flash through Arduino IDE. - Thanks!

      ==================================================================================

      If I try to configure my very basic (nearly plain) new ESP8266 MySensors 2.2.0 gateway with an static ip address then I get in serial monitor the following repeating output:
      (Log parser do not have further information for this specific error?)

      48 MCO:BGN:INIT GW,CP=RRNGE---,VER=2.2.0
      91 TSF:LRT:OK
      106 TSM:INIT
      119 TSF:WUR:MS=0
      139 TSM:INIT:TSP OK
      160 TSM:INIT:GW MODE
      scandone
      state: 0 -> 2 (b0)
      state: 2 -> 3 (0)
      state: 3 -> 5 (10)
      add 0
      aid 1
      cnt
      
      connected with SSID, channel 5
      dhcp client start...
      331 TSM:READY:ID=0,PAR=0,DIS=0
      364 MCO:REG:NOT NEEDED
      scandone
      889 GWT:TPC:CONNECTING...
      1416 GWT:TPC:CONNECTING...
      1944 GWT:TPC:CONNECTING...
      2472 GWT:TPC:CONNECTING...
      3000 GWT:TPC:CONNECTING...
      3528 GWT:TPC:CONNECTING...
      4056 GWT:TPC:CONNECTING...
      4584 GWT:TPC:CONNECTING...
      5112 GWT:TPC:CONNECTING...
      5640 GWT:TPC:CONNECTING...
      6168 GWT:TPC:CONNECTING...
      6696 GWT:TPC:CONNECTING...
      7224 GWT:TPC:CONNECTING...
      7752 GWT:TPC:CONNECTING...
      8280 GWT:TPC:CONNECTING...
      

      If I switch to dhcp then everything is working like expected.
      And of course the ip is not already assigned by an different device 😉

      What I am doing wrong?

      ␀�/��␝���48 MCO:BGN:INIT GW,CP=RRNGE---,VER=2.2.0
      91 TSF:LRT:OK
      105 TSM:INIT
      119 TSF:WUR:MS=0
      139 TSM:INIT:TSP OK
      160 TSM:INIT:GW MODE
      scandone
      state: 0 -> 2 (b0)
      state: 2 -> 3 (0)
      state: 3 -> 5 (10)
      add 0
      aid 1
      cnt
      
      connected with SSID channel 5
      dhcp client start...
      331 TSM:READY:ID=0,PAR=0,DIS=0
      363 MCO:REG:NOT NEEDED
      scandone
      889 GWT:TPC:CONNECTING...
      1416 GWT:TPC:CONNECTING...
      1944 GWT:TPC:CONNECTING...
      2472 GWT:TPC:CONNECTING...
      3000 GWT:TPC:CONNECTING...
      ip:10.0.8.160,mask:255.255.255.0,gw:10.0.8.253
      3528 GWT:TPC:CONNECTING...
      3556 GWT:TPC:IP=10.0.8.160
      3584 MCO:BGN:STP
      
      -- STA (client) informations --
      Hostname: mqtt-sensor-gateway1
      Connected to: SSID (xx:xx:xx:xx:xx:xx), -45dBm
      IP address: 10.0.8.160
      Gateway address: 10.0.8.253
      Subnet mask: 255.255.255.0
      MAC STA address: xx:xx:xx:xx:xx:xx
      -- AP (server) informations --
      Soft IP address: 0.0.0.0
      MAC AP address: xx:xx:xx:xx:xx:xx
      ----
      
      3826 MCO:BGN:INIT OK,TSP=1
      3986 GWT:TPC:IP=10.0.8.160
      4014 GWT:RMQ:MQTT RECONNECT
      4058 GWT:RMQ:MQTT CONNECTED
      4087 GWT:TPS:TOPIC=ehome/gateway1-out/0/255/0/0/18,MSG SENT
      pm open,type:2 0
      

      Sketch:

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0 - Henrik Ekblad
       *
       * DESCRIPTION
       * The ESP8266 MQTT gateway sends radio network (or locally attached sensors) data to your MQTT broker.
       * The node also listens to MY_MQTT_TOPIC_PREFIX and sends out those messages to the radio network
       *
       * LED purposes:
       * - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs in your sketch
       * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
       * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
       * - ERR (red) - fast blink on error during transmission error or recieve crc error
       *
       * See http://www.mysensors.org/build/esp8266_gateway for wiring instructions.
       * nRF24L01+  ESP8266
       * VCC        VCC
       * CE         GPIO4
       * CSN/CS     GPIO15
       * SCK        GPIO14
       * MISO       GPIO12
       * MOSI       GPIO13
       *
       * Not all ESP8266 modules have all pins available on their external interface.
       * This code has been tested on an ESP-12 module.
       * The ESP8266 requires a certain pin configuration to download code, and another one to run code:
       * - Connect REST (reset) via 10K pullup resistor to VCC, and via switch to GND ('reset switch')
       * - Connect GPIO15 via 10K pulldown resistor to GND
       * - Connect CH_PD via 10K resistor to VCC
       * - Connect GPIO2 via 10K resistor to VCC
       * - Connect GPIO0 via 10K resistor to VCC, and via switch to GND ('bootload switch')
       *
        * Inclusion mode button:
       * - Connect GPIO5 via switch to GND ('inclusion switch')
       *
       * Hardware SHA204 signing is currently not supported!
       *
       * Make sure to fill in your ssid and WiFi password below for ssid & pass.
       */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
      #define MY_BAUD_RATE 9600
      
      // Enables and select radio type (if attached)
      //#define MY_RADIO_NRF24
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      #define MY_RADIO_RFM69
      #define MY_RFM69_FREQUENCY RFM69_433MHZ // Set your frequency here
      //#define MY_IS_RFM69HW // Omit if your RFM is not "H"
      #define MY_RF69_IRQ_PIN D1
      #define MY_RF69_IRQ_NUM MY_RF69_IRQ_PIN
      #define MY_RFM69_CS_PIN D8 // NSS. Use MY_RF69_SPI_CS for older versions (before 2.2.0)
      
      #define MY_RFM69_NETWORKID 200 // Default is 100 in lib. Uncomment it and set your preferred network id if needed
      
      #define MY_GATEWAY_MQTT_CLIENT
      #define MY_GATEWAY_ESP8266
      
      // Set this node's subscribe and publish topic prefix
      #define MY_MQTT_PUBLISH_TOPIC_PREFIX "ehome/gateway1-out"
      #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "ehome/gateway1-in"
      
      // Set MQTT client id
      #define MY_MQTT_CLIENT_ID "ehome-gw-1"
      
      // Set WIFI SSID and password
      #define MY_ESP8266_SSID "MySSID"
      #define MY_ESP8266_PASSWORD "MyPassword"
      
      // Set the hostname for the WiFi Client. This is the hostname
      // it will pass to the DHCP server if not static.
      #define MY_ESP8266_HOSTNAME "mqtt-sensor-gateway1"
      
      // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
      #define MY_IP_ADDRESS 10, 0, 8, 200
      
      // If using static ip you can define Gateway and Subnet address as well
      #define MY_IP_GATEWAY_ADDRESS 10, 0, 8, 253
      #define MY_IP_SUBNET_ADDRESS 255, 255, 255, 0
      
      // MQTT broker ip address.
      #define MY_CONTROLLER_IP_ADDRESS 10, 0, 12, 200
      
      // Enable these if your MQTT broker requires username/password
      #define MY_MQTT_USER "MyUsername"
      #define MY_MQTT_PASSWORD "MyPassword"
      
      // The MQTT broker port to to open
      #define MY_PORT 1883
      
      // Enable inclusion mode
      //#define MY_INCLUSION_MODE_FEATURE
      // Enable Inclusion mode button on gateway
      //#define MY_INCLUSION_BUTTON_FEATURE
      // Set inclusion mode duration (in seconds)
      //#define MY_INCLUSION_MODE_DURATION 60
      // Digital pin used for inclusion mode button
      //#define MY_INCLUSION_MODE_BUTTON_PIN  3
      
      // Set blinking period
      //#define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Flash leds on rx/tx/err
      //#define MY_DEFAULT_ERR_LED_PIN 16  // Error led pin
      //#define MY_DEFAULT_RX_LED_PIN  16  // Receive led pin
      //#define MY_DEFAULT_TX_LED_PIN  16  // the PCB, on board LED
      
      #include <ESP8266WiFi.h>
      #include <ArduinoOTA.h>
      #include <MySensors.h>
      
      void setup()
      {
        // Setup locally attached sensors
      #if defined MY_DEBUG
        if (WiFi.status() != WL_CONNECTED)
        {
          Serial.println("Not connected to WiFi");
        }
        else
        {
          Serial.println("");
          Serial.println("-- STA (client) informations --");
          Serial.print("Hostname: ");
          Serial.println(WiFi.hostname());
          Serial.print("Connected to: ");
          Serial.print(WiFi.SSID());
          Serial.print(" (");
          Serial.print(WiFi.BSSIDstr());
          Serial.print("), ");
          Serial.print(WiFi.RSSI());
          Serial.println("dBm");
          Serial.print("IP address: ");
          Serial.println(WiFi.localIP());
          Serial.print("Gateway address: ");
          Serial.println(WiFi.gatewayIP());
          Serial.print("Subnet mask: ");
          Serial.println(WiFi.subnetMask());
          Serial.print("MAC STA address: ");
          Serial.println(WiFi.macAddress());
          Serial.println("-- AP (server) informations --");
          Serial.print("Soft IP address: ");
          Serial.println(WiFi.softAPIP());
          Serial.print("MAC AP address: ");
          Serial.println(WiFi.softAPmacAddress());
          Serial.println("----");
          Serial.println("");
        }
      #endif
        ArduinoOTA.onStart([]() {
          Serial.println("ArduinoOTA start");
        });
        ArduinoOTA.onEnd([]() {
          Serial.println("\nArduinoOTA end");
        });
        ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
          Serial.printf("OTA Progress: %u%%\r", (progress / (total / 100)));
        });
        ArduinoOTA.onError([](ota_error_t error) {
          Serial.printf("Error[%u]: ", error);
          if (error == OTA_AUTH_ERROR)
          {
            Serial.println("Auth Failed");
          }
          else if (error == OTA_BEGIN_ERROR)
          {
            Serial.println("Begin Failed");
          }
          else if (error == OTA_CONNECT_ERROR)
          {
            Serial.println("Connect Failed");
          }
          else if (error == OTA_RECEIVE_ERROR)
          {
            Serial.println("Receive Failed");
          }
          else if (error == OTA_END_ERROR)
          {
            Serial.println("End Failed");
          }
        });
        ArduinoOTA.begin();
      }
      
      void presentation()
      {
        // Present locally attached sensors here
      }
      
      void loop()
      {
        // Send locally attech sensors data here
        ArduinoOTA.handle();
      }
      
      
      posted in Development
      ehome
      ehome
    • RE: Looking for reliable PIR human detection sensors

      @silex I know these IR-Array sensors. But at the moment they are very expensive.
      And I think also the detection range and angle is not as good as from an PIR.

      I need a minimum range of 5-7m and tests I have seen on youtube just covered 2-3m.

      But I also see the big advantage to have human detection without active motion. With these devices it is possible to create real presence detection sensors.

      posted in Hardware
      ehome
      ehome