PROCESSING over WIFI


Most of my code on PROCESSING is using serial connection either a cable or XBEE module. Lately, while working on my new 4WD platform I got feed up with all the cables on the table and all the USB ports used so decided to move to WIFI, not only XBEE, a real WIFI connection. I do have a couple of WIFLY modules from Roving Networks and one of them is XBEE format, just nice to swap it to the existing XBEE module.

I thought there will be a lot work to switch from serial communication to WIFI, but in PROCESSING is actually pretty simple, just change few lines and you are done!

To use serial port communication the code will look like:

import processing.serial.*;
Serial myPort;

void setup() {
  size(200, 200);
  myPort = new Serial(this, "/dev/cu.usbserial-A700dzYV", 57600);
  myPort.clear();
}
...

For network communication (client mode) the code looks like:

import processing.net.*; 
Client myClient; 

void setup() { 
  size(200, 200);
  myClient = new Client(this, "192.168.1.8", 2000); 
}
...
 

Well, “myPort” can stay the same as long you initialise it properly, pretty cool, right?

Can’t wait to see if this bugger can really go up to 1Mbps as in the datasheet or hit the wall like XBEE @ 230400 Bps ^_^

 

Update: Unfortunately there is a latency, to have it work fine you’ll need to set the WLAN Rate to 11Mbps or 54Mbps. Also, when you plan using it you need to take into consideration the time you need to get the module authenticated and joining the network and the bunch of data generated on the serial port. Using XBEE on the other hand is pretty straight forward and fast… Now is only based on the application. 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s