How to make a Light Sensor Circuit using a Photoresistor and a Raspberry Pi

Поделиться
HTML-код
  • Опубликовано: 18 ноя 2024

Комментарии • 50

  • @kevintech7457
    @kevintech7457 Год назад

    Follows most of this through to the end. This was my first "programming" if you will and boy am I proud of the results. Your tutorial was one of the most satisfying I've ever had. Only thing different for me was that I used set pin 11 and I had a 3 prong photoresistor module. With a little experimentation and wire swapping I was able to figure it out. Thanks a bunch man!

  • @daytodatainc
    @daytodatainc 3 года назад +2

    This is probably the best video I've watched on this subject! Thank you!! I was driving myself crazy using gpiozero LightSensor value output with a 10 uF capactor (all I had). You've explained it in some really great detail!!!!

  • @izzy1335
    @izzy1335 6 месяцев назад

    im using this in a project, it works so well (thanks for that i couldnt find anyone else who could actually do it) but on its first reading i keep getting massive spikes on the reading when i first press run, its fine after that but it messes with the rest if my code, how do i fix that?

    • @Flopperam
      @Flopperam  5 месяцев назад +1

      Sorry for the late response but I would double check that you don't have a faulty photoresistor or transistor as well as any loose connections.

  • @mattiamirigaldi633
    @mattiamirigaldi633 4 года назад +1

    Great tutorial !

  • @iwangeddes4962
    @iwangeddes4962 3 года назад

    Hi I did everything you said to do in the video but when I run it, it comes up with an error saying theres "No module named 'RPi'"

    • @Flopperam
      @Flopperam  3 года назад

      Try running "sudo apt-get install python3-dev python3-rpi.gpio"

  • @Fraunzi
    @Fraunzi 3 года назад

    Can you code some type of timelapse camera shutter option that is synchronized with the LDR sensor?

    • @Flopperam
      @Flopperam  3 года назад

      Sorry for the late reply but I believe you should be able to do that.

  • @stephan4198
    @stephan4198 4 года назад

    Great video. How do I get absolute values [W/cm^2] from the readings of the capacitor? Does this work with all wavelengths?

    • @Flopperam
      @Flopperam  4 года назад +1

      Hey, this should work with various wavelengths. As for the question about getting absolute readings from the capacitor, I am not sure about how to go about this.

  • @rigongashi5984
    @rigongashi5984 2 года назад

    Hey, i wanted to ask what unit are the numbers that the sensor is giving?

    • @Flopperam
      @Flopperam  2 года назад

      Seconds, since the program just reads how long it takes for the capacitor to be charged.

  • @pkrai69
    @pkrai69 10 месяцев назад

    can you use a battery instead of a capacitator?

    • @Flopperam
      @Flopperam  10 месяцев назад

      I think for this, technically yes, but don't quote me on it.

    • @pkrai69
      @pkrai69 10 месяцев назад

      @@Flopperam if so, how do you? also thank u for the reply :)

    • @Flopperam
      @Flopperam  10 месяцев назад

      I'm not too sure as I wouldn't recommend a battery for this use case.

  • @jaafaromar8570
    @jaafaromar8570 3 года назад

    Dude, is it possible to configure this LDR sensor without a capacitor and still identify the value in the terminal?

    • @Flopperam
      @Flopperam  3 года назад +1

      As far as I know, not with this approach because in this video we calculate how long it takes to charge the capacitor. However, you can create a photocell using the photoresistor by connecting it directly to analog input. Here's a link with more information about it, learn.adafruit.com/photocells?view=all. Keep in mind though that this is for Arduino but the process is very similar for Raspberry Pi.

    • @jaafaromar8570
      @jaafaromar8570 3 года назад

      Thanks 🤜🤛

  • @pocoace5415
    @pocoace5415 Год назад

    what if i change the capacitor into mcp3008?

    • @Flopperam
      @Flopperam  Год назад

      Sorry for the late response. Don't quote me on this but it should be fine.

  • @sam_1887
    @sam_1887 2 года назад

    What is the unit of the values ​​coming from the sensor?

    • @Flopperam
      @Flopperam  2 года назад

      In this case it's just seconds or maybe milliseconds since we're just measuring how long it takes for the photoresistor to detect sufficient light.

    • @sam_1887
      @sam_1887 2 года назад

      @@Flopperam thanks

  • @rahuls973
    @rahuls973 5 лет назад

    hey would you be open to make a tutorial on request?

  • @azridaniel6009
    @azridaniel6009 2 года назад

    Can i replace raspberry pi with arduino uno with same coding’s ?

    • @Flopperam
      @Flopperam  2 года назад

      Not with the exact same code since I used Python here but probably similar yes. Wiring should also be similar

  • @RandommmUserrr
    @RandommmUserrr 5 лет назад +2

    Nice intro

  • @Gabriel-dh8xl
    @Gabriel-dh8xl 2 года назад

    beste videeo it workked ze firsté time

  • @twinsassink8745
    @twinsassink8745 5 лет назад

    When are your plans to go over match making? and quieing and adding friends to a game
    this is about the ue4 gamelift tutrial
    Thanks

  • @sam_1887
    @sam_1887 2 года назад

    all I get as output is 0, what did I wrong?

    • @Flopperam
      @Flopperam  2 года назад

      Hey, I would suggest double checking your wiring setup.

    • @sam_1887
      @sam_1887 2 года назад

      @@Flopperam I read a comment and checked the wiring. Watched your video multiple times but in my opinion the wiring is like yours. If I plug the capacitor into the breadboard the python file is printing nothing. Not 0’s but nothing and then when I unplug it again there are some numbers showing up. I really don’t know what’s wrong there but thanks for your reply even though the video is years old.

    • @Flopperam
      @Flopperam  2 года назад +1

      Sometimes the legs of certain parts like capacitors can be switched, for e.g. longer leg could be positive or it could be negative. And last thing I would suggest is double checking the code of course. Just throwing possibilities out there.

    • @riccardoceolin7404
      @riccardoceolin7404 Год назад

      Did u solve it? Please help me

  • @Dnsx_plus
    @Dnsx_plus 4 года назад

    AT 6:03, how come the resistor pin has to be GPIO.LOW for it to be charged? Wouldn't it have to be GPIO.HIGH

    • @Flopperam
      @Flopperam  4 года назад

      Hey, the reason we set it to GPIO.LOW is because we are measuring the time it takes to become GPIO.HIGH. Naturally, with light, the resistor will reach GPIO.HIGH.

    • @Dnsx_plus
      @Dnsx_plus 4 года назад

      @@Flopperam Okay, I get that, but how come in the while loop you put if GPIO.input(...) == GPIO.LOW? Wouldn't you do if (Gpio.input(resistorPin) == GPIO.HIGH)?

    • @Flopperam
      @Flopperam  4 года назад

      @@Dnsx_plus The reason is that we are waiting for GPIO.input(...) to be equal to GPIO.HIGH so that we can see how long it took to become GPIO.HIGH. If we replaced the condition like you said, then the while loop would most likely be skipped over at the first check every time since it will take at least some time for the photoresistor to charge.

    • @Dnsx_plus
      @Dnsx_plus 4 года назад

      @@Flopperam ahhh, but the thing is, by the time the if condition is true, we can do the time subtraction, right? I'm sorry, I'm confused, but I kind of get what your saying.

    • @Flopperam
      @Flopperam  4 года назад +1

      That's a good point, you could do the time subtraction after the while loop instead of inside the while loop.

  • @ZSteez4
    @ZSteez4 4 года назад

    I'm only getting 0's

    • @Flopperam
      @Flopperam  4 года назад

      Hey, can you double check your wiring? If the wiring matches the diagram linked in the description then please let us know.

    • @lokeandy8220
      @lokeandy8220 4 года назад

      I am getting 0s too, have you solved your problem?

    • @riccardoceolin7404
      @riccardoceolin7404 Год назад

      Did u solve it? Please help me

  • @RandommmUserrr
    @RandommmUserrr 5 лет назад

    First