I have an arduino opta running the example sketch from thedocumentation:
/**
Opta's Analog Input Terminals
Name: opta_analog_inputs_example.ino
Purpose: This sketch demonstrates the use of I1, I2, and I3 input
terminals as analog inputs on Opta.
@author Arduino PRO Content Team
@version 2.0 22/07/23
*/
// Define constants for voltage, resolution, and divider.
const float VOLTAGE_MAX = 3.3; // Maximum voltage that can be read
const float RESOLUTION = 4095.0; // 12-bit resolution
const float DIVIDER = 0.3034; // Voltage divider
// Array of terminals.
const int TERMINALS[] = {A0, A1, A2};
// Number of terminals.
const int NUM_PINS = 3;
void setup() {
// Initialize serial communication at 9600 bits per second.
Serial.begin(9600);
// Enable analog inputs on Opta
// Set the resolution of the ADC to 12 bits.
analogReadResolution(12);
}
void loop() {
// Loop through each of the terminal, read the terminal analog value, convert it to voltage, and print the result.
for (int i = 0; i < NUM_PINS; i++) {
readAndPrint(TERMINALS[i], i + 1);
}
// Delay for a second before reading the terminals again.
delay(1000);
}
// This function reads the value from the specified pin, converts it to voltage, and prints the result.
void readAndPrint(int terminal, int terminalNumber) {
// Read the input value from the analog pin.
int terminalValue = analogRead(terminal);
// Convert the terminal value to its corresponding voltage.
float voltage = terminalValue * (VOLTAGE_MAX / RESOLUTION) / DIVIDER;
// Print the terminal value and its corresponding voltage.
Serial.print("I");
Serial.print(terminalNumber);
Serial.print(" value: ");
Serial.print(terminalValue);
Serial.print(" corresponding to ");
Serial.print(voltage, 5);
Serial.println(" VDC");
}
The weird thing is i was hoping to read the input voltage of a voltage divider by reading the output voltage.
R1 = 68k and R2 = 10k , with a 24V input the output should be 3.077V which is correct when i measure the Vout with a multimeter.
The weird part is the moment i connect the Vout of 3.077V into A0 or A1 or A3 the voltage drops to 1.54V and serial monitor also shows this voltage :
I1 value: 0 corresponding to 0.00000 VDC
I2 value: 583 corresponding to 1.54851 VDC
I3 value: 0 corresponding to 0.00000 VDC
Why is this happening? The 24V came from the the same 24V the opta is powered with, the ground of the voltage divider is also connected to the same powersupply.
Is there a analog ground that i need to connect perhaps?


