Notifications
Clear all

ATTiny85 with PIR sensor and two LED strips USB connectors

49 Posts
5 Users
3 Likes
12.6 K Views
Farah Haddad
(@fhaddad)
Member
Joined: 4 years ago
Posts: 32
Topic starter  

Hi,

As suggested to me, I am doing my first project and I would like to ask for help please to finish it. I will list the description and notes as bullet points to make it easy to read:

  • I am using ATTiny85 since the project is relatively easy and doesn't require many I/O
  • I am using Buck-Boost convertor to provide 5V DC for the whole circuit
  • My LED strip and the PIR Sensor are 5V
  • PIR Sensor datasheet is uploaded

     

  • The Schematic image is attached
    PIR Sensor with ATTiny85 schem

     

  • The project Schematic on Fritzing is attached

     

  • The code that I want to upload to ATTiny85 using Arduino is shown below

What I need your help with please is:

  • Is the schematic correct or am I doing something wrong
  • Is it correct to assume that using 9V battery to power project with Buck-Boost Converter is a good idea as the battery will last long (takes time to go down from 9V to 3V)
  • How can I make sure that the current going out from ATTiny85 is enough to power the LEDs 

    Thanks for the help

    const int SensorSignal = 7; // defining the sensor signal as pin 7 on ATTiny85
    const int ledPin1 = 6;  // define the first Strip cpnnected to USB on pin 6 of ATTiny85
    const int ledPin2 = 5; // define the second Strip cpnnected to USB on pin 5 of ATTiny85
    int sensorValue = 0;
    void setup()
    {
      pinMode(SensorSignal, INPUT);  // declare digital pin 7 as input
      pinMode(ledPin1, OUTPUT); // declare digital pin 6 as output
      pinMode(ledPin2, OUTPUT); // declare digital pin 5 as output
    }
    void loop()
    {
      sensorValue = digitalRead(SensorSignal); // read the value of pin 7, should be high or low
      if (sensorValue == HIGH)
      {
          digitalWrite(ledPin1, HIGH); // if sensor is sensing motion then send HIGH to the first LED strip
          digitalWrite(ledPin2, HIGH); // if sensor is sensing motion then send HIGH to the second LED strip
          }
      else {
          digitalWrite(ledPin1, LOW);
          digitalWrite(ledPin2, LOW);
          }
    }
     

   
Quote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
 

The schematic and code appear to be ok at first glance.

Posted by: @fhaddad

Is it correct to assume that using 9V battery to power project with Buck-Boost Converter is a good idea as the battery will last long (takes time to go down from 9V to 3V)

Batteries can only deliver so much current.  After that their voltage under load will drop off dramatically.   So I don't think you'll see much of an extended battery life when drawing the current that will most likely be required by your LED strips.

Where you might see an extended battery life when using a lower voltage than the battery is rated for is when the application uses very little current.   So I'm not sure you'll see much extension in battery life here.  But other than this, everything else about your project appears to be ok.

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 
Posted by: @fhaddad
  • How can I make sure that the current going out from ATTiny85 is enough to power the LEDs 

Look up the current requirements of the LED strips you are using.  Do you have the specs for the LED strips.  Are they one of the rgb individually addressable led strips?  From a quick google 10mA to 20mA is probably the most you want to draw from your pins. If your LED strip requires more current, or just to play safe, use a MOSFET to drive the LED strips.

Although you say the LED strips are 5volt you may be able to use 6 volts?  Then just use four big 1.5v cells to power the lot?

I have no way to view the files, .prj .sch or .fzz

 


   
ReplyQuote
Farah Haddad
(@fhaddad)
Member
Joined: 4 years ago
Posts: 32
Topic starter  

@casey

the files you can't read are on Fritzing but I posted the circuit as a photo. The problem is that I checked the website of the LED strip and it is not showing me a current. The product can be found here 

 

 


   
ReplyQuote
Farah Haddad
(@fhaddad)
Member
Joined: 4 years ago
Posts: 32
Topic starter  

@robo-pi

Really!! I thought I am going to get so many comments about the mistakes I've done in the schematic....oh this is such a confidence boosting feeling. Thanks a lot.

One more question, the current that my LED is drawing is not known and the technical specs of the LED strip can be found here but it is not giving me the resistance or the current. How can I calculate the current? 


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

It shows 5 volts and 1.5 watts,
current (amps) = Power (watts) / Force (volts)
= .3 amps
= 300 milliampere

So i guess the 5 volt power source would have to provide 300 mA per led strip to work.

resistence (ohms) = Force (volt) / current (amps)
= 5 / 0.3
= 17 ohms Resistance of a led strip

If you use a 6 volt power supply I don't know if the led strip will be damaged.
Maybe a resister in series with the led strip to drop 6 volt down to 5 volts?


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
 
Posted by: @fhaddad

Really!! I thought I am going to get so many comments about the mistakes I've done in the schematic....oh this is such a confidence boosting feeling. Thanks a lot.

Just because I didn't notice any obvious problems doesn't mean there aren't any.    But hopefully everything will go smoothly for you. ?

Posted by: @fhaddad

One more question, the current that my LED is drawing is not known and the technical specs of the LED strip can be found here but it is not giving me the resistance or the current. How can I calculate the current? 

The LED strip runs on 5 volts.  It's rated at 1.5 watts.   Power = voltage times current.   Using algebra:

Current = Power divided by voltage.    1.5 watts divided by 5 volts = 0.3 amps or 300 ma.

Since you are using two strips you'll be drawing about 600 ma when the LEDs are on.

9v batteries are typically rated between 400 to 600 mAh.   This means that using good quality batters you can expect your project to run (with the LED strips turned on) for about 1 hour before the battery dies.   Subtract some time for the ATTiny power requirements.

But that's with the LED strips lit constantly.  It's hard to say how long it might last if they only come on once in a great while and don't stay on too long.

But the bottom line is that you aren't likely to obtain any extra time by only using a smaller voltage.   The battery is still going to die when it reaches its current generating capabilities.   It's the current that will kill the battery, not the voltage.

But if I did the calculation correctly, your project should take approximate 600 ma with the LEDs on, plus whatever the ATTiny is drawing.

The specs on the light strip are slightly confusing.  It's listed a 1,5 watts.  Notice the use of a comma instead of a decimal point.  I'm not sure if they did that as a typo or if they meant they can use anywhere between 1 to 5 watts?

If it turns out to use 5 watts per strip that will change everything.   If you have a strip handy you can plug it into your power source and  measure the current it draws then you'll know exactly what your strips are actually drawing.

But yeah,  Power  P=IE     Current I= P/E    Voltage E = P/I    Where P=watts, I=amps, E=volts. 

 

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
Farah Haddad
(@fhaddad)
Member
Joined: 4 years ago
Posts: 32
Topic starter  

@robo-pi

Perfect thanks I will do as you said, I will plug and measure the current. To be honest this didn’t cross my mind (how stupid I am but learning) 

by the way the comma thing is because the manufacturer is a German company and they use the comma for decimal and the decimal for comma in Germany, so 1,500.00 in our world for one thousand five hundred point zero zero is written in Germany as 1.500,00 !


   
ReplyQuote
Farah Haddad
(@fhaddad)
Member
Joined: 4 years ago
Posts: 32
Topic starter  

@casey

Thanks a million. I will check and wire it up tomorrow and let you know the results 

thank you so Much 


   
ReplyQuote
Farah Haddad
(@fhaddad)
Member
Joined: 4 years ago
Posts: 32
Topic starter  

@robo-pi @casey

If I may ask again, I have a rechargeable battery which is 1.2V 2450 mAh, since the 9V battery is rated between 400 and 600 as you mentioned and it will run for an hour then if I used 4 times 1.2V battery that’s 4.8V with 2450 mAh which will run for 2450/600=4 hours contentiously sand if I use a step up booster to boost 4,8V to 5V then I am good. Is all what I said correct ??

84B5FACB 2BEF 4534 8207 A9F664A6FAD8
This post was modified 4 years ago by Farah Haddad

   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
 
Posted by: @fhaddad

If I may ask again, I have a rechargeable battery which is 1.2V 2450 mAh, since the 9V battery is rated between 400 and 600 as you mentioned and it will run for an hour then if I used 4 times 1.2V battery that’s 4.8V with 2450 mAh which will run for 2450/600=4 hours contentiously sand if I use a step up booster to boost 4,8V to 5V then I am good. Is all what I said correct ??

Sounds good to me, but I'm no expert on batteries.   I probably know as much about this as you do at this point. ? 

But the setup you have just suggested sounds like it should outlast the 9 volt battery setup.   It's more important that the batters are rated at a sufficient mAh capacity than what their voltage is.   The current is ultimately what you are using.

DroneBot Workshop Robotics Engineer
James


   
Farah Haddad reacted
ReplyQuote
Farah Haddad
(@fhaddad)
Member
Joined: 4 years ago
Posts: 32
Topic starter  

Ok I connected it to my power supply and something strange happened I am not sure if I am doing something wring, the voltage keeps dropping to 3.6V and the power supply switch to constant current and provides around 240mA. What’s the story can you please explain me. I am attaching the video


   
ReplyQuote
Robo Pi
(@robo-pi)
Robotics Engineer
Joined: 5 years ago
Posts: 1669
 

@fhaddad

I'm not seeing the video.  I see a player, but it doesn't play video on my computer.  It also seems to be only 7 seconds long.  It plays, but I don't see anything and only hear a click.    Do the light strips work when you plug them into a standard USB power jack?

DroneBot Workshop Robotics Engineer
James


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 
Posted by: @fhaddad

Ok I connected it to my power supply ...

Is the "it" your circuit or the LED strip?


   
ReplyQuote
Farah Haddad
(@fhaddad)
Member
Joined: 4 years ago
Posts: 32
Topic starter  

@robo-pi

That’s bad you can’t see the video I am just showing how the voltage drops to 3.6V when I connect the LEF strip and yes the LED works fine when I connect them 


   
ReplyQuote
Page 1 / 4