dslreports logo
site
 
    All Forums Hot Topics Gallery
spc

spacer




how-to block ads


Search Topic:
uniqs
874
share rss forum feed


Nick
Purveyor of common sense
Premium,VIP,MVM
join:2000-10-29
Smithtown, NY

Repurposing night lights?

Click for full size
Can someone explain to me in simple electronics terms whether
1. Night lights can be safely modified and repurposed
2. How they step down 120 a/c to light LEDs in such a small form factor?

What I want to do is actually make a custom nightlight that's based on an attiny85 and a 12v analog Rgb strip with a PIR sensor rather than an ldr

I have built my nightlight on a breadboard and feed it with a 12v wall wart but it's not compact at all
--
-Stupidity, like hydrogen, is one of the basic building blocks of the Universe.
-Insanity: doing the same thing over and over again and expecting different results.

Misc


Nick
Purveyor of common sense
Premium,VIP,MVM
join:2000-10-29
Smithtown, NY

The piece in the photo is a disassembled air wick air freshener with nightlight and when I measured the transistor voltages it was in the order of 1.5 v with maybe 20 milliamps draw.

I want to either buy, modify or build something similar to this but with 12vdc and higher amperage.


lutful
... of ideas
Premium
join:2005-06-16
Ottawa, ON
kudos:1
reply to Nick

said by Nick:

How they step down 120 a/c to light LEDs in such a small form factor?

1. Many night lights use specially designed "off-line" LED driver ICs.

Usually just the tiny "die" of the IC, without usual plastic package, is mounted directly on the PCB under a small black lump.

2. I have seen really simple, but dangerous, discrete circuits to drive one LED from AC. Google if you are curious, but don't try them at home!

3. There are also LED packages (Seoul Semiconductor's Acriche series for example) which connect directly across AC.

None of the above can be re-purposed for 12V.

But it is very easy to drive a single LED from 12V. Check old threads, specially by Subaru.

TheMG
Premium
join:2007-09-04
Canada
kudos:3
Reviews:
·NorthWest Tel
reply to Nick

A common method that I have seen used in many products to drive an LED from 120VAC involves a resistor, capacitor, and a diode.

The capacitor placed in series with the resistor and LED acts as a crude method of limiting the current going to the LED, due to the high impedance of the capacitor at 60Hz. Much more efficient than using just a resistor.

The diode is placed in parallel with the LED and in reverse. It limits the reverse voltage on the LED to 0.7V, which is necessary to avoid destruction of the LED during the negative AC cycle (LEDs do not tolerate a high reverse voltage).

Believe it or not, I've also seen this method used in high-reliability LED lamps, such as those red ones commonly seen on top of buildings and towers.

Anyways, such a circuit is not suited for powering a microcontroller, or applications where electrical isolation is required for safety. This simple circuit DOES NOT isolate from the AC mains voltage, ALL connections are to be regarded as potentially dangerous!

For your intended design, an isolated low voltage power supply would be the preferred way to go.



Nick
Purveyor of common sense
Premium,VIP,MVM
join:2000-10-29
Smithtown, NY
reply to Nick

Click for full size
I think this is the circuit I have (Sorry I'm new to Eagle)

Basically (currently) have a 12VDC/2A power brick that feeds into a 5V regulator to power the ATTINY85. The ATTINY85 PWM pins are going to resistors which then feed the base of the 2N2222 transistors. There are 6 LEDs on the strip right now, but for a nightlight I would probably want to do only 1 section of 3 LEDs.

How big are the isolated low voltage power supplies?
--
-Stupidity, like hydrogen, is one of the basic building blocks of the Universe.
-Insanity: doing the same thing over and over again and expecting different results.

Misc


leibold
Premium,MVM
join:2002-07-09
Sunnyvale, CA
kudos:10
Reviews:
·SONIC.NET

Very small. For your purpose you could use any of those small cubes that are sold as USB chargers and eliminate the 5V regulator from your circuit unless the LEDs that you want to use really need 12V (your diagram shows them connected to the 12V rail without any resistor).
--
Got some spare cpu cycles ? Join Team Helix or Team Starfire!



Nick
Purveyor of common sense
Premium,VIP,MVM
join:2000-10-29
Smithtown, NY

The LED strip has resistors built into it. They appear to be 150Ohm resistors (SMD based with 151 on them) I have a dead Nano clone that I used to test my strip and when I connect to the 5v and GND I don't get the LED lighting up. When I use a 9V battery they do.

I can't modify the SMD resistors because the strip is coated with a clear protective coating.

I have thought of using something like this but i am unsure of current requirements/limits
»www.ebay.com/itm/like/370996057268?lpid=82
--
-Stupidity, like hydrogen, is one of the basic building blocks of the Universe.
-Insanity: doing the same thing over and over again and expecting different results.

Misc



mackey
Premium
join:2007-08-20
kudos:12

said by Nick:

I have thought of using something like this but i am unsure of current requirements/limits
»www.ebay.com/itm/like/370996057268?lpid=82

If you look at the zoomed-in pic on that ebay page you can see that adaptor is rated for 500mA. Your LED strip will use approx. 20mA per color per string of 3 LEDs; since you said you are only going to use 1 string of 3, your LEDs will be drawing 20+20+20=60mA when they're all on full (worst case). That micro will be drawing next to nothing, so that adaptor will be plenty for your project.

I do not see it on your Eagle drawing but you'll need a decoupling capacitor or 2 across the supply pins of the micro.

/M


SparkChaser
Premium
join:2000-06-06
Downingtown, PA
kudos:3
Reviews:
·Verizon FiOS
reply to Nick

said by Nick:

The LED strip has resistors built into it. They appear to be 150Ohm resistors (SMD based with 151 on them) I have a dead Nano clone that I used to test my strip and when I connect to the 5v and GND I don't get the LED lighting up. When I use a 9V battery they do.

If the three LEDs are not turning on with 5V then your circuit is not going to work. Three LEDs are probably 5-6 Volts to turn on. If you use 12V, you will be drawing too much current without an external resistor.

Caveat - I understand what you're trying to do.
--
"There are in fact two things, science and opinion; the former begets knowledge, the latter ignorance." - Hippocrates

"The good thing about science is that it's true whether or not you believe in it." - Neil deGrasse Tyson


Nick
Purveyor of common sense
Premium,VIP,MVM
join:2000-10-29
Smithtown, NY

But my circuit does work with 12V and they light up pretty bright. I'm sure it could be incorrect (won't be the first time) but nothing released the magic smoke yet.



SparkChaser
Premium
join:2000-06-06
Downingtown, PA
kudos:3

Didn't say it wouldn't work. Saying it's probably more that the 20 mA stated somewhere in the thread.

3 LED @ 2V = 6V , 12-6 =6V, 6V/150 =40 mA

Do the colors look equally bright?



Nick
Purveyor of common sense
Premium,VIP,MVM
join:2000-10-29
Smithtown, NY

With 12v/2a all 3 look equally bright and I can get almost white light from the LEDs (most likely a pwm issue on the blue channel)

With a 9v battery the blue channel is weaker



mackey
Premium
join:2007-08-20
kudos:12
reply to SparkChaser

said by SparkChaser:

3 LED @ 2V = 6V , 12-6 =6V, 6V/150 =40 mA

Actually the Green and Blue on these strips are 3.2-3.4v each making that:

3 LEDs @ 3.3V = 9.9V, 12-9.9 = 2.1V, 2.1/150 = 14 mA

As someone who has used a large amount of these strips I can tell you they do not need any additional/external resistors. All the strips I have use the same resistor for grn/blu and a higher value one for red.

/M


SparkChaser
Premium
join:2000-06-06
Downingtown, PA
kudos:3
Reviews:
·Verizon FiOS
reply to Nick

said by Nick:

With 12v/2a all 3 look equally bright and I can get almost white light from the LEDs (most likely a pwm issue on the blue channel)

With a 9v battery the blue channel is weaker

Great! sound like you got what you want.
--
"There are in fact two things, science and opinion; the former begets knowledge, the latter ignorance." - Hippocrates

"The good thing about science is that it's true whether or not you believe in it." - Neil deGrasse Tyson


Nick
Purveyor of common sense
Premium,VIP,MVM
join:2000-10-29
Smithtown, NY

Well....for a prototype I do have what I want. But I want to significantly shrink what I have so it can be plugged into an outlet without a wall wart and 6 feet of wire. The LED strip gets slightly warm right now but does exactly what I want.

Basically I can solder all of my existing components onto a 5x7 perfboard but that doesn't account for the AC to DC conversion. I need to look into the isolated low voltage power conversion leibold mentioned and see if they sell 12v versions.

I guess my other option would be to source some RGB LEDs and not use the strip.
--
-Stupidity, like hydrogen, is one of the basic building blocks of the Universe.
-Insanity: doing the same thing over and over again and expecting different results.

Misc



Nick
Purveyor of common sense
Premium,VIP,MVM
join:2000-10-29
Smithtown, NY

Breathing nightlight with "bathroom" mode

iknow_t

join:2012-05-03
reply to Nick

there's some LEDs here to choose from that'll make a nice nightlight. all three colors. »www.digikey.com/product-search/e···ffec84a6



Nick
Purveyor of common sense
Premium,VIP,MVM
join:2000-10-29
Smithtown, NY

That's be one expensive nightlight with a 50+ bulb



SparkChaser
Premium
join:2000-06-06
Downingtown, PA
kudos:3
Reviews:
·Verizon FiOS

said by Nick:

That's be one expensive nightlight with a 50+ bulb

:D

What are the strips you are using? Do you have a link. I've never played with them.


Nick
Purveyor of common sense
Premium,VIP,MVM
join:2000-10-29
Smithtown, NY

Something like this:
»m.ebay.com/itm/251299906156?nav=SEARCH

You can cut segments off and solder on new leads for smaller projects



Nick
Purveyor of common sense
Premium,VIP,MVM
join:2000-10-29
Smithtown, NY
reply to Nick

Click for full size
Thank you mackey See Profile for the help in PM to add the decoupling capacitors...

Orange - 5v
Brown - 12v
Black - GND
RED/BLUE/GREEN = LED Strip colors
White - LDR sensor
Purple - PIR sensor

The one piece that's missing is the 12V DC Barrel jack so the regulator will have to shift in one column.
--
-Stupidity, like hydrogen, is one of the basic building blocks of the Universe.
-Insanity: doing the same thing over and over again and expecting different results.

Misc


mackey
Premium
join:2007-08-20
kudos:12

Hmmm, what regulator are you using? 7805-compatible has ground as the center pin. Also make sure the pinout is correct for those transistors; for example a PN2222A has the collector/emitter swapped vs a 2N2222. Are the color bands on the resistor for the LDR correct? 220 ohms seems a bit low. Finally, those electrolytics are backwards; white stripe is ground.

/M



Nick
Purveyor of common sense
Premium,VIP,MVM
join:2000-10-29
Smithtown, NY
reply to Nick

You're right,

Middle pin is ground...
I am using 2N2222 A338 transistors I have this circuit minus the capacitors running off 12v right now on a breadboard and it works...So I think that the pins are correct.
For resistors, I am using 1k for LEDs and 10K for LDR
Thanks, I forgot the electrolytics have polarity....Do ceramic ones have polarity?
--
-Stupidity, like hydrogen, is one of the basic building blocks of the Universe.
-Insanity: doing the same thing over and over again and expecting different results.

Misc



mackey
Premium
join:2007-08-20
kudos:12

said by Nick:

Do ceramic ones have polarity?

Not usually, no.

So other then that regulator everything looks good

/M


Nick
Purveyor of common sense
Premium,VIP,MVM
join:2000-10-29
Smithtown, NY

Thank you again, I will solder it up tomorrow



Nick
Purveyor of common sense
Premium,VIP,MVM
join:2000-10-29
Smithtown, NY

Took a few hours but the board came out great. I changed the transistors to, I believe 3904s and it still worked since I am not wiring the whole led strip. The most annoying part was the LED soldering, the 20 gauge wiring isn't very flexible so the pads on the LEDs came off a few times and I had to switch to a new segment.

After I finished I realized that I need to make the ldr more light sensitive (it still keeps the nightlight on during the day) and adjust the white light duration to more than a few seconds. Since I anticipated this I used a socket for the attiny85 instead of soldering it in. I will add some photos a bit later but here's an action video...
--
-Stupidity, like hydrogen, is one of the basic building blocks of the Universe.
-Insanity: doing the same thing over and over again and expecting different results.

Misc


Nick
Purveyor of common sense
Premium,VIP,MVM
join:2000-10-29
Smithtown, NY

2 edits

Click for full size
Click for full size
Click for full size
Photos and code

I added headers for quick connect/disconnect of the PIR/LDR and LED strip. Works great so far. I suspect there may be some rust/oxidation from bathroom humidity but it's cheap enough I'm willing to take a chance to see how long it works before things break down.

 
//Configure the pins
#define REDPIN 0
#define GREENPIN 1
#define PIR 3
#define LDR A1
#define BLUEPIN 4
#define NIGHTLIGHT_TIME 300000 //5 Minutes
//Set up variables
boolean human_detected = false;
unsigned long timer;
int i, r, g, b, runonce;
 
#define FASTFADESPEED 10     // make this higher to slow down
#define SLOWFADESPEED 50
 
//Run setup to configure the pins as appropriate
void setup() {
  pinMode(PIR, INPUT);
  pinMode(LDR, INPUT);
  pinMode(REDPIN, OUTPUT);
  pinMode(GREENPIN, OUTPUT);
  pinMode(BLUEPIN, OUTPUT);
  timer = millis();
}
 
//Main program
void loop() {
  //We only want to run this program if the LDR is reading low light
  int light_status = analogRead(LDR); 
  if (light_status > 700)  {
    //We want to check if the PIR sensor was triggered  
    int sensor_status = digitalRead(PIR);
    //We saw someone so we store the time and start a timer
    if (sensor_status == 1) {
      human_detected = true;
      timer = millis();
    }
    //We want to run this only once, instead of repetitively 
    if ((human_detected) && (runonce == 0)) {
      // fade to white
      runonce = 1; //Toggle the flag so we don't run again
      for (i = 0; i < 200; i++) { //Fade to white
        analogWrite(REDPIN, i);
        analogWrite(GREENPIN, i);
        analogWrite(BLUEPIN, i);
        if (i > 190){ //There's a small color cast so we adjust to white
          analogWrite(BLUEPIN, 190);
        }
        delay(SLOWFADESPEED);
      }
    } 
    else { //Nobody was detected so we breathe a red light
      //Breathe red for night light
      for (r = 250; r > 50; r--){
        analogWrite(REDPIN, r);
        delay(FASTFADESPEED);
      }
      for (r = 50; r < 250; r++){
        analogWrite(REDPIN, r);
        delay(FASTFADESPEED);
      }
    }
  }
  //We check to see if timer expired then we reset the paramenters
  if ((millis() - timer > NIGHTLIGHT_TIME) || (light_status < 700)){
    timer = 0;
    human_detected = false;
    runonce = 0;
    analogWrite(GREENPIN, 0);
    analogWrite(BLUEPIN,0);
    analogWrite(REDPIN,0);
  }
}