Sensor request with Arduino Yun to Processing via Spacebrew

Hello everyone,

I’m a beginner in programming and need some help for my project, but I didn’t found any solution in the internet.

For my bachelor thesis I’m trying to program an application with the aid of Processing and the Arduino Yun Board. I want to connect six pressure sensors with my Arduino Yun and want to sent each value via spacebrew to Processing. I tried it with the basic Range Sketch, which is included in the Spacebrew Processing and Arduino Libraries and it worked, but only with one single pressure sensor. At the moment I’m trying to make it work with two sensors at analog Pin 0 and 5. My Code looks like this:

Arduino Code:

#include <Bridge.h>
#include <SpacebrewYun.h>
SpacebrewYun sb = SpacebrewYun(“spacebrewYun Range”, “Range sender and receiver”);

void setup() {
Bridge.begin();
Console.begin();
delay(4000);
while (!Console){
; // wait for Console port to connect.
}
Console.println(“You’re connected to the Console!!!”);
sb.verbose(true);
sb.addPublish(“Pin0”, “range”);
sb.addPublish(“Pin5”, “range”);
sb.connect(„My IP Adress");
}

void loop() {
sb.monitor();
if ( sb.connected() ) {
int value0 = analogRead(A0);
sb.send(“Pin0”, value0);
int value5 = analogRead(A5);
sb.send(“Pin5”, value5);
}
}

Processing Code:

import spacebrew.*;
String server=„My IP Adresse";
String name;
String description =“Client that sends and receives range messages. Range values go from 0 to 1023.”;
Spacebrew sb;

int Pin0;
int Pin5;
int Pressure0;
int Pressure5;

void setup() {
size(1044, 200);
background(0);

sb = new Spacebrew( this );
sb.addSubscribe( “Pin0”, “range” );
sb.addSubscribe( “Pin5”, “range” );
sb.connect(server, name, description );

}

void draw() {
background(50);
stroke(0);
fill(255);
text(„Pressure0: ", 30, 60);
text(Pressure0, 180, 60);
text(„Pressure5: ", 30, 80);
text(Pressure5, 180, 80);
}

void onRangeMessage( String name, int value ){
if(name.equals(“Pin5”) == true){
Pressure5 = value;
}
if(name.equals(“Pin0”) == true){
Pressure0 = value;
}
}

As you can see I tried to get the different values for the pressure sensors in the void onRangeMessage, but it doesn’t worked…

Do you maybe have some hints or a sample code for me so that I can get the different values from each sensor?

As you can see I tried to get the different values for the pressure sensors in the void onRangeMessage, but it doesn't worked..

No, I can't see that. I can see that you tried to test that the name is "Pin0" or "Pin5". I can not see that you actually printed the value in name, to see what it actually is. I can not see that the code did, or did not, successfully compare the name to "Pin0" or "Pin5".

   text(„Pressure0: ", 30, 60); 
   text(Pressure0, 180, 60);
   text(„Pressure5: ", 30, 80);

What the heck is that? There IS a reason that you are supposed to use code tags.