Chinese Solar Lipo powered PIR led lamp.



  • This would nicely fit into Chinese solar Lipo powered PIR led lamp.
    http://www.aliexpress.com/item/New-Generation-16-LED-Solar-Power-Energy-PIR-Infrared-Motion-Sensor-Garden-Security-Lamp-Outdoor-Light/32336307599.html
    We would only need 3,3 regulator to feed radio and arduino.
    This way we could have smart mysensors aware security solar powered PIR sensor and LED garden lamp.
    But it would be challenging to hack original circuit so it would be mysensors aware.
    I'm willing to check elements and do additional circuit verification. But ic is without id. I think it is BISS0001?
    What do you guys think? I can provide additional information if somebody is interested?
    0_1455218646731_Photo 11-02-16 13 20 12.jpg
    0_1455218826197_Photo 11-02-16 13 21 13.jpg


  • Hardware Contributor

    @gyro Looks like the BISS0001 and this one needs 3V3, so I'm fairly certain there is a 3V3 DC regulator in the SOT-23 format on the board.

    There is a SOT-23 package type chip next to C3. Can you measure the voltages over the pins ? Middle one is ground, left small pin is input (I think), right of ground is output, large in on the other side is ground as well I think (just stating from my feeble memory). Just measure DC voltage. If one side is 3.7V-4.2V, that could be from the LIPO battery, one of the other pins probably gives 3V3.

    If i'm right, you could tap that pin for power. I do not know the output pin (which can drive the leds on) of the BISS0001, but probably one of the transistors (Q1 to 4) is driving U3, which is what I assume to be the IC driving the power to the leds. But that could be the LIP charging chip.

    In any case: interesting 🙂

    Time to break out the voltmeter ...



  • @GertSanders U3 has label 6206A, next to C3 is 5358A,
    i have measured BISS0001 based on specifications:
    pin7 -> GND
    pin8 -> 3V
    pin11 ->3V
    where is 3V source?
    battery voltage is 4.07V
    0_1455222552359_Photo 11-02-16 21 11 04.jpg


  • Hardware Contributor

    @gyro Measure the pins on U3.



  • @GertSanders i found similar ic specs:
    id is 6206A 1521/30
    where Marking Rule is
    6206A
    xxxx: Date Code
    /xx : Output Voltage(e.g. 33=3.3V) in my case 30 means 3.0V
    i have measure U3:
    1 - 2 -> GND - Vin = 4V
    1 - 3 -> GND - Vout = 3V ....so this will be my power source for your node

    BIS0001 specifications: http://www.ladyada.net/media/sensors/BISS0001.pdf
    PIR (id 500BP Nicera 571) detection trigger (source -signal) is connected to BISS pin 14 (high voltage level is 0,68)

    BISS output signal should be on pin 2 - i have meassured voltage (2.4V), which i think is enough to trigger digital input on atmega328 ?

    So if I lift pin 2 up and connect it to atmega328 input, i could detect motion with mysensor PIR libray ?

    • and then if I connect another digital out pin on circuit where was previous soldered BISS0001 pin 2, i can control the LEDs with mysensors relay scetch?
    • then i add rule in my controller (OPENHAB) when PIR detected motion - turn light on for 30s or blink if alarm is triggered ?

    Please correct/comment me if i am thinking this wrong?

    The lamp should have day/night sensor but i dont see any LDR ?


  • Admin

    (moved discussion to a new thread)


  • Plugin Developer

    Really interested by your investigations, as i stared build some sensor based on this box (ie the Weather station project). But I had trashed the original pcb and replaced by mine, rebuilding a charger, and getting rid of the builtin PIR. But if it is enough hackable, why not keep it as an addionnal sensor.

    So please post your results here.

    A few remarks :

    • if there is no LDR, I guess they've simply used the solar panel to detect if there is sun 🙂
      There should be something like :
      Solar+ --------- Resistor ------------ BIS0001 pin 9, so the challenge would be to find which resitor it is, explode it with a cutter or a drill, and put pin 9 to high (ie 3,3v) to make PIR alway ON.

    • to controll the light there should be something like this:
      BIS0001 pin 2 --------- Transistor (base) : remove this connection and connect pin2 to an arduino input and the transistor base to an arduino output.

    • You would also have to check is the retrigering time fit your need, and it the sensibility is well setup...

    • for the arduino software it will really simple, ie some pseudo code :

      • When input pin is high send Mysensor Message to gateway
      • On incoming Mysensor Message1, set output PIN to High for 30 seconds.
      • On incoming Mysensor Message2, set output PIN to blink for 1 hour.


  • @soif your are partially right, day/night sensor is solar cell
    -when solar cell is powering the battery over ic (XB5358A - see picture below), then the LEDs are disconnected (something disconnects load - LED lights),
    but
    additional findings:
    voltage regulator (6206A) is powered from battery all the time (day and night):

    • which is great that the atmega328 will have full time 3.0V power source.

    for BISS0001:

    • pin 9 is always high (3V) - day and night (my solar cell is 5V power supply ON-day, OFF-night)

    • so PIR is powered all the time and when triggered its source signal is ON for around ~25s

    • when PIR is triggered (0,6V), on pin 2 is output ~2.4V for the trigger interval time (25s)

    • so i will try to break pin 2 connection to arduino input, and then connect (transistor base) to an arduino output.

    what i still don't know is what drives LEDs:

    • at day (solar cell power is high -5V), LEDs are off.
    • at night (solar cell power is low- 0V): LEDs work at 2 phases
    • when PIR is not active - LEDs ared dimmed (illuminate with little intensity)
    • when PIR is active (motion detected)LEDs are verry bright for the time of the trigger interwal (25s)

    Questions are:

    • what disconnects (control) the load (LEDs) when battery is being charged from solar cell?

    • is it safe to connect atmega328 to regulator (6206A), i guess it is comparable to BISS0001 & PIR power requirements
      so additional very small load (like @GertSanders - minimal 2 switch node ) should not be a problem

    • what controlls the trigger interval (it could be shorter than 25s), because after connected arduino the
      output pin will configure the LED HIGH intensity interval?
      0_1455270382675_2_662_33228_535_448.jpg
      0_1455270397856_Photo 12-02-16 10 05 57.jpg



  • I think "mysensors" aware chinese LED solar lamp could work with a little effort, prototype is working now ( thanks to the forum members for help)
    What needs to be done:

    • disconnect BISS0001 pin 2 from circuit (i have cut circuit wire on the back of PCB)

    • connect BISS0001 pin 2 to input pin 3 of arduino pro mini (3,3 V model)

    • connect resistor R9 (smd 102 - 1kohm) to output pin 4 of arduino which drives the transistor(Y1) base

    • i think that the easiest way would be to remove resister R9 from circuit. Then connect left part of resistor to input pin of arduino,

    • then wire to arduino output (pin 4) resistor 1K and then connect to right part of removed transistor.

    Now i can use the solar light as motion detection and control LED lights independantly.

    • motion detection works all day,
    Received PUBLISH (d0, q0, r0, m0, 'mygateway1-out/11/12/1/0/16', ... (1 bytes))
    0
    Received PUBLISH (d0, q0, r0, m0, 'mygateway1-out/11/12/1/0/16', ... (1 bytes))
    1
    

    but i can control the lights

    root@kali:~# mosquitto_pub -d -h 192.168.1.115 -t "mygateway1-in/11/1/1/0/2" -m "1"
    Received CONNACK
    Sending PUBLISH (d0, q0, r0, m1, 'mygateway1-in/11/1/1/0/2', ... (1 bytes))
    root@kali:~# mosquitto_pub -d -h 192.168.1.115 -t "mygateway1-in/11/1/1/0/2" -m "0"
    
    

    only when they are not charging (someone would need to figure out how to connect/disconnect
    the solar charging - circuit now automatically disconnects the LEDs when there is voltage on solar cell and the battery is charging)

    usage example:

    • with many solar lights on the garden if motion is detected on one we can light on all of them,

    • they can all blink as an alarm, (i would need help with code)

    • when we need light we can turn lights on from mobile app

    • or any other usage (control something that can be controlled with the power of lipo battery )

    • I think it would be good idea to meassure battery voltage, what divider should i use to meassure Lipo battery voltage, when arduino is powered from 3.0V battery (solar lamp onboard regulator is 3.0V), that we dont drain battery to much

    i have combined motion detection and relay scetch:
    the code is below (its not optimized, but it works):

    // Enable debug prints
    #define MY_DEBUG
    #define MY_NODE_ID 11 
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    #include <SPI.h>
    #include <MySensor.h>
    
    unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
    #define CHILD_ID 12   // Id of the sensor child
    
    boolean lastMotion = false;
    
    // Initialize motion message
    MyMessage msg(CHILD_ID, V_TRIPPED);
    
    #define RELAY_1  4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 1 // Total number of attached relays
    #define RELAY_ON 1  // GPIO value to write to turn on attached relay
    #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
    
    void setup()  
    {  
      pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
        
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
        // Then set relay pins in output mode
        pinMode(pin, OUTPUT);   
        // Set relay to last known state (using eeprom storage) 
        digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
      }
    }
    
    void presentation()  {
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Motion Sensor and pir", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID, S_MOTION);
        for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
        // Register all sensors to gw (they will be created as child devices)
        present(sensor, S_LIGHT);
      }
    }
    
    void loop()     
    {     
      // Read digital motion value
      boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; 
            
     if (lastMotion != tripped) {
      Serial.println(tripped);
      lastMotion = tripped;
      send(msg.set(tripped?"1":"0"));  // Send tripped value to gw 
     }
      // Sleep until interrupt comes in on motion sensor. Send update every two minute. 
      //sleep(INTERRUPT,CHANGE, SLEEP_TIME);
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_LIGHT) {
         // Change relay state
         digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
         // Store state in eeprom
         saveState(message.sensor, message.getBool());
         // Write some debug info
         Serial.print("Incoming change for sensor:");
         Serial.print(message.sensor);
         Serial.print(", New status: ");
         Serial.println(message.getBool());
       } 
    }
    

    0_1455429970577_diconnected pin2 .jpg


  • Hardware Contributor

    very nice to see that good progress was made 🙂


  • Plugin Developer

    @gyro
    Keep up the good work debugging this chinese box !

    This box is a really good value for money box to build mysensors projects ( at least box + lipo + solar panel).

    If your investigations let us to also use the built in Charger / PIR / LEDS , it would just be amazing.

    Please keep us in touch ! 😉



  • @soif , @GertSanders
    some progress was made, but i need an hardware advice.

    This is the part of schematic that drives the LEDs.
    0_1455909866821_piygV.png

    First the battery is not connected directly (as here in schematic) but over protection IC logic.

    Question 1:

    Current circuit works as follows:

    • When solar cell voltage is higher than 0.7V , LED is OFF (sort off day/night sensor).
    • When solar voltage is lower than 0,7V, LED is shining with low intensity

    What is the the correct way to connect arduino pin D1 to take control over above described default behavior? (disconnect the line at SW4 and remove R9 -1Mohm)?

    Question 2:
    Which voltage measurement technique (internal reference or reference to regulated Vcc voltage) should i use to meassure Lipo voltage?
    What are correct/recommended resistor value for optimal battery utilization.
    Should this reference be used: https://github.com/rlogiacco/BatterySense

    Would make sense to measure also solar cell voltage?

    Question 3:

    Is arduino pin D2 connect properly? It control two level LED intensity:
    pin HIGH - LED glows with HIGH intensity (between led+ and led- is ~4V) pin LOW LED glows with LOW intensity (between led+ and led- is ~2,5V)

    Thanks for help and recommendations

    I have asked the same here, but no perfect answer jet:
    http://electronics.stackexchange.com/questions/218114/solar-battery-powered-leds-circuit-arduino-controlled


  • Hardware Contributor

    @gyro

    Since you are using a atmega328p, it does make sense to measure the battery level and solar power level.

    If you make a node which does NOT sleep all the time, then monitoring both voltage levels is the starting point to make decisions.

    I'm guessing you want to add a node using the battery, so a node that sleeps until something needs to be done.
    In that case we need a trigger when the light is bright enough to switch off the leds, and dark enough to switch them on again.

    The trigger to wake up from sleep should be a voltage change on pin D2 or D3, and the voltage difference needs to be from below the lowest "HIGH" threshold to above the highest "LOW" threshold. Check the specification for the atmega328 you use, as this depends on the working voltage of the processor.

    The question I ask myself is what is the lowest voltage you get from the solar cell ? Looking at the circuit, they use the voltage of the solar cell to open the gate of a transistor, which then pulls the emitter voltage of a transistor to ground, which in turn switches off a second transistor with is feeding the battery current to the LEDs.

    Your question of the values of R2 and R11 is actually how to measure voltages over a resistor divider? You can choose any value of resistors, but their ratio is what is important.

    To calculate the resistor values:

    To measure at a maximum of 5V on an analog pin:

    R11 = R2 * (1 - voltage-ratio) / voltage-ratio

    To go from 6V to 5V the ratio = 5V / 6V = 0.83

    Take R2 as 1M Ohm, then R11 = 1M * (1 - 0.83) / 0.83 = 205K => a common value is 220K

    To check: voltage over R2 (which is the input voltage on the analog pin A0)

    V(A0) = Vinput * R2 / (R1 + R2) = 6V * 1M / (1M+220K) = 4.9 V



  • @GertSanders I think i managed to successfully connect arduino with solar lamp.

    My prototype is working, and has the following functions:

    1. Measure battery voltage (when charging it is alway 100% - makes sense)
    2. Measure solar voltage (can be omitted - but resistor should be there for a transistor to work properly)
    3. Solar power day/night trigger with transistor as a switch (can be used wake up arduino from sleep)
    4. PIR sensor (can be used wake up arduino from sleep)
    5. Lights on/off dimmed brightness
    6. Lights on/off high brightness ( original resistor R9 -1k was replaced with 4.7k - i think it draws to much current and sometimes hangs arduino)

    I will post the code later, but every part works with default "mysensor" examples

    How to connect and how to add elements see picture:
    0_1457202432374_solar_circuit_connect_arduino.jpg


  • Hardware Contributor

    @gyro
    Very nice work !!!!



  • higher math for me...
    Great...

    Can you use the motion seperate from the liight?
    And can u use the light with a switch option? [ i will turn on the light when there is motion.. ]
    Or is the light switching only on lux?



  • @GertSanders thanks, you have motivated my research

    @Dylano the purpose of this project was exactly what you have asked.

    The lamp is now mysensors aware.
    Every task can be operated separately.

    • When there is dark, the trigger is send, when the sun shines, the trigger is send. (transistor as switch). In scetch i use it as magnet switch part of code. When trigger is received (can wake up arduino), than you decide with controller what you want to do .

    • PIR acts as classic PIR sensor and can also be used as trigger. (can wake up arduino), than you decide with controller what you want to do.

    • The Lamp have two phases and can be controlled with controller (i control it over mqtt for now)

    • phase one is dimmed light (relay 1)

    • phase two is high bright light (relay 2)

    Below is code that works for now. I wil improve it in next few days

    // Enable debug prints
    #define MY_DEBUG
    #define MY_NODE_ID 11 
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    #include <SPI.h>
    #include <MySensor.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 INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
    #define CHILD_ID 12   // Id of the sensor child
    
    boolean lastMotion = false;
    
    // Initialize motion message - start
    MyMessage msg(CHILD_ID, V_TRIPPED);
    
    //trigger solar power day on/off -start
    #define CHILD_ID_SW 5
    #define BUTTON_PIN  5  // Arduino Digital I/O pin for button/reed switch
    Bounce debouncer = Bounce();
    int oldValue = -1;
    
    // Change to V_LIGHT if you use S_LIGHT in presentation below
    MyMessage SolarMsg(CHILD_ID_SW, V_TRIPPED);
    // trigger solar - end
    
    #define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 2 // Total number of attached relays
    #define RELAY_ON 1  // GPIO value to write to turn on attached relay
    #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
    
    void setup()
    {
    	//trigger solar power day on/off - start
    	// Setup the button
    	pinMode(BUTTON_PIN, INPUT);
    	// Activate internal pull-up
    	digitalWrite(BUTTON_PIN, HIGH);
    
    	// After setting up the button, setup debouncer
    	debouncer.attach(BUTTON_PIN);
    	debouncer.interval(5);
    	//trigger solar - end
    
    
    	pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
    
    	for (int sensor = 1, pin = RELAY_1; sensor <= NUMBER_OF_RELAYS; sensor++, pin++) {
    		// Then set relay pins in output mode
    		pinMode(pin, OUTPUT);
    		// Set relay to last known state (using eeprom storage) 
    		digitalWrite(pin, loadState(sensor) ? RELAY_ON : RELAY_OFF);
    	}
    }
    
    void presentation() {
    	// Send the sketch version information to the gateway and Controller
    	sendSketchInfo("Motion Sensor and light", "1.0");
    
    	// Register all sensors to gw (they will be created as child devices)
    	present(CHILD_ID, S_MOTION);
    	for (int sensor = 1, pin = RELAY_1; sensor <= NUMBER_OF_RELAYS; sensor++, pin++) {
    		// Register all sensors to gw (they will be created as child devices)
    		present(sensor, S_LIGHT);
    
    		// Register binary input sensor to gw (they will be created as child devices)
    		// You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
    		// If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
    		present(CHILD_ID_SW, S_DOOR);
    	}
    }
    
    void loop()
    {
    	// Read digital motion value
    	boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
    
    	if (lastMotion != tripped) {
    		Serial.println(tripped);
    		lastMotion = tripped;
    		send(msg.set(tripped ? "1" : "0"));  // Send tripped value to gw 
    	}
    	// Sleep until interrupt comes in on motion sensor. Send update every two minute. 
    	//sleep(INTERRUPT,CHANGE, SLEEP_TIME);
    
    	//trigger solar power day on/off - start
    	debouncer.update();
    	// Get the update value
    	int value = debouncer.read();
    
    	if (value != oldValue) {
    		// Send in the new value
    		send(SolarMsg.set(value == HIGH ? 1 : 0));
    		oldValue = value;
    	//trigger solar power day on/off - stop
    	}
    }
    
    void receive(const MyMessage &message) {
    	// We only expect one type of message from controller. But we better check anyway.
    	if (message.type == V_LIGHT) {
    		// Change relay state
    		digitalWrite(message.sensor - 1 + RELAY_1, message.getBool() ? RELAY_ON : RELAY_OFF);
    		// Store state in eeprom
    		saveState(message.sensor, message.getBool());
    		// Write some debug info
    		Serial.print("Incoming change for sensor:");
    		Serial.print(message.sensor);
    		Serial.print(", New status: ");
    		Serial.println(message.getBool());
    	}
    }```


  • mmm i ordered 1...
    So i hope i gonna ix this...
    It is looking higher mathematics

    Will see... when i have time..
    Thanks for the sketch!!!
    Give it a try in a uno ...



  • guess what...
    I do have a:
    http://www.ebay.com/itm/161885080971?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
    Exact the same board in of this light...
    I think i going to try the make this work...

    Only i do not understand exact the wiring of your example.
    Will you please make a list of exact stuff to buy.
    And make some more pictures, from the good places..

    And a thing that i see.
    You use D2 from the arduino.
    Is that not a one for the radio?



  • @gyro is there a reason you used high/low intensity with resistor instead of PWM?



  • @siklosi Resistor is used as transisistor base resistor. This was the best way to connect i could think off. But you need two output pins - 2 transistors are controlled.
    first PIN - lights ON/OFF
    second PIN - ligths bright ON/OFF



  • @Dylano Great to hear that the light has the same board...please post a picture.
    My light is still protoype connected together on protoboard - connected to arduino pro mini - i can post only a picture connected elements on protoboard for now.
    I am trying to put all together in openhab now.
    I will try to make a list of exact elements.
    I have free D2 pin on arduino pro mini.



  • As the easiest way to disable dimmed mode this lamp?


  • Hero Member

    Got myself a similar PIR LED lamp. The functionality seems like it is the same but the circuit board is different.

    3_1461237714861_WP_20160415_06_56_45_Pro.jpg 2_1461237714860_WP_20160415_06_31_16_Pro.jpg 1_1461237714860_WP_20160415_06_30_18_Pro.jpg 0_1461237714859_WP_20160415_06_24_35_Pro.jpg



  • @korttoma
    Nice to see some interest in smart solar lamps 🙂
    It looks like an updated version (at least i like it more from your pictures). Could you post an order link.
    I think this one should be even easier to intercept with "mysensors", beacause i see only two transistors and circuit connectios are clearly visible.

    so lets try to understand the circuit:
    -U3 is probably battery protection circuit

    • Q1 i think is voltage regulator HT33 - to power arduino wih 3.3V (meassure voltage)
    • take a photo of PIR sensor from front side (is there any ic elements)?
    • U1 - i would guess PIR sensor IC logic - leg 6 (count from dot on IC) should be output (meassure voltage - high 3,3 V when motion detected):
      -if it is output from PIR just remove R3 and IC ouput goes over resistor to you arduino input.
    • the output goes over resistor to Q2
      -whats is left - you have to figure out what drives resistor Q1(J3y) :
    • i gues its driven by solar cell, than collector is connected to resistor R10, resesitor is than connected over board to the other side.......

  • Hero Member

    I guess you meant U4 is the 3.3V regulator. I measured it to 3.3V and HT33 should be a regulator. Q1 and Q2 I think are transistors. U3 handles the solar charging. U1 is for the PIR but unfortunately there is no text on the chip. I will get you the link tomorrow but it is quite easy to find on aliexpress.



  • @korttoma
    sorry my typo: you are correct

    • U4 - HT33 is voltage regulator
    • yes Q1 and Q2 are transistors
    • U1 - PIR out test - measure voltage between PIN 6 and R3 when PIR is OF and ON. I think this drives Q2 (high brightness / low brightnes)

    also take picture of other side of circuit board, beause i think Q1 is conected to R10 and
    then further on the other side


  • Hero Member

    Here is the link to the one I got but it seems like the prize is allot higher now since I paid 23,84$ including shipping -> http://www.aliexpress.com/item/1-Set-1200-Lumens-46-pcs-LED-Solar-Power-Motion-Sensor-Lamp-Ultra-thin-PIR-Outdoor/32354254209.html

    Also it took like 10 weeks for it to arrive so maybe another seller would be a better fit.


  • Hero Member

    There is not much on the other side of the board, just a status LED, a button to turn it on and the PIR.

    0_1461306917706_WP_20160422_09_27_29_Pro.jpg



  • @korttoma
    Are you sure that this light has two modes of operation or only one: when a person is present is activated for 15s and then switched off


  • Hero Member

    I'm sorry I did not test the device I just read the manual so I think that yes it has 2 modes for LED brightness.

    0_1461308847304_WP_20160422_09_59_09_Pro.jpg



  • @korttoma
    Don't be sorry.I am not an circuits expert, I just try help you figure things out.
    You wil have to test this lamp a little bit.
    it looks that Q1 drives U1 active/not active when there is sun, but how/what turns on dimm lights in dark?

    Did you measure U1 pin 6 when pir active/not active?


  • Hero Member

    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;
    }
    

  • Hero Member

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



  • Hi @korttoma

    • yes battery sense is A0
    • yes R1 and R2 are resistors values to measure Lipo voltage

  • Hero Member

    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?


  • Hero Member

    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



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


  • Hardware Contributor

    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



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


  • Hardware Contributor

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


Log in to reply
 

Suggested Topics

  • 8
  • 5
  • 7
  • 3
  • 1
  • 2

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts