Chinese Solar Lipo powered PIR led lamp.
-
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.
-
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.
@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; } -
@gyro said:
int BATTERY_SENSE_PIN = 0;
This means that you use A0 for measuring right?
#define R1 1e6
#define R2 330e3And you have used 1Mohm and 330kohm for the resistors?
-
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?
-
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.

-
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.

@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 -
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:



Greetings
-
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:



Greetings
-
@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.
