Home 2018 Forums Crumble Support Q: Adding light level to my pir/neo pixel crumble setup?

Tagged: ,

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2726
    garysone
    Participant

    Completed: Crumble detects movement and switches Neo Pixel white lights on for 1.5 minutes before switching off and then looping.

    This all works (too) perfectly – the lights come on regardless of the existing light level.

    I have a two pin light level sensor from a camjam.me edukit – open in new window. and wondering if i can simply connect one pin to + and the other to an analogue input? – could it be that simple?

    Pic showing light sensor

    I know I could ‘give it a go’ – but experience and wisdom says otherwise!

    Thoughts/Comments welcome please.

    #2727
    Joseph
    Keymaster

    Hi,

    It looks like the light sensor is a standard LDR, so yes you can connect the LDR to + and an input 🙂

    If you create the program in the attached screenshot and ensure the Variable tab is open, you should be able to monitor the analogue value in realtime – next to the variable ‘t’ in the sidebar, you should see a number instead of a question mark.

    Hope this helps,

    Joseph

    #2729
    garysone
    Participant

    Many thanks, seems 0=Direct Sunlight and 1=Room (day) – will be good to see if this changes to 2 or 3 later…. Many thanks for the quick response – appreciated.

    Crumble and LDR

    #2730
    Joseph
    Keymaster

    Mmmm… That doesn’t sound quite right. I’d expect roughly >200 in daylight and <100 in low light. Was the battery connected when you took these readings?

    Joseph

    #2731
    garysone
    Participant

    If i disconnect the PIR and the Neo Pixel ring I get a good reading from the LDR – my assumption is that I can’t run the PIR, Neo Pixel and LDR at the same time… Will do some more playing… I’m powering the crumble from a port on my (Official?) RaspberryPI hub

    #2733
    winkleink
    Participant

    I believe you need to use a voltage divider for the LDR to give an analogue input. The following link gives more details.
    http://www.doctronics.co.uk/voltage.htm

    As the Raspberry Pi doesn’t have analogue inputs the CamJam kit uses time to charge as the measure of light.

    An LDR is just a resistor that changes it’s resistance depending on the amount of light that hits it. You cannot get a value from it by just connecting it to 5V.

    I’d suspect your analogue pin is floating or the value is dependant on the internal resistance of the Crumble.

    #2734
    Joseph
    Keymaster

    Yes, normally you do need a voltage divider to use an LDR directly with an analogue input, however, the Crumble has 100k pulldown resistors on each of ABC and D, which form the ‘bottom’ part of the divider. Although, depending on the LDR, you might get better results with a 10k resistor, for example.

    I can’t think of a reason why you couldn’t use an LDR, Neo pixel ring and PIR sensor at the same time. Unless they are sharing pins, or there’s a dreaded bug!

    Powering from the Raspberry Pi hub should be fine.

    If you wanted to send me the program, I wouldn’t mind taking a look at it.

    All the best,

    Joseph

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.