analogique.ino
The GIGA's 12-bit ADC samples at 50 Hz with a 32-sample sliding average: the serial plotter shows a clean curve, ready for a real analog sensor (0-3.3 V).
Hardware required
An Arduino GIGA R1 WiFi (STM32H747, 1DX radio module: Wi-Fi b/g/n + BLE, u.FL antenna included), powered over USB-C. 1 0-3.3 V analog sensor (potentiometer wiper, conditioned module output).
Wiring
Signal on A0, common GND. Never exceed 3.3 V: the ADC is not 5 V tolerant.
How it works
The 32-value circular buffer smooths without allocation; analogReadResolution aligns width to the STM32H7 native. Sampling at 50 Hz leaves the M7 free. In the Arduino IDE, « Arduino Zephyr-based Boards » platform, « Arduino Giga R1 » board; fit the u.FL antenna before using the radio, then Upload.
Going further
Trigger an out-of-range alert, or send the average over CAN (dedicated sketch).
analogique.ino
// Capteur analogique sur A0 : ADC 12 bits + moyenne glissante.
const int CANAL = A0;
const int FENETRE = 32;
uint16_t tampon[FENETRE];
int tete = 0;
unsigned long precedent = 0;
void setup() {
analogReadResolution(12); // 0..4095 pour 0..3,3 V
Serial.begin(115200);
}
void loop() {
if (millis() - precedent < 20) return; // 50 Hz
precedent = millis();
tampon[tete] = analogRead(CANAL);
tete = (tete + 1) % FENETRE;
uint32_t somme = 0;
for (int i = 0; i < FENETRE; i++) somme += tampon[i];
float moyenne = (float)somme / FENETRE;
float volts = moyenne * 3.3f / 4095.0f;
Serial.printf("%6.1f %.3f V\n", moyenne, volts); // traceur serie
}