Skip to content
  • 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. My Project
  3. Chinese Solar Lipo powered PIR led lamp.
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

Chinese Solar Lipo powered PIR led lamp.

Scheduled Pinned Locked Moved My Project
42 Posts 9 Posters 26.5k Views 19 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.
  • korttomaK Offline
    korttomaK Offline
    korttoma
    Hero Member
    wrote on last edited by
    #33

    In the application I will use this one I actually do not care so much for the built in PIR and LED, I just see it as a smart enclosure with a solar battery power-supply built in. I will tap in to the 3.3V regulator to power a pro mini that has an external PIR and (LDR) Light sensor. In addition to this I would like to add voltage measurement for the battery. BTW, did you komplette your sketch? I would like to copy the battery voltage sensor part. I will look att figuring out the circuit later, it does not look to complicated.

    • Tomas
    gyroG 1 Reply Last reply
    0
    • korttomaK korttoma

      In the application I will use this one I actually do not care so much for the built in PIR and LED, I just see it as a smart enclosure with a solar battery power-supply built in. I will tap in to the 3.3V regulator to power a pro mini that has an external PIR and (LDR) Light sensor. In addition to this I would like to add voltage measurement for the battery. BTW, did you komplette your sketch? I would like to copy the battery voltage sensor part. I will look att figuring out the circuit later, it does not look to complicated.

      gyroG Offline
      gyroG Offline
      gyro
      wrote on last edited by
      #34

      @korttoma
      I did try some battery measurement variants. The following code works best for me. I suggest that you first try the following sketch.

      • measure the voltage with voltmeter on VCC pin and correct #define VREF value so it will be a close as possible to measured value before you integrate into case specific code
      
      
      // define values for the battery measurement
      #define R1 1e6
      #define R2 330e3
      #define VMIN 2.8
      #define VMAX 4.2
      #define ADC_PRECISION 1023
      #define VREF 1.13
      
      
      int oldBatteryPcnt = 0;
      int batteryVoltage = 0;
      int BATTERY_SENSE_PIN = 0;
      int val = 0;
      
      void setup()  
      { 
           // use the 1.1 V internal reference
        #if defined(__AVR_ATmega2560__)
           analogReference(INTERNAL1V1);
        #else
           analogReference(INTERNAL);
        #endif
        Serial.begin(9600);
      }
      
      void loop()      
      {  
         //float batteryPcnt = getBatteryPercentage();
      
        //val = analogRead(BATTERY_SENSE_PIN);
        //Serial.println(batteryVoltage);
        float batteryVoltage = getBatteryPercentage();
        Serial.println(batteryVoltage);
        float batteryV= batteryVoltage;
      
        float batteryVmap = fabs(fmap(batteryV, 2.5, 4.2, 0.0, 1000.0));
        int batteryPcnt = batteryVmap / 10;
        if (batteryPcnt >= 100) {
      	  batteryPcnt = 99;
        }
         Serial.print("Battery voltage: ");
         Serial.print(batteryPcnt);
         Serial.println(" %");
      delay(2000);
         /*if (oldBatteryPcnt != batteryPcnt) {
           // Power up radio after sleep
           //gw.sendBatteryLevel(batteryPcnt);
           oldBatteryPcnt = batteryPcnt;
         }*/
        
        // totally random test values
      
      }
      
      float getBatteryPercentage() {
      
        // read analog pin value
        int inputValue = analogRead(BATTERY_SENSE_PIN);
        
        // calculate the max possible value and therefore the range and steps
        float voltageDividerFactor = (R1 + R2) / R2;
        float maxValue = voltageDividerFactor * VREF;
        float voltsPerBit = maxValue / ADC_PRECISION;
      
        float batteryVoltage = voltsPerBit * inputValue;
        float batteryPercentage = ((batteryVoltage-VMIN)/(VMAX-VMIN))*100;
        //int batteryPercentage = map(batteryVoltage, 0, maxValue, 0, 100);
      
        //return batteryPercentage;
        return batteryVoltage;
      }
      float fmap(float x, float in_min, float in_max, float out_min, float out_max) {
      	return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
      }
      
      1 Reply Last reply
      0
      • korttomaK Offline
        korttomaK Offline
        korttoma
        Hero Member
        wrote on last edited by
        #35

        @gyro said:

        int BATTERY_SENSE_PIN = 0;

        This means that you use A0 for measuring right?

        #define R1 1e6
        #define R2 330e3

        And you have used 1Mohm and 330kohm for the resistors?

        • Tomas
        gyroG 1 Reply Last reply
        0
        • korttomaK korttoma

          @gyro said:

          int BATTERY_SENSE_PIN = 0;

          This means that you use A0 for measuring right?

          #define R1 1e6
          #define R2 330e3

          And you have used 1Mohm and 330kohm for the resistors?

          gyroG Offline
          gyroG Offline
          gyro
          wrote on last edited by gyro
          #36

          Hi @korttoma

          • yes battery sense is A0
          • yes R1 and R2 are resistors values to measure Lipo voltage
          1 Reply Last reply
          0
          • korttomaK Offline
            korttomaK Offline
            korttoma
            Hero Member
            wrote on last edited by
            #37

            Thanks for the code and the additional info. Measuring the battery seems to work as expected but using the Internal reference seems to mess with the light level measurement LDR. Is it possible to use indifferent reference for different analog inputs? Or do I need to recalculate my LDR voltage divider?

            • Tomas
            1 Reply Last reply
            0
            • korttomaK Offline
              korttomaK Offline
              korttoma
              Hero Member
              wrote on last edited by
              #38

              I managed to squeeze in a pro mini and radio that is now powered from the 3.3V available from the built in circuit board. It has battery voltage measurement, light level and a external PIR.

              0_1461752523359_WP_20160427_11_25_34_Pro.jpg

              • Tomas
              gyroG 1 Reply Last reply
              1
              • korttomaK korttoma

                I managed to squeeze in a pro mini and radio that is now powered from the 3.3V available from the built in circuit board. It has battery voltage measurement, light level and a external PIR.

                0_1461752523359_WP_20160427_11_25_34_Pro.jpg

                gyroG Offline
                gyroG Offline
                gyro
                wrote on last edited by gyro
                #39

                @korttoma great that you maneged to connect it lamp..
                I don't know if analog reference is than set for all analog interfaces..
                Just one more thing you should adjust:
                I have figured out that I need to raise alarm for lower threshold for battery to higher than 3V (now is 2.5V!) because regulator voltage drop is ~250mV, and mini pro drops out at around 2.8V..
                But the whole concept now works fairly good

                1 Reply Last reply
                0
                • ranseyerR Offline
                  ranseyerR Offline
                  ranseyer
                  Hardware Contributor
                  wrote on last edited by ranseyer
                  #40

                  Hi,

                  im waiting to my Chinese Lamps. So i ordered in the meantime one directly in Germany: TaoTronics Solar ...-16 LED (Model TT-HSL002)

                  https://www.amazon.de/gp/product/B00REDHZMW

                  As you can see there is very different PCB. Do you have a hint for me if modification makes Sense ?

                  ed: now with external images:
                  alt text
                  alt text
                  alt text

                  Greetings

                  gyroG 1 Reply Last reply
                  0
                  • ranseyerR ranseyer

                    Hi,

                    im waiting to my Chinese Lamps. So i ordered in the meantime one directly in Germany: TaoTronics Solar ...-16 LED (Model TT-HSL002)

                    https://www.amazon.de/gp/product/B00REDHZMW

                    As you can see there is very different PCB. Do you have a hint for me if modification makes Sense ?

                    ed: now with external images:
                    alt text
                    alt text
                    alt text

                    Greetings

                    gyroG Offline
                    gyroG Offline
                    gyro
                    wrote on last edited by gyro
                    #41

                    @ranseyer
                    This one looks is a little complicated. I think you should wait for china version :)
                    Take a picture of other side of circuit also.

                    ranseyerR 1 Reply Last reply
                    0
                    • gyroG gyro

                      @ranseyer
                      This one looks is a little complicated. I think you should wait for china version :)
                      Take a picture of other side of circuit also.

                      ranseyerR Offline
                      ranseyerR Offline
                      ranseyer
                      Hardware Contributor
                      wrote on last edited by
                      #42

                      @gyro

                      Thanks for the Answer. Mine was produced in China too...

                      Her the picture of the backside:
                      alt text
                      No connections, but a board name: YYGF-601L.

                      I would be happy for any hints...

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


                      2

                      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
                      • OpenHardware.io
                      • Categories
                      • Recent
                      • Tags
                      • Popular