2 Replies Latest reply on Apr 1, 2015 6:50 AM by ABIX_PL

    Photoresistor, Galileo Gen 1, Python pyGalileo library - little confustion

    ABIX_PL

      I have Galielo Gen1 and Debian Linux on SD Card working good. I use pyGalileo library to manage pins from Python scripts.

      I can do LED Blinking as in youtube film: LED blinking - YouTube.

      Everything is also on Superteacher's Blog: http://www.superbelfrzy.edu.pl/linux-i-wioo/galileo-dalsze-postepy-w-pracy/ (in polish language only, but code is in python ;-)

       

      OK - that works well, so I try today to connect photoresistor to Analog A0 pin and try top read. The film is showing voltage : VID 20150401 115913 - YouTube

      The python code is:

       

          while True:

              foto_value = analogRead("A0")

              print "Value is: "+ str(foto_value)

              delay(5000)

       

      The output is:

      Value is: 2

      Value is: 3

      Value is: 2

      Value is: 3

      Value is: 3

      Value is: 3

      Value is: 3

      Value is: 3

       

      It looks like something is not working like should be. But even investigating pyGalileo source code does not gave me ani hint, why... Maybe someone will help?

        • 1. Re: Photoresistor, Galileo Gen 1, Python pyGalileo library - little confustion
          rgb

          Hi Abix

          It is a bit difficult to figure out you problem without the rest of the code and a sketch or picture of your setup.

          Are you using a voltage divider circuit with you LDR? From the video you posted it looks like you are just reading across the LDR. You  need to connect the LDR from +5V to a resistor (about 10K works well) and then ground the other side of the resistor. You then take your readings from the junction of the LDR and resistor. see How to Use a Light Dependent Resistor (LDR) for an example.

          Did you try the example in PyGalileo?

          rgb

          • 2. Re: Photoresistor, Galileo Gen 1, Python pyGalileo library - little confustion
            ABIX_PL

            Works like a charm ;-)

             

            root@coderdojo-galileo:~/python_scripts# python fotorezystor_test.py

            test pin on

            test pin off

            Value is: 862

            Value is: 862

            Value is: 861

            Value is: 862

            Value is: 864

            Value is: 862

            Value is: 828

            Value is: 1990

            Value is: 1978

            Value is: 1972

            Value is: 1968

            Value is: 1966

            Value is: 825

            Value is: 837

            Value is: 609

            Value is: 637

            Value is: 858

            Value is: 829

            Value is: 207

            Value is: 181

            Value is: 862

             

            photoresistor.png

            I have made 2 mistakes I think:

             

            1) I've put "A0" in python code - should be "A5" - I look from secod side ;-)

            2) Ground wire was connected to the opposite side of Galileo pins - I found strange behavior with LED blinks - if I connect pin4 and ground in the same series of pin, the light is bright, but when GND is from series of pins where 3,5 V and 5V is, the led blinks very little....

            Nevertheless this problem is SOLVED ;-) rgba - thanks for any hints.