Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Xiao ESP32 C3 and ADS1115-Based Light Intensity Data Logger

View and Edit Project In Cirkit DesignerImage of Xiao ESP32 C3 and ADS1115-Based Light Intensity Data Logger

Circuit Documentation

Summary of the Circuit

This circuit is designed to read currents from four phototransistors using an Adafruit ADS1115 16-bit ADC, which is interfaced with a Xiao ESP32 C3 microcontroller via I2C communication. The ADC converts the analog signals from the phototransistors into digital values that the microcontroller can process. The readings are then printed to the Serial monitor. The circuit is powered by a DC power source, and a resistor is used to form a pull-down network for the phototransistor.

Component List

Xiao ESP32 C3

Adafruit ADS1115 16Bit I2C ADC

DC Power Source

Phototransistor

Resistor (10 Ohms)

Wiring Details

Xiao ESP32 C3

Adafruit ADS1115 16Bit I2C ADC

DC Power Source

Phototransistor

Resistor (10 Ohms)

Documented Code

/*
 * This Arduino Sketch reads the currents from four phototransistors using
 * an Adafruit ADS1115 16-bit ADC connected via I2C to a Xiao ESP32 C3.
 * The readings are printed to the Serial monitor.
 */

#include <Wire.h>
#include <Adafruit_ADS1X15.h>

Adafruit_ADS1115 ads;  // Create an ADS1115 object

void setup() {
  Serial.begin(115200);  // Initialize serial communication
  Wire.begin();  // Initialize I2C communication
  ads.begin();  // Initialize the ADS1115
}

void loop() {
  int16_t adc0, adc1, adc2, adc3;
  adc0 = ads.readADC_SingleEnded(0);  // Read AIN0
  adc1 = ads.readADC_SingleEnded(1);  // Read AIN1
  adc2 = ads.readADC_SingleEnded(2);  // Read AIN2
  adc3 = ads.readADC_SingleEnded(3);  // Read AIN3

  // Print data to Serial monitor
  Serial.print("AIN0: ");
  Serial.print(adc0);
  Serial.print("\tAIN1: ");
  Serial.print(adc1);
  Serial.print("\tAIN2: ");
  Serial.print(adc2);
  Serial.print("\tAIN3: ");
  Serial.println(adc3);

  delay(1000);  // Wait for 1 second before next reading
}

The code is written for the Arduino platform and is intended to be uploaded to the Xiao ESP32 C3 microcontroller. It initializes the I2C communication, sets up the ADS1115 ADC, and continuously reads the analog inputs from the phototransistors, printing the results to the Serial monitor every second.