Reading xbee data in Processing

Hi all,

I'm trying to send data from an xbee series 1 connected to an arduino Fio to the serial port using an xbee explorer usb. I want to use the data in processing. As a test I just I try sending "hello" with this simple example:

void setup(){

void loop(){
  Serial.write(45); // send a byte with the value 45
   int bytesSent = Serial.write("hello"); //send the string “hello” and return the length of the string.

In the X-CTU monitor everything works fine, I can read the word 'hello'. In processing however I just get the following numbers: 104 108 111 repeated over and over. I use this code in processing:

import processing.serial.*;

Serial myPort;  // Create object from Serial class
int val;      // Data received from the serial port
void setup() 
  size(200, 200);
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 9600);

void draw()
  if ( myPort.available() > 0) {  // If data is available,
    val =;         // read it and store it in val

Does anyone know what's happening here? Any help would be greatly appreciated. Best, d

In processing you are simply printing the value of the bytes you receive. You are not printing the ASCII code that this corresponds to. You need to do this to read the message hello.

In processing however I just get the following numbers:
repeated over and over.

I bet there are other numbers as well, in particular those that correspond to the letters in hello.

Hi thanks very much for your fast response. Where should I look to convert the bytes to ascII? TIA, danielle

I've got it! From the serial library in Processing I need to use this:

// Example by Tom Igoe

import processing.serial.*;

int lf = 10;    // Linefeed in ASCII
String myString = null;
Serial myPort;  // The serial port

void setup() {
  // List all the available serial ports
  // Open the port you are using at the rate you want:
  myPort = new Serial(this, Serial.list()[0], 9600);
  // Throw out the first reading, in case we started reading 
  // in the middle of a string from the sender.
  myString = myPort.readStringUntil(lf);
  myString = null;

void draw() {
  while (myPort.available() > 0) {
    myString = myPort.readStringUntil(lf);
    if (myString != null) {

More info here: