adk-telemetrie.ino

Arduino Mega ADK (Rev3) · File : adk-telemetrie.ino · Language : Arduino · Use case : Envoyer des mesures de capteurs vers le téléphone en trames simples

Structured data rather than chat: the board pushes one CSV line per second (analog input + rough temperature derived from the internal bandgap) to the Android app that plots it.

Hardware required

An Arduino Mega ADK Rev3 (ATmega2560 + MAX3421E USB host chip with a Type-A port; digital pin 7 is reserved for the MAX3421E reset). 1 Android phone + source on A0 (potentiometer recommended).

Wiring

USB-A → phone cable; potentiometer on A0 (5 V/GND/wiper).

How it works

Reading the AVR internal reference yields the supply voltage, from which an order-of-magnitude temperature comes; each \n-terminated line is one sample. Select « Arduino Mega ADK » in the IDE. For USB host/ADK work, install the USB Host Shield 2.0 library; do not use D7. The USB-A port powers the accessory at 5 V.

Going further

Add I2C sensors (BME280) to the frame, or log to EEPROM while the phone is unplugged.

adk-telemetrie.ino

// Telemetrie ADK : A0 + temperature interne -> trames CSV vers Android.
#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>

AndroidAccessory adk("Arduino", "Mega ADK", "Telemetrie", "1.0", "Fab", "Num");

void setup() {
  Serial.begin(9600);
  adk.Init();
}

void loop() {
  if (adk.isReady()) {
    int a0 = analogRead(A0);
    float vcc = 1100.0 * 1023.0 / analogRead(14); // A14 = bande passante interne
    float temp = (vcc - 500.0) / 10.0;            // approximation 5V
    String trame = String(a0) + "," + String(temp, 1) + "
";
    adk.write(trame.length(), (uint8_t *)trame.c_str());
    Serial.print(trame);
  }
  delay(1000);
}

← Back to the board