Home Circuitpython Adafruit Feather M0 and TEMT6000 light sensor circuitpython example

Adafruit Feather M0 and TEMT6000 light sensor circuitpython example

by shedboy71

In this example we connect a TEMT6000 light sensor to an Adafruit Feather M0 running Circuitpython

First lets look at some information about the sensor from the manufacturer

Description

TEMT6000X01 ambient light sensor is a silicon NPN epitaxial planar phototransistor in a miniature transparent 1206 package for surface mounting. It is sensitive to visible light much like the human eye and has peak sensitivity at 570 nm.

Here is a picture of a module

 

APPLICATIONS

Ambient light sensor for control of display backlight dimming in LCD displays and keypad backlighting of mobile devices and in industrial on/off-lighting operation.

• Automotive sensors
• Mobile phones
• Notebook computers
• PDA’s
• Cameras
• Dashboards

Parts Required

The sensor is only $1, so is a low cost option for light detection

Name Link
Adafruit Feather M0 Express Adafruit (PID 3403) Feather M0 Express – Designed for CircuitPython – ATSAMD21 Cortex M0
TEMT6000 TEMT6000 ambient light sensor
Connecting cables Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

 

Schematic/Connection

A very easy sensor to connect, you simply require power and an analog in pin, I chose A1 you can chose another if you want you would have to modify the code very slightly in the next section

Code Example

I used Mu for development

The example below simply returns the voltage on the A1 pin, you can also use the raw reading by uncommenting the print(pin.value) line

import time
import board
from digitalio import DigitalInOut, Direction, Pull
from analogio import AnalogIn
 
pin = AnalogIn(board.A1)
 
def get_voltage(pin):
	return (pin.value * 3.3) / 65536
 
while True:
    print(get_voltage(pin))
    #print(pin.value)
    time.sleep(1)

Output

Here is what I saw in Mu REPL window for the voltage returned

0.0797607
0.0805664
0.0813721
0.0999023
0.242505
0.136963
0.31582
0.319043
0.323877
0.327905

A low value was me covering the sensor and the higher value was a desktop lamp

Links

Datasheet – https://www.vishay.com/docs/81579/temt6000.pdf

You may also like

Leave a Comment