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
  1. Home
  2. Troubleshooting
  3. Battery level don't show up

Battery level don't show up

Scheduled Pinned Locked Moved Troubleshooting
dht22vera plugin 1.4pro miniverabattery powered
8 Posts 3 Posters 5.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cheesepower
    wrote on last edited by cheesepower
    #1

    Hello all,

    I encounter an issue with my battery powered sensor.
    It's based on an arduino pro mini 3,3 V, a DHT 22 and powered via a LiPo 3,7V battery.

    It runs on a Vera 3 with the 1.4 library.

    After inclusion, my vera see 1 node, 1 humidity sensor and 1 temperature sensor. The temperature and humidity are working fine, The problem is that the battery level don't show up :-(
    On th serial connection i can see my battery level.

    Here is my code:

    ''''
    #include <SPI.h>
    #include <MySensor.h>
    #include <DHT.h>

    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define HUMIDITY_SENSOR_DIGITAL_PIN 3
    unsigned long SLEEP_TIME = 300000; // Sleep time between reads (in milliseconds)
    int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point

    MySensor gw;
    DHT dht;
    float lastTemp;
    float lastHum;
    boolean metric = true;
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    int oldBatteryPcnt = 0;

    void setup()
    {
    gw.begin();
    dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);

    // Send the Sketch Version Information to the Gateway
    gw.sendSketchInfo("Humidity", "1.0");
    gw.sendSketchInfo("Battery Meter", "1.0");

    // Register all sensors to gw (they will be created as child devices)
    gw.present(CHILD_ID_HUM, S_HUM);
    gw.present(CHILD_ID_TEMP, S_TEMP);

    //metric = gw.getConfig().isMetric;
    }

    void loop()
    {
    delay(dht.getMinimumSamplingPeriod());

    float temperature = dht.getTemperature();
    if (isnan(temperature)) {
    Serial.println("Failed reading temperature from DHT");
    } else if (temperature != lastTemp) {
    lastTemp = temperature;
    if (!metric) {
    temperature = dht.toFahrenheit(temperature);
    }
    gw.send(msgTemp.set(temperature, 1));
    Serial.print("T: ");
    Serial.println(temperature);
    }

    float humidity = dht.getHumidity();
    if (isnan(humidity)) {
    Serial.println("Failed reading humidity from DHT");
    } else if (humidity != lastHum) {
    lastHum = humidity;
    gw.send(msgHum.set(humidity, 1));
    Serial.print("H: ");
    Serial.println(humidity);
    }

    // get the battery Voltage
    int sensorValue = analogRead(BATTERY_SENSE_PIN);
    Serial.println(sensorValue);

    // 1M, 470K divider across battery and using internal ADC ref of 1.1V
    // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
    // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
    // 3.44/1023 = Volts per bit = 0.003363075
    float batteryV = sensorValue * 0.0041;
    int batteryPcnt = sensorValue / 10;

    Serial.print("Input Value: ");
    Serial.println(sensorValue);

    Serial.print("Battery Voltage: ");
    Serial.print(batteryV);
    Serial.println(" V");

    Serial.print("Battery percent: ");
    Serial.print(batteryPcnt);
    Serial.println(" %");

    if (oldBatteryPcnt != batteryPcnt) {
    // Power up radio after sleep
    gw.sendBatteryLevel(batteryPcnt);
    oldBatteryPcnt = batteryPcnt;
    }

    gw.sleep(SLEEP_TIME); //sleep a bit
    }

    ''''

    R 1 Reply Last reply
    0
    • C cheesepower

      Hello all,

      I encounter an issue with my battery powered sensor.
      It's based on an arduino pro mini 3,3 V, a DHT 22 and powered via a LiPo 3,7V battery.

      It runs on a Vera 3 with the 1.4 library.

      After inclusion, my vera see 1 node, 1 humidity sensor and 1 temperature sensor. The temperature and humidity are working fine, The problem is that the battery level don't show up :-(
      On th serial connection i can see my battery level.

      Here is my code:

      ''''
      #include <SPI.h>
      #include <MySensor.h>
      #include <DHT.h>

      #define CHILD_ID_HUM 0
      #define CHILD_ID_TEMP 1
      #define HUMIDITY_SENSOR_DIGITAL_PIN 3
      unsigned long SLEEP_TIME = 300000; // Sleep time between reads (in milliseconds)
      int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point

      MySensor gw;
      DHT dht;
      float lastTemp;
      float lastHum;
      boolean metric = true;
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
      int oldBatteryPcnt = 0;

      void setup()
      {
      gw.begin();
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);

      // Send the Sketch Version Information to the Gateway
      gw.sendSketchInfo("Humidity", "1.0");
      gw.sendSketchInfo("Battery Meter", "1.0");

      // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID_HUM, S_HUM);
      gw.present(CHILD_ID_TEMP, S_TEMP);

      //metric = gw.getConfig().isMetric;
      }

      void loop()
      {
      delay(dht.getMinimumSamplingPeriod());

      float temperature = dht.getTemperature();
      if (isnan(temperature)) {
      Serial.println("Failed reading temperature from DHT");
      } else if (temperature != lastTemp) {
      lastTemp = temperature;
      if (!metric) {
      temperature = dht.toFahrenheit(temperature);
      }
      gw.send(msgTemp.set(temperature, 1));
      Serial.print("T: ");
      Serial.println(temperature);
      }

      float humidity = dht.getHumidity();
      if (isnan(humidity)) {
      Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum) {
      lastHum = humidity;
      gw.send(msgHum.set(humidity, 1));
      Serial.print("H: ");
      Serial.println(humidity);
      }

      // get the battery Voltage
      int sensorValue = analogRead(BATTERY_SENSE_PIN);
      Serial.println(sensorValue);

      // 1M, 470K divider across battery and using internal ADC ref of 1.1V
      // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
      // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
      // 3.44/1023 = Volts per bit = 0.003363075
      float batteryV = sensorValue * 0.0041;
      int batteryPcnt = sensorValue / 10;

      Serial.print("Input Value: ");
      Serial.println(sensorValue);

      Serial.print("Battery Voltage: ");
      Serial.print(batteryV);
      Serial.println(" V");

      Serial.print("Battery percent: ");
      Serial.print(batteryPcnt);
      Serial.println(" %");

      if (oldBatteryPcnt != batteryPcnt) {
      // Power up radio after sleep
      gw.sendBatteryLevel(batteryPcnt);
      oldBatteryPcnt = batteryPcnt;
      }

      gw.sleep(SLEEP_TIME); //sleep a bit
      }

      ''''

      R Offline
      R Offline
      RJ_Make
      Hero Member
      wrote on last edited by
      #2

      @cheesepower I've notice that sometimes it take a while for the indicator to show up in Vera.

      RJ_Make

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cheesepower
        wrote on last edited by
        #3

        My sensor runs for 2 weeks now.

        One more question : where did the battery level is supposed to be ? on the node under a variable or elsewhere ?

        1 Reply Last reply
        0
        • R Offline
          R Offline
          RJ_Make
          Hero Member
          wrote on last edited by
          #4

          Looks like this.....

          Screen Shot 12-11-14 at 02.02 PM.PNG

          RJ_Make

          1 Reply Last reply
          0
          • C Offline
            C Offline
            cheesepower
            wrote on last edited by
            #5

            I have this:

            http://img15.hostingpics.net/pics/796697vera.jpg

            R 1 Reply Last reply
            0
            • M Offline
              M Offline
              m26872
              Hardware Contributor
              wrote on last edited by m26872
              #6

              I assume you've done extensive resets, reloads, reboots of sensor, vera, luup, and gateway in all diffent ways?
              And a little dare to use custom device names before you get it going if you ask me.
              And yes, the battery level as a number is also visible under variables after first receive..

              1 Reply Last reply
              0
              • C cheesepower

                I have this:

                http://img15.hostingpics.net/pics/796697vera.jpg

                R Offline
                R Offline
                RJ_Make
                Hero Member
                wrote on last edited by
                #7

                @cheesepower as @m26872 suggested, you should try a power cycle your equipment.. if that doesn't work...... you have a problem. I can't see any issue in the sketch.

                RJ_Make

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  cheesepower
                  wrote on last edited by cheesepower
                  #8

                  Yes i made several reset, exclusions, inclusions, vera reset and clear EPROM but nothing worked...

                  I made a new sensor and it works perfectly

                  Strange... I will try again when i will have more time.

                  Thanks for the help :D

                  1 Reply Last reply
                  0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  16

                  Online

                  12.0k

                  Users

                  11.2k

                  Topics

                  113.4k

                  Posts


                  Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                  • Login

                  • Don't have an account? Register

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