🛠 Lire un capteur analogique 0–10 V sur les entrées Opta

Arduino Opta (micro PLC, STM32H747) · intermediaire · Schéma : IMG-opta-plc-intermediaire-2-opta-entree-analogique.svg — transmetteur de pression 0-10 V alimenté en 24 V dont la sortie analogique est raccordée à la borne I1 de l'Opta avec le diviseur interne 12 bits

Objectives

Configure the multifunction inputs I1..I8 in analog mode to read 0–10 VDC transmitters. The Opta offers a user-configurable resolution from 12 to 16 bits (LSB 166 µV, accuracy ±5 %, repeatability ±2 %, acquisition cycle 10 µs). You will learn how to convert the raw reading into actual voltage using the onboard voltage divider (factor 0.3034).

Hardware

Complete code

// opta_analogique_0_10v.ino — surveillance de 3 transmetteurs 0..10 V
const float VOLTAGE_MAX = 3.3;     // pleine echelle ADC
const float RESOLUTION  = 4095.0;  // 12 bits
const float DIVIDER     = 0.3034;  // diviseur embarque 10 V -> ~3,3 V
const int TERMINAUX[]   = {A0, A1, A2}; // borne I1, I2, I3

void setup {
  Serial.begin(9600);
  analogReadResolution(12); // 12..16 bits configurables sur Opta
}

void loop {
  for (int i = 0; i < 3; i++) {
    int brut = analogRead(TERMINAUX[i]);
    float volts = brut * (VOLTAGE_MAX / RESOLUTION) / DIVIDER; // 0..10 V
    Serial.printf("I%d : %d -> %.3f VDC\n", i + 1, brut, volts);
  }
  delay(1000);
}

Expected verification

With a transmitter outputting 5 V, the corresponding line displays approximately 5.000 VDC. By switching to analogReadResolution(16), decimal stability improves (oversampling). The measurable range is 0–10 VDC only in analog mode — not 24 V.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials