We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Let's say I was outputting a string with an output of a sensor. So Serial.println("reading" + String(reading)) on arduino that uses Xbee to transfer it to GUI. Constantly. However, if there's no easy solution, I will just stop streaming because I am required to output certain things rather than everything. Thanks for your quick replies guys!
I think you need to check the arduino forum for this type of question or stackoverflow. You might try previous posts: https://forum.processing.org/two/search?Search=xbee
Kf
Hello all,
I am working on a project in which I am using an Arduino attached to an XBee to send data to an XBee that is attached to my computer. I am then trying to use processing to intercept the data that the XBee at the computer is gathering. However, the port that the XBee is plugged into is always in use gathering, and thus never has any chance to send it to processing. I was wondering if anybody knew a work around for this? I have working processing code to gather data directly from the Arduino (no XBee involvement) with no "port busy" error.
Thank you for any insight you may have!
So I have been working on a user interface for a robotics project of mine, using Game Control Plus for the USB controller input processing, that is sent out to my Arduino via an Xbee.
For obvious safety reasons I was testing what happens if say my dead man switch is pressed then Disconnect the my controller, I have notice it keeps the value of the press thus this could lead to a run away situation. I would like to know if there is away to detect in this library a controller disconnect, and if so how to implement it.
I mean I could simply check for a change in input over time if none then consider it a disconnect but this would not be the most elegant of solutions. As I use a wireless 360 Controller this would be a nice feature to have.
I find checking previous post is always a good way to start:
https://forum.processing.org/two/search?Search=xbee
Kf
Hi everyone!
I'd like to learn how to use an xbee with processing in order to send ascii data (e.g.: "hello world!")... Does anyone have any examples for doing this?
Any thoughts/suggestions/example would be great!
this is sender node :
My problem is when it receive "node1" from sender through xbee, the condition is aborted.. BUT, when i manually write in serial, the condition is worked.. i think the data sent by sender is not actually "node1"..even when i Serial.print(), it shows ""node1" physically.
this is receiver node:
The correct library xbjlib.zip is located in the processing_getting_started directory (see XBeeArduinoCodingPlatform-1.0.0.zip, https://github.com/digidotcom/XBeeArduinoCodingPlatform/releases).
The XBJL-1.1.1 library works with NetBeans or Eclipse IDEs.
Thank you :-*
Hi,
I try to run the follow_the_leader demo from XBeeArduinoCodingPlatform (see https://docs.digi.com/display/XBeeArduinoCodingPlatform/Follow+the+Leader).
Unfortunately, I get : No library found for com.digi.xbee.api.models No library found for com.digi.xbee.api.connection Libraries must be installed in a folder named 'libraries' inside the 'sketchbook' folder.
However, I have put the XBJL-1.1.1 directory in the ~/Documents/Processing/libraries directory as required.
Could anyone help me ?
Thank you.
That's what I thought, or my teacher told me that it is possible is my concern... Thank you for your help and your patience ^_^ So my program is fully functional with your help ! I will divide the code in cases where at the end of my project if someone is interested in an interface connecting a hive that is managed from multiple sensors and XBEE.
Regards,
Hi guys ! As I encoutered a problem, but not the solution, I need your help ! :D
The program is a graphic interface used to pilot a robot thanks to a xbee and arduino card. Into it, I have loaded an image of a little robot. I would like to rotate the robot of +/- PI/8 each time I press 'q' or 'd'. BUT, when I tried to code it, as I was expected it, ALL the screen is rotating.
Do you guys have any idea of how to rotate the robot's image but not the graphic interface ?
Thank you very much !
Hello, I have a problem, I need to make a communication between my Xbee module and Processing/Arduino. I have to do a simulation like exemple the height, the temperature.
I have an exemple like this video :
Can you help me please, do you have a similary program ? Thank you very much.
Dude,
I'm not 'starting wrongly' with myPort.read(), and repeating it and putting up a childish gif doesn't make you right, I'm afraid. Nor does sidetracking with a pointer to how I should be presenting my code. I don't give a flying f*** what the forums 'expect' of me, just in why this library is wack.
I'm interested in a byte, value 126, period. I don't need to use readString(), it's entirely irrelevant. Either bufferUntil(0x7E) waits until 126 arrives or it does not.
Then, either port.read() gathers it correctly, every time, or it mucks it up every time, not one way, then the other. What do you think readString() is going to produce, when faced with 126 coming in? I need to parse packets of bytes, not strings, and I sure as Hell don't need to be converting stuff from one form to another.
"Works better with ending values, not starting 1s", is the most bizarre 'answer' I've ever heard!
Also, it's entirely incorrect to say that I have to wait until the next transmission. With buffer(1) set, every single byte that hits the port triggers a serialEvent(). With buffer(8), for example, it takes 8 bytes (obviously) to arrive before serialEvent() fires.
The XBee sends a packet, of [n] bytes, starting with a delimiter, 126. There are many scenarios in which that's it, there's no more to come. myPort.read() DOES do exactly as it should, no need for any string anything.
I don't want to get embroiled in petty arguments here, just looking for a definitive answer. Thanks for your input, but you've either not grasped what I'm talking about, or you don't know what you're talking about. No need to reply, thanks.
Max
Hi,
Thanks for the reply.
Initially, the Arduino is not relevant. The XBee sends it's node information wirelessly, independently of any attached device, to the co-ordinator, which is plugged into my USB port. This is a packet of information with a format that starts with a delimiter, 7E. Thus, I don't have control over how the data is sent and, besides, it's a byte arriving howsoever.
I was using this simple code in setup:
myPort = new Serial(this, Serial.list()[3], 19200);
myPort.buffer(1);
myPort.bufferUntil(0x7E);
txPacket(AT_ND);
(This last line is a simple method that sends a remote AT command to all XBees, asking them to broadcast their identification settings)
Inside serialEvent, I was merely doing this, to see why things weren't working:
print(hex(myPort.read(),2));
This produces the output:
7E00
The 7E arrives when the co-ordinator sends its node information, then the 00 appears when the end device sends its information. As far as I'm concerned, using bufferUntil(0x7E) should produce:
7E7E
OR... If the 7E is being discarded, then:
0000
Unless somebody wants to explain why it differs...
If I do NOT use bufferUntil(0x7E), I can see both packets arrive, perfectly formed, BOTH beginning with 7E, thus:
7E001E88014E440000000013A200409351CF4D415354455200FFFE0000C105101E7F 7E001D88014E4400CB860013A200409351AF534C4156450000000200C105101E9A
I won't go into the details of the XBee packet structure, as it's not relevant. Suffice to say the device names ('MASTER','SLAVE') are in there, along with packet length info, checksums, etc.
If I just use myPort.read() inside serialEvent(), and add each byte to an array, everything is perfect, and in sync, with no issues, as one would expect.
Again, thanks for the reply, but it doesn't explain what's going on.
Max
Hi,
I'm pulling my hair out with the buggy serial library in Processing. I'll try and explain without pasting reams of code here.
In my setup, I'm sending a node discovery command to an XBee co-ordinator (AT command ND), running in API mode. In my serialEvent, I used to wait for the Xbee delimiter (7E) using bufferUntil(0x7E), then do a port.read() to get the LSB of the packet length, then another port.read() for the MSB. I would then do a loop of [LSB] iterations to read in the packet.
port.buffer(1) must be set, btw, otherwise all kinds of weird behaviour results. Using different values truncated the packets, which are of varying length, naturally, so you have to trigger on each seperate byte arrival.
The XBee replies (in my two device setup) with two packets, one containing the name of the co-ordinator, and one containing the name of the end device. However, it became apparent that bufferUntil(0x7E) would produce the delimiter first time, and the 00 of the MSB the next, skipping the 7E. Why?
After trying numerous workarounds, I gave up, and started writing a ring buffer. Initially, I could watch the two XBee packets hit it, totalling the correct length, so I went back to the Arduino code that I'm using to send data to Processing.
The data packets are hitting the ring buffer, which is now filling up nicely. However, NOW, if I stop the Processing sketch, and let the Arduino continue to send packets, THEN stop the Arduino sketch, THEN start the Processing sketch, I get 130 bytes, always 130 bytes, sitting in the buffer, even though it's inside a class, and I'm instantiating it in my setup. Obviously, the serialEvent is firing when the sketch is started, and all attempts to clear it down are failing miserably.
I've tried port.clear(), a loop of port.read() inside a while(port.available() > 0), and nothing is working. Obviously, I need everything to be initialised when I stop and then run the Processing sketch, as eventually, data will be coming in from numerous devices, and I have to have a zero'd ring buffer, from which to start extracting valid packets.
If the bufferUntil() method wasn't so flaky, I wouldn't need to be faffing around with a ring buffer anyway. I hope I've explained this clearly. Before anybody says 'post some code snippets', you have to realise that all my workaround stuff is relevant, and has been cut and replaced with numerous different attempts at curing this issue.
I could do with some help here, before I un-install Processing and look for a more robust piece of s/w for my project. I simply cannot be the only person experiencing these issues.
Thanks.
Max
i have made ultrasonic rader using arduino uno and processing tool. now i have to make it wireless with the help of xbee. i am not geting how to make it.as i have never work on xbee.plz help me its urgent.
i am using xbee interfacing with processing and i have to switch on two push buttons to give me output 0,1,2 and when the first button is switched on it give output 1 and when the second button is switched on it give output 2 either if both are off it give 0 so i want to sound an alarm when my output is 1 and 2. my code for just getting output 1 and 2 without alarm sound is as follow
import processing.serial.*;
Serial myPort;
String sensorReading="";
PFont font;
void setup() {
size(600,400);
background(255,255,255);
//intial colour of boxes
myPort = new Serial(this, "COM3", 9600);
myPort.bufferUntil('\n');
font = createFont(PFont.list()[2],32);
textFont(font);
}
void draw() {
//The serialEvent controls the display
}
void serialEvent (Serial myPort){
sensorReading = myPort.readStringUntil('\n');
if(sensorReading != null){
sensorReading=trim(sensorReading);
}
writeText("Button No: " + sensorReading);
}
void writeText(String textToWrite){
background(208,24,24);
fill(0);
text(textToWrite, width/10, height/2);
}
Hi,
I have some simple code that is controlling an Arduino based Vehicle and something in this particular setup is not working. What I have done so far:
The setup where I have the problem is with my Mac running Yosemite and Processing 2.2.1 I can successfully communicate via bluetooth to the Arduino via the Arduino Serial Monitor. So bluetooth is paired right and the hardware setup works too. I did some simple call-response tests, turn LED on or off etc. via Arduino and that works.
The obvious would be not choosing the correct port, but I did that too. I even got it my Rover to react sometimes via bluetooth using processing, but with a huge delay. And sometimes it does not react at all. Believe me, I wish I could give you more consistent information but it is behaving erratically (at least to me).
What I have observed is that whenever I run this processing code on my mac that fan comes on and something is working really hard. I have the latest Version of Java installed. Maybe somebody has an idea from this description already and I am of course happy to provide more information!
Thanks!
Here is the code I am using:
import processing.serial.*;
Serial myPort;
String inString;
void setup()
{
size(1000,800);
background(10,200,25);
printArray(Serial.list());// prints a list of ports in the status window
String portName = Serial.list()[3];// This is where you must match port numbers.
myPort = new Serial(this, portName, 9600);
}
void draw()
{
//Draw the arrows and the commands button
fill(30,25,255);
rect(400,100,200,150);// Forward button
triangle(400,100,600,100,500,50);
rect(400,450,200,150);//reverse button
triangle(400,600,600,600,500,650);
rect(100,250,150,200);//left button
triangle(100,250,100,450,50,350);
rect(750,250,150,200);// right button
triangle(900,250,900,450,950,350);
fill(204, 102, 0);
rect(350,300,300,100,7); //commands.txt button
fill(0, 102, 153);
text("Run commands in 'commands.txt'", 410, 355);
//check commands.txt button coordinates to see if it was pressed
if(mousePressed && mouseX>350&&mouseX<650&&mouseY>300&& mouseY<400)
{
String lines[] = loadStrings("commands.txt");
if (lines!=null) {
fill(10,200,25);
noStroke();
rect(400,0,300,30);
delay(100);
println("There are " + lines.length + " commands in commands.txt.");
for (int i = 0 ; i < lines.length; i++) {
String[] list = split(lines[i], ',');
if (list.length<4) {
println("INVALID: [" + lines[i] +"].");
}
else {
String mystring = lines[i];
int time = millis();
int mydelay = int(list[3]);
println("Executing command: [" + lines[i] +"].");
println(mydelay);
println(mystring);
myPort.write(mystring);
mydelayfcn(mydelay);
delay(300);
}
}
}
else
{
text("'commands.txt' not available", 410, 15);
}
}
//check Top square coordinates.
if(mousePressed && mouseX>400&&mouseX<600&&mouseY>100&& mouseY<250)
{
myPort.write("FA");
// println ("FA");
}
//Check bottom square coordinates
else if(mousePressed && mouseX>400&&mouseX<600&&mouseY>450&& mouseY<600)
{
myPort.write("BA");
}
//Check left square coordinates
else if(mousePressed && mouseX>100&&mouseX<250&&mouseY>250&& mouseY<450)
{
myPort.write("LA");
}
//Check right square coordinates
else if(mousePressed && mouseX>750&&mouseX<900&&mouseY>250&& mouseY<450)
{
myPort.write("RA");
}
else
{
myPort.write("5");
}
delay(100);
}
void mydelayfcn(int delay)
{
int time = millis();
while(millis() - time <= delay);
}
Hi, I am working on a remote mini ECG system and would like to send my data to a cloud server. I have set up an xbee system where the Xbee USB dongle receives data from an Xbee connected to my ECG chip. I have been told that Processing can be used to send the data received from the Xbee via a computers wifi connection to a cloud server. However, I am having trouble writing the code to connect to my cloud server URL.
My Xbees are series 1 and I am using an Arduino Uno as the microcontroller.
Are there any kind souls that can help me out? Is it possible to send my data over the internet without purchasing a wifi module? My project has budget constraints so I am trying to minimise my purchases.
Appreciate any help I can get!
I'm working on code to sense environmental data from a remote location using XBees, my Mac MIni, Processing, and XCode. I run my Processing code on the Mac. The Mac is connected via USB to the coordinator XBee, which in turn communicates wirelessly to the remote end-item XBee. Remote data is parsed by the Processing code and stored on the Mac's disk drive as a .dat file. The XCode Objective-C program reads that .dat file asynchronously, examines the data and sends an SMS message to my iPhone if something is amiss at the remote location.
I have all the parts working great. You can see a block diagram here: block_diagram
There is, however, one problem. The Processing and Obj-C programs loop continuously, checking the remote data about every 20 seconds. After about one hour, though, the Processing code breaks down. It no longer speaks to the coordinator XBee. I believe it has something to do with the USB interface. If I halt the Processing code, quit Processing altogether and disconnect/reconnect the USB cable, and then reload/rerun the Processing code, I can get the system working again. But for the life of me I can't figure out what is causing the problem after running fine for an hour or so.
Here are what I think are the pertinent lines of my Processing code:
import processing.serial.*;
Serial port; // Create object from Serial class
byte[] dataArray = new byte [40]; //create an array for the data read from the remote xbee
byte[] dataArray3 = new byte [40]; //create an array for the date read from the coordinator (xbee3)
byte[] shopData = new byte [32]; //create an array for the shop data stored to disk
byte chksum;
int count = 0;
byte doorstatus;
byte htrctrl;
int lightlevel;
float temp1;
float temp2;
int temp3;
float degreesC;
float degreesF;
byte pumpctrl;
float pumppressure;
int delayval = 100; // 100 ms
int i = 0; // array index
int x; // scratch value
float y; // scratch value
//set up addresses for each xbee in the network
int xbee1addrlow = 0x40B098E6; //end unit 1
int xbee2addrlow = 0x40ACC07E; //end unit 2
int xbee3addrlow = 0x4089DF59; //coordinator unit
void setup() {
println("setup");
println(Serial.list());
String arduinoPort = Serial.list()[5];
port = new Serial(this, arduinoPort, 9600);
The complete Processing code file is here.
The complete Objective-C code file is here. Though I don't think the issue is at all related to the C code. The same problem occurs whether I run the C code or not.
Sorry about this long post. If anyone has any ideas, I'd be very grateful.
Thanks,
Kevin H.