We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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.