Giuseppe Parrello

 

Embedded Photoresistor


Introduction

With this project we will manage a photoresistor, using the FTDI FT232H development board (of which there is a dedicated page on this site) and the TI ADS1115 development board (of which there is a dedicated page on this site).

 

Connection

This photoresistor must be connected to the TI ADS1115 development board. The connection connectors are listed below:

Image Board FT232H Board ADS1115 Photoresistor

FT232H - ADS1115 - PHOTORESISTOR

AD0 SCL ------
AD1 + AD2 SDA ------
+5V VDD ------
GND GND ------
------ A0 SIG
+3.3V ------ VCC
GND ------ GND

 

Python code

To manage this photoresistor, the presence of the "Adafruit CircuitPython ADS1x15" library is required.
The following Python code example displays both the current value (in "raw" format) and the current voltage of the photoresistor:

import time
import board
import busio
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn

# Create the I2C bus
i2c = busio.I2C(board.SCL, board.SDA)

# Create the ADC object using the I2C bus
ads = ADS.ADS1115(i2c)

# Create single-ended input on channel 0
chan = AnalogIn(ads, ADS.P0)

print("{:>5}\t{:>5}".format("raw", "v"))

while True:
    print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
    time.sleep(0.5)

To manage this photoresistor, the presence of the "ADS1115_FTDI" library is required.
The following Python code example displays both the current value (in "raw" format) and the current voltage of the photoresistor:

import time
import ads1x15 as ADS

# Create the ADC object using the I2C bus
ads = ADS.ADS1115()

# Create single-ended input on channel 0
chan = ADS.AnalogIn(ads, ADS.P0)

print("{:>5}\t{:>5}".format("raw", "v"))

while True:
    print("{:>5}\t{:>5.3f}".format(chan.value, chan.voltage))
    time.sleep(0.5)