edge lab LIVE! starts Tuesday in Munich. Grab a workshop seat and take home the board you build on. Code FRIEND-HACKSTER saves 20%. () Learn more!
Cathy Cathy
Published © MIT

Dual-Channel Sensor Interface with OPA2320

Build a compact dual-channel analog front end using OPA2320 to condition sensor signals before MCU ADC conversion.

IntermediateProtip24 hours18
Dual-Channel Sensor Interface with OPA2320

Things used in this project

Hardware components

OPA2320AQDGKRTW
×1
Arduino UNO
Arduino UNO
×1
NTC Thermistor
×1
Photoresistor / LDR
×1
Resistor 10k ohm
Resistor 10k ohm
×1

Software apps and online services

Digital Multimeter
Wire Cutter / Stripper
Soldering Iron
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Mastech MS8217 Autorange Digital Multimeter
Digilent Mastech MS8217 Autorange Digital Multimeter
Soldering iron (generic)
Soldering iron (generic)
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires

Story

Read more

Schematics

OPA2320

Code

Arduino Uno

C/C++
This Arduino sketch reads the two conditioned analog signals from the OPA2320 front end. A0 monitors the NTC temperature-sensing channel, while A1 monitors the LDR light-sensing channel. The firmware reports both ADC readings and their corresponding voltages through the Serial Monitor at 115200 baud.
/*
  Dual-Channel Sensor Interface with OPA2320

  Channel A:
    NTC Thermistor -> OPA2320 -> Arduino A0

  Channel B:
    LDR -> OPA2320 -> Arduino A1

  The Arduino reads both conditioned analog signals
  and reports the ADC value and voltage through Serial Monitor.
*/

const int NTC_PIN = A0;
const int LDR_PIN = A1;

const float ADC_REFERENCE = 5.0;
const int ADC_RESOLUTION = 1023;

void setup() {
  Serial.begin(115200);

  pinMode(NTC_PIN, INPUT);
  pinMode(LDR_PIN, INPUT);

  Serial.println("Dual-Channel Sensor Interface");
  Serial.println("OPA2320 + Arduino Uno");
  Serial.println("--------------------------------");
}

void loop() {
  int ntcADC = analogRead(NTC_PIN);
  int ldrADC = analogRead(LDR_PIN);

  float ntcVoltage = ntcADC * ADC_REFERENCE / ADC_RESOLUTION;
  float ldrVoltage = ldrADC * ADC_REFERENCE / ADC_RESOLUTION;

  Serial.print("NTC | ADC: ");
  Serial.print(ntcADC);
  Serial.print(" | Voltage: ");
  Serial.print(ntcVoltage, 3);
  Serial.println(" V");

  Serial.print("LDR | ADC: ");
  Serial.print(ldrADC);
  Serial.print(" | Voltage: ");
  Serial.print(ldrVoltage, 3);
  Serial.println(" V");

  Serial.println("--------------------------------");

  delay(500);
}

Filtered Dual-Channel Sensor Monitoring

C/C++
This code adds a simple signal-processing layer to the OPA2320 sensor interface. Each analog channel is sampled 16 times and averaged to reduce short-term ADC fluctuations. The filtered readings are converted to voltage and monitored for significant changes, allowing the Arduino Uno to provide more stable sensor data through the Serial Monitor.
/*
  OPA2320 Dual-Channel Sensor Monitor
  -----------------------------------
  A0: NTC sensor signal
  A1: LDR sensor signal

  Features:
  - Multi-sample averaging
  - Voltage conversion
  - Simple signal-change detection
  - Serial Monitor output
*/

const byte NTC_PIN = A0;
const byte LDR_PIN = A1;

const float VREF = 5.0;
const int ADC_MAX = 1023;
const int SAMPLE_COUNT = 16;

float previousNTC = 0.0;
float previousLDR = 0.0;

int readFilteredADC(byte pin)
{
  long total = 0;

  for (int i = 0; i < SAMPLE_COUNT; i++)
  {
    total += analogRead(pin);
    delay(2);
  }

  return total / SAMPLE_COUNT;
}

float adcToVoltage(int adcValue)
{
  return (adcValue * VREF) / ADC_MAX;
}

void printChannel(const char *name, int adcValue, float voltage)
{
  Serial.print(name);
  Serial.print(" | ADC = ");
  Serial.print(adcValue);

  Serial.print(" | Voltage = ");
  Serial.print(voltage, 3);
  Serial.println(" V");
}

void setup()
{
  Serial.begin(115200);

  pinMode(NTC_PIN, INPUT);
  pinMode(LDR_PIN, INPUT);

  Serial.println();
  Serial.println("OPA2320 Dual-Channel Sensor Monitor");
  Serial.println("16-sample ADC averaging enabled");
  Serial.println("------------------------------------");
}

void loop()
{
  int ntcADC = readFilteredADC(NTC_PIN);
  int ldrADC = readFilteredADC(LDR_PIN);

  float ntcVoltage = adcToVoltage(ntcADC);
  float ldrVoltage = adcToVoltage(ldrADC);

  printChannel("NTC", ntcADC, ntcVoltage);
  printChannel("LDR", ldrADC, ldrVoltage);

  // Detect relatively large changes in the conditioned signals
  if (abs(ntcVoltage - previousNTC) > 0.10)
  {
    Serial.println("NTC: Significant signal change detected.");
  }

  if (abs(ldrVoltage - previousLDR) > 0.10)
  {
    Serial.println("LDR: Significant signal change detected.");
  }

  previousNTC = ntcVoltage;
  previousLDR = ldrVoltage;

  Serial.println("------------------------------------");

  delay(500);
}

Credits

Cathy Cathy
4 projects • 0 followers
Electronics sourcing expert at lovechip. Focused on component integrity, EOL solutions, and next-gen semiconductor trends.

Comments