Getting a faster transmission using Bridge.put


My initial project is to build a wireless sensor interface for me and for friends of mine musician/dance/circus artists.
Considering the purpose is to use the data with Max/MSP or alike i wanted an OSC format for the raw data to be sent

So the idea was to get the raw values from sensor from Arduino side to YUN side, then to send thoses values with a Python script (I don’t know Python I just learned right there for the purpose of the project)

I tried quite a lot of things and figured out 2 possibility to get the data from Arduino to YUN with the help of the forum :

  • To use the (key,value) communication with Bridge.put
  • To use serial transfer with serial module in Python, and use the following code to get it
serialConnection = serial.Serial("/dev/ttyATH0", 115200, timeout=1)

So far I chose the Bridge.put approach considering I didn’t have to disabled the console that way ans it seemed easier.

Here are my codes

Arduino : this one juste read a potentiometer input that i use for testing everything


int potPin = 2;    // select the input pin for the potentiometer
int val;

void setup() {
  Serial.begin(115200); //opens serial port, sets data rate to 115200 bps
  while (!Serial) {
  }; //gives time to serial to open
   // Bridge startup
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  digitalWrite(13, HIGH);

void loop() {
  val = analogRead(potPin);    // read the value from the sensor
  Bridge.put("Pot", String(val));

Python Script : The script get the value from the ‘Pot’ and send it thru OSC.
At first I did put it within the Arduino sketch with a Process call after each Begin.put but it was really very slow (1s to enter the process and give the value). So I took the script out and I run it wiht an SSH command (I could do it at Linino Startup within Luci maybe ?)

import OSC

import sys 
sys.path.insert(0, '/usr/lib/python2.7/bridge/')

from bridgeclient import BridgeClient as bridgeclient

sensorsRawData = bridgeclient()

# Init OSC 
client = OSC.OSCClient()
msg = OSC.OSCMessage()

# To be looped infinitly
while True:
	client.sendto(msg, ('', 9001))

Doing that way i can make the transmission BUT it’s still too slow (about 5/6Hz, so a value every 166/200ms which isn’t enough for a lot of purpose)
Now I’m gonna start to investigate the “serial connection approach”, but maybe i’m just missing something somethin that might improve the “Bridge.put() approch” ?

I did some "serial connection approach" test, the speed could reach ~4ms. if not faster enough then go through SPI. if still too slower then go through ar9331 MAC/PHY but MCU need updated/replaced.

Good to know !

The 200ms speed is something. We begin the artistic part tomorrow, working on the movement and relationship with sensors/music (even if we ever draw quite a good idea of the basical use of this system for this specific performance about the "suspension points" and its relationship with musical "crouse/anacrouse")

About the serial approach if you have any step by step guidance i would certainly have use of it, especially if you ever have a python script. Even if i guess the basical idea is to use nano or any other text edit software to comment a line that take the console out. Then use this line to get the serial communication

serialConnection = serial.Serial("/dev/ttyATH0", 115200, timeout=1)

(in such a case i'm certainly gonna change my arduino code to send OSC formatted data instead of doing it within python,i would have to parse the serial data in order to separate every sensor and i prefer not to work on such a parsing when it's time to choreography now)

Thank you !

Would one want to use the previous arduino code in a wifi situation you should delete this line

  Serial.begin(115200); //opens serial port, sets data rate to 115200 bps
  while (!Serial) {
  }; //gives time to serial to open

If you don't the arduino loop, and even the end of the setup won't happen as the serial connection isn't available.