🛠 Téléverser par WiFi, logger sur microSD, et récupérer une Yún briquée
Objectives
Three operational skills to keep a Yún running: (1) upload sketches over WiFi, without a cable; (2) log sensor data to microSD from Linux; (3) recover a card with corrupted Linino OS (bad network config, failed opkg, full flash) using the restoration procedure.
Hardware
- 1 Arduino Yún on the network (preferably with a working WiFi configuration)
- 1 microSD card (FAT32 or ext4 depending on usage, 16 GB max recommended)
- Recent Arduino IDE
- Stable power supply (NEVER cut power during a reinstallation)
1) Uploading over WiFi
Once the Yún is on your network, the IDE (Port menu) displays it as a network port (arduino.local or its IP): the upload goes over the network, and the AR9331 reprograms the 32U4 via its internal serial port. Advantage: no more cables, the board stays in its enclosure. If the port does not appear: check mDNS (iTunes/Bonjour on Windows) or enter the IP in the additional ports.
2) Logging to microSD (Linux side)
# Montage auto typique : /mnt/mmcblk0p1 (sinon : mount /dev/mmcblk0p1 /mnt)
# Script de log alimenté par le data store du Bridge :
cat > /root/logger.sh << 'EOF'
#!/bin/sh
LOG=/mnt/mmcblk0p1/log.csv
[ -f $LOG ] || echo "timestamp,pot" > $LOG
while true; do
V=$(wget -qO- http://localhost/data/get/pot 2>/dev/null)
[ -n "$V" ] && echo "$(date +%s),$V" >> $LOG
sleep 5
done
EOF
chmod +x /root/logger.sh && /root/logger.sh &
On the sketch side, remember to publish regularly: Bridge.put("pot", String(analogRead(A0))). For a clean restart, add the script to /etc/rc.local.
3) Recovering a corrupted Yún
- Lost network: hold the WiFi button for ~30 s at startup → recovery mode (SSID "Arduino Yun"), reconfigure via http://arduino.local. The root password, however, is NOT reset by this button.
- Linino OS broken: the official reflash procedure uses recovery mode (booting an image from the 32U4 or USB) — download the Linino OS "sysupgrade" image and follow the recovery page on the Arduino/OpenWrt wiki. As a last resort, the SoC test pins allow serial booting. >
- 32U4 intact, Linux dead: the board continues to upload and blink via USB — only the Linux world needs reinstalling.
Expected Verification
Upload Blink WITHOUT a USB cable (via WiFi): the LED blinks. The logger script fills log.csv even after replugging (data survives, unlike /data in RAM). Simulate a disaster: passwd with a forgotten password over SSH → full reinstallation → the board comes back alive, with the microSD and 32U4 bootloader intact.
Common Errors
- Cutting power during a sysupgrade: this is THE best way to brick the AR9331; reflash patiently if it happens.
- microSD in exFAT/NTFS: Linux does not mount it properly — format as FAT32 (simple data) or ext4 (scripts/permissions).
- Logging to internal flash "because it works": ~10 MB and real wear; the microSD is there for this purpose.
- Disappointed with IDE 2.x: the Yún is a legacy platform; if the modern IDE no longer lists it, document your upload tool (IDE 1.8.x or arduino-cli) in your project.
- Confusing the two worlds when debugging: upload failing over WiFi = 32U4 chain (go back to USB); REST API dead but Blink OK = Linux world (recovery).
Other tutorials for this board
- Premiers pas sur la Yún : Bridge, Console et LED
- Connecter la Yún au WiFi et piloter une broche depuis le navigateur
- Envoyer un capteur analogique sur le réseau : potentiomètre et Bridge REST
- runShellCommandOnLinux : faire exécuter des commandes Linux depuis le sketch
- L'API REST du Bridge en détail : /arduino, /data et routes personnalisées
- Alerte email : bouton sur la Yún et envoi via sendmail
Code examples for this board
clignotant-rest.inoArduinoconsole-bridge.inoArduinovaleurs-partagees.inoArduinoprocess-shell.inoArduinoserveur-json.inoArduinolecture-fichier.inoArduino