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

Поділитися
Вставка
  • Опубліковано 27 лис 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 !

  • @RandommmUserrr
    @RandommmUserrr 5 років тому +2

    Nice intro

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

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

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

  • @Gabriel-dh8xl
    @Gabriel-dh8xl 2 роки тому

    beste videeo it workked ze firsté time

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

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

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

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

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

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

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

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

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