Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Using photoresistor with 10kohm resistance

    Scheduled Pinned Locked Moved FiPy
    sensorselectronicslightsensorphotoresistor
    2 Posts 2 Posters 625 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      Matthew
      last edited by Matthew

      I'm new here, a few hours ago i've received the fipy and im trying to get a value by the photoresistor,
      the white cable between the photoresistor and resistor goes to pin 16 but i always get the value of 4095.0 even if i cover the photo or point it with the torch
      then the red cable to 3V3 and black to GND
      i've read that maybe this is caused by an incorrect time.sleep()
      can someone pleas help me and explain me whats wrong?
      thank you
      0_1524237636163_img.jpg

      import pycom
      import time
      import machine
      from machine import Pin
      adc = machine.ADC()
      apin = adc.channel(pin='P16')
      def reading():
         avg = 0
         _AVG_NUM = const(100)
         for _ in range (_AVG_NUM):
             avg += apin()
         avg /= _AVG_NUM
         return(avg)
      while True:
          analog_val = reading()
          print(analog_val)
          time.sleep(1)
          pass
      
      L 1 Reply Last reply Reply Quote 0
      • L Offline
        livius @Matthew
        last edited by

        @matthew
        look at attenuation
        https://docs.pycom.io/chapter/firmwareapi/pycom/machine/ADC.html#adcchannel--pin-attnadcattn0db
        try ADC.ATTN_11DB

        think about people first, then computers

        1 Reply Last reply Reply Quote 1

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • 1 / 1
        • First post
          Last post

        Pycom on Twitter

        Pycom