I’m following the Tufty 2040 getting started learn guide.
Using the as-delivered micropython installation.
The lux sensor doesn’t seem to be doing anything useful. Not really important for me, but just wondering.
from machine import ADC
from time import sleep
lux = ADC(26)
while True:
reading = lux.read_u16()
print(reading)
sleep(1)
There’s little or no reaction to me putting my finger over the sensor or shining my ‘blinding’ smartphone torch LED at it. It bobbles around 288 or 272.
If I try using pin 27 instead, I get more of a reaction, it goes from 720 (dark) to 416 (bright white LED). So it works, albeit ‘upside-down’.
Any ideas, what I’m, or what the hardware/software could be doing wrong?
ADC(28)
672 608 642.88 range: 64
Calculating Mix, Min and average
from machine import ADC
from time import sleep
lux = ADC(27)
maxx = 0
minn = 200000
total = 0
for i in range (100):
reading = lux.read_u16()
if reading < minn: minn = reading
if reading > maxx: maxx = reading
total = total + reading
print(reading)
sleep(0.3)
print(maxx, minn, total/100)
As you say, pretty insensitive and appears inverted with ADC 27 appearing best. This should be connected to ‘sensor power’.
According to this, lcd_badger.sch (shopify.com)
It’s connected to GPIO26 / ADC0
It’s a photo transistor. The higher the intensity of light is that hits it, the more it conducts.
If I read the schematic correctly, the voltage to ADC0 should increase as the light level increases.
Yes, thanks, we already know that, Tony posted a part of the schematic above.
What we don’t know is, why isn’t it working properly?
It really doesn’t seem to be all that useful as an ambient light sensor.