🛠 Pont série SoC ↔ MCU : le tunnel x86 vers ATmega32U4

LattePanda Alpha · intermediaire · Schéma : IMG-lattepanda-alpha-intermediaire-1-pont-serie-soc-mcu.svg — tunnel série USB interne reliant le script Python du SoC x86 au sketch Arduino de l ATmega32U4

Objectives

Set up the central pattern of the LattePanda Alpha: the serial bridge between the x86 PC (Core m3-7Y30) and its own ATmega32U4 coprocessor, connected via an internal USB invisible from the outside. The MCU sends measurement frames over Serial, and a Python script on the host reads them line by line. This is exactly the scheme of DFRobot's official "python_arduino_bridge" tutorial, without Firmata.

Hardware

Complete Code

On the firmware side (Arduino IDE, board "Arduino Leonardo"):

// stream_analog.ino — envoie A0 au PC hôte à 10 Hz
void setup { Serial.begin(9600); }
void loop {
  Serial.println(analogRead(A0));   // valeur ADC 10 bits : 0..1023
  delay(100);
}

On the host side (on the Alpha itself, Windows or any Linux distribution):

# host_reader.py — pas besoin de Firmata, tramage série simple
import serial  # pip install pyserial

# Windows : 'COM5'  |  Linux : '/dev/ttyACM0' (utilisateur dans le groupe 'dialout')
with serial.Serial('COM5', 9600, timeout=1) as ser:
    for line in ser:
        try:
            raw = int(line.strip)
            print(f'ADC={raw}  ({raw * 5.0 / 1023:.2f} V en supposant une référence 5 V)')
        except ValueError:
            pass  # ignorer les lignes partielles au démarrage

Expected Verification

The host terminal displays approximately 10 lines per second: ADC=0 (0.00 V) at rest, and values rising towards 1023 if a potentiometer is wired to A0. Ctrl+C stops the script without touching the firmware, which continues to transmit autonomously.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials