Navigation

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

    Topics created by ShadeX12

    • ShadeX12

      ESP8266 Gateway with local sensors stuck in loop
      Troubleshooting • • ShadeX12  

      6
      0
      Votes
      6
      Posts
      52
      Views

      Karl-Heinz K

      @ShadeX12 Hello, maybe these links will provide the necessary background information to solve your problem: Basics about ESP8266 sleep modes: https://www.losant.com/blog/making-the-esp8266-low-powered-with-deep-sleep Extensive discussion of this topic: https://github.com/esp8266/Arduino/issues/1488 Especially this citation might be interesting: "GPIO16 is connected to CH_DP for deepSleep. and pulled low during deepSleep. if CH_DP goes high the chip wakes up. for what reason the high signal comes from does not mater. can be the RTC timer or any other electrical stuff connected to CH_DP. so adding a pullup to CH_DP and a switch that is normally close to GPIO16 will work fine." Excellent summary, how to work with interrupts in general on the ESP8266: https://techtutorialsx.com/2016/12/11/esp8266-external-interrupts/ Good luck with your project. Karl-Heinz
    • ShadeX12

      Sketch kills batteries in 2-3 days
      Development • • ShadeX12  

      8
      0
      Votes
      8
      Posts
      435
      Views

      tbowmo

      @wahid As an example, I have 4 sensebender micros, which has been deployed since june 2015, I have not changed batteries in them yet, and they still report temperature / humidity (that's more than 4 years battery life!). The batteries are cheap AA alkaline types (2 pieces).. I'm not doing anything special (hardware wise) to power off the radio, or any other peripherals on the board. Only using standard software powerdown where available.
    • ShadeX12

      Adding Door sensor to Multisensor not working...
      Troubleshooting • • ShadeX12  

      8
      0
      Votes
      8
      Posts
      2111
      Views

      ShadeX12

      Okay I figured this out! The problem was actually with where I was defining the pins. They where withing the if statement for the DHT warning. I have moved them outside that statement and it seems to be working fine. /** * 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 * Motion Sensor example using HC-SR501 * http://www.mysensors.org/build/motion * */ // Enable debug prints #define MY_DEBUG #define MY_NODE_ID 233 #define MY_PARENT_NODE_ID 0 #define MY_PARENT_NODE_IS_STATIC // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #include <MySensors.h> #include <SPI.h> #include <DHT.h> #include <Bounce2.h> unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds) #define DIGITAL_INPUT_SENSOR 2 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define DIGITAL_INPUT_SENSOR2 3 // The input for door sensor #define CHILD_ID_MOTION 1 // Id of the sensor child #define CHILD_ID_HUM 2 #define CHILD_ID_TEMP 3 #define CHILD_ID_DOOR 4 // Set this to the pin you connected the DHT's data pin to #define DHT_DATA_PIN 4 // Set this offset if the sensor has a permanent small offset to the real temperatures #define SENSOR_TEMP_OFFSET 0 // Force sending an update of the temperature after n sensor reads, so a controller showing the // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that // the value didn't change since; // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms] static const uint8_t FORCE_UPDATE_N_READS = 10; float lastTemp; float lastHum; uint8_t nNoUpdatesTemp; uint8_t nNoUpdatesHum; bool metric = true; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); // Initialize motion message MyMessage msg(CHILD_ID_MOTION, V_TRIPPED); MyMessage msgDoor(CHILD_ID_DOOR, V_TRIPPED); DHT dht; void presentation() { // Send the sketch version information to the gateway sendSketchInfo("TemperatureAndHumidity", "1.1"); // Register all sensors to gw (they will be created as child devices) present(CHILD_ID_HUM, S_HUM); present(CHILD_ID_TEMP, S_TEMP); present(CHILD_ID_MOTION, S_MOTION); present(CHILD_ID_DOOR, S_DOOR); metric = getControllerConfig().isMetric; } void setup() { dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor if (1200000 <= dht.getMinimumSamplingPeriod()) { Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!"); } // Sleep for the time of the minimum sampling period to give the sensor time to power up // (otherwise, timeout errors might occure for the first reading) sleep(dht.getMinimumSamplingPeriod()); pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input pinMode(DIGITAL_INPUT_SENSOR2, INPUT); // sets the door sensor digital pin as input digitalWrite(DIGITAL_INPUT_SENSOR2,HIGH); // Activate internal pull-up } void loop() { // Force reading sensor, so it works also after sleep() dht.readSensor(true); // Get temperature from DHT library float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT!"); } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) { // Only send temperature if it changed since the last measurement or if we didn't send an update for n times lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } // Reset no updates counter nNoUpdatesTemp = 0; temperature += SENSOR_TEMP_OFFSET; send(msgTemp.set(temperature, 1)); #ifdef MY_DEBUG Serial.print("T: "); Serial.println(temperature); #endif } else { // Increase no update counter if the temperature stayed the same nNoUpdatesTemp++; } // Get humidity from DHT library float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) { // Only send humidity if it changed since the last measurement or if we didn't send an update for n times lastHum = humidity; // Reset no updates counter nNoUpdatesHum = 0; send(msgHum.set(humidity, 1)); #ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif } else { // Increase no update counter if the humidity stayed the same nNoUpdatesHum++; } // Read digital motion value bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; Serial.println(tripped); send(msg.set(tripped?"1":"0")); // Send tripped value to gw // Read digital door value bool tripped2 = digitalRead(DIGITAL_INPUT_SENSOR2) == HIGH; Serial.println(tripped2); send(msgDoor.set(tripped2?"1":"0")); // Send tripped value to gw // Sleep until interrupt comes in on motion sensor. Send update every two minute. sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, digitalPinToInterrupt(DIGITAL_INPUT_SENSOR2), CHANGE, SLEEP_TIME); } Thanks again for all your help everyone!