valeurs-partagees.ino
The bridge value store is the shared MCU↔Linux variable: valuePut exposes a key readable by a plain local HTTP request, valueGet fetches a setpoint written from the Linux. Two lines for a full round trip.
Hardware
An Arduino Tian (Microchip SAM3X8E + TianOS Linux on an Atheros AR9344, dual USB, Ethernet and Wi-Fi). 1 potentiometer or LDR on A0 for the demo.
Wiring
Wiper to A0, ends to 5V and GND.
How it works
Bridge.valuePut pushes the key to the bridge daemon on the Linux side, exposed under /data/<key>; valueGet re-reads a key the Linux wrote with a POST /data.
Running it
Arduino IDE with the Arduino Tian board: upload over the « Native » USB port. Linux side: ssh root@arduino.local. The Bridge library is identical to the Yun's.
Variants
Add state keys (relay, mode) for a small automaton, or rotate the setpoint from a Linux cron.
valeurs-partagees.ino
// Echange de donnees par le magasin de cles du pont.
#include <Bridge.h>
const int CAPTEUR = A0;
unsigned long t0 = 0;
void setup() {
Bridge.begin();
}
void loop() {
if (millis() - t0 < 1000) return;
t0 = millis();
// 1) Publier la mesure : cote Linux -> GET /data/lumiere
int brut = analogRead(CAPTEUR);
Bridge.valuePut("lumiere", String(brut).c_str());
// 2) Lire une consigne ecrite par le Linux (defaut 500).
String consigne;
if (!Bridge.valueGet("seuil", consigne) || consigne.length() == 0) {
consigne = "500";
}
int seuil = consigne.toInt();
if (brut < seuil) {
Bridge.valuePut("alerte", "obscurite");
} else {
Bridge.valuePut("alerte", "ok");
}
}
// Cote Linux (Yun) :
// curl http://localhost/data/lumiere
// curl -d "400" http://localhost/data/seuil