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. Development
  3. How to get battery volt / percentage message send to mqtt?

How to get battery volt / percentage message send to mqtt?

Scheduled Pinned Locked Moved Development
15 Posts 3 Posters 1.8k Views 3 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.
  • gohanG Offline
    gohanG Offline
    gohan
    Mod
    wrote on last edited by
    #5

    it looks as the analogread keeps returning zero

    M 1 Reply Last reply
    0
    • gohanG gohan

      it looks as the analogread keeps returning zero

      M Offline
      M Offline
      Mr_sensor
      wrote on last edited by
      #6

      @gohan Tried to find out what causing that but can not figure it out. I'm bot a real coderer so its trial and error :) and trying to understand form other sketches / posts. Any idea where to look for?

      1 Reply Last reply
      0
      • gohanG Offline
        gohanG Offline
        gohan
        Mod
        wrote on last edited by
        #7

        try adding a delay(500) before the analogread

        M 1 Reply Last reply
        0
        • gohanG gohan

          try adding a delay(500) before the analogread

          M Offline
          M Offline
          Mr_sensor
          wrote on last edited by
          #8

          @gohan said in How to get battery volt / percentage message send to mqtt?:

          delay(500)

          Hi, tried that (already tried it with wait). Now I added it here:

          delay(500);
              int sensorValue = analogRead(BATTERY_SENSE_PIN);
          

          Also tried it here:

           if (oldBatteryPcnt != batteryPcnt) {
                  // Power up radio after sleep
                  delay(500);       
                  sendBatteryLevel(batteryPcnt);
                  oldBatteryPcnt = batteryPcnt;
              } 
                                                                                                                                                                                
            sleep(SLEEP_TIME); //sleep a bit  ```
          
          Both did not help still ending up with 0 . 
          So what should be the best place the right place to put the delay?
          1 Reply Last reply
          0
          • gohanG Offline
            gohanG Offline
            gohan
            Mod
            wrote on last edited by
            #9

            the second one is useless. It is odd that it misses the analog reads. What AVR boards version are you using?

            M 1 Reply Last reply
            0
            • gohanG gohan

              the second one is useless. It is odd that it misses the analog reads. What AVR boards version are you using?

              M Offline
              M Offline
              Mr_sensor
              wrote on last edited by
              #10

              @gohan I'm using the EasyPCB board with an arduino pro mini 3,3v

              1 Reply Last reply
              0
              • gohanG Offline
                gohanG Offline
                gohan
                Mod
                wrote on last edited by
                #11

                I mean in Arduino IDE library manager

                M 1 Reply Last reply
                0
                • gohanG gohan

                  I mean in Arduino IDE library manager

                  M Offline
                  M Offline
                  Mr_sensor
                  wrote on last edited by
                  #12

                  @gohan

                  Arduino Pro or Pro Mini
                  Programmer AVR ISP
                  ATmega328P (3,3v 8mhz)

                  M 1 Reply Last reply
                  0
                  • M Mr_sensor

                    @gohan

                    Arduino Pro or Pro Mini
                    Programmer AVR ISP
                    ATmega328P (3,3v 8mhz)

                    M Offline
                    M Offline
                    Mr_sensor
                    wrote on last edited by
                    #13

                    Still not getting it working! Any thoughts on this?

                    1 Reply Last reply
                    0
                    • gohanG Offline
                      gohanG Offline
                      gohan
                      Mod
                      wrote on last edited by
                      #14

                      Try a simple example sketch that reads the analog pin just to make sure the hardware is OK, or try another pro mini

                      M 1 Reply Last reply
                      0
                      • gohanG gohan

                        Try a simple example sketch that reads the analog pin just to make sure the hardware is OK, or try another pro mini

                        M Offline
                        M Offline
                        Mr_sensor
                        wrote on last edited by
                        #15

                        @gohan Ok will try that see if I made a fault somewhere

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        21

                        Online

                        11.7k

                        Users

                        11.2k

                        Topics

                        113.0k

                        Posts


                        Copyright 2019 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