SparkFun Forums 

Where electronics enthusiasts find answers.

All things pertaining to wireless and RF links
By jeremyhise
#184475
Yes! That's right, my simple setup is dropping lower case "p". This has to rank as one of the dumbest problems I've had in my 20+ years as a programmer.

I have a fairly simple setup. An UNO with an XBee S1 Pro attached via an xbee shield. This device reads an analog value from a pot and sends it via serial to my other UNO with an XBee s1 Pro. It sends a string like "Reporter r1:Temperature:123". On the receiving end, I receive one of the following:

Reporter r1:Temperature:123
Reorter r1:Temperature:123
Reporter r1:Temerature:123
Reorter r1:Temerature:123

If I change the string that is being transmitted to upper case, it doesn't happen. If I change the lower case "p" to "s", it doesn't happen.

Have I finally gone insane?

Any help or direction would be greatly appreciated.
By jeremyhise
#184545
Thank you for responding. There are a lot of supporting classes so I'll simply include the main loop on the receiving device:

void loop()
{

if(XBee.available()) {
incomingData = XBee.readString();
if(incomingData != "") {
Serial.println(network.getLabel() + ":" + logger.formatResults(incomingData));
Serial.println(incomingData); // This will also print the erroneous string
} else {
Serial.println("Xbee available, no data");
}
digitalWrite(ledRXPin, LOW);
} else {
digitalWrite(ledRXPin, LOW);
}
}

Note the two Serial.println() calls. The first is the original code and the second was to quickly see if I was goofing something up.

Here is the sending device setup and main loop:

void setup()
{
Serial.begin(BAUD_RATE);
XBee.begin(BAUD_RATE);
pinMode(13, OUTPUT); // We simply blink the 13 led when we send data

// 1. Here we are directly setting the label that will help us visually identify
// this reporting board when looking at the data.
reporter.setLabel("Reporter R1");

// 2. Add a sensor to the collection. This is an analog sensor attached to port 0. We
// are giving in an arbitrary ID of 1.
my_sensor_collection.addSensor(1, 0, PIN_TYPE_ANALOG, "Potentiometer");
my_sensor_collection.addSensor(2, 1, PIN_TYPE_ANALOG, "Temperature");


}


void loop()
{
ESN_Sensor current_sensor;

/**
* All of the following is left as is as we have yet to determine a format. We have to take
* readability (machine) into account as well as dealing with this data collision issue.
*/

// Reset the internal pointer on the sensor collection
my_sensor_collection.reset();

digitalWrite(13, HIGH);

// Loop through all the sensors
for(int i = 1; i < my_sensor_collection.getSensorCount() + 1; i++) {
// Get the current sensor
current_sensor = my_sensor_collection.getNextSensor();
Serial.println(reporter.getLabel() + ":" + current_sensor.getLabel() + ":" + (String) current_sensor.readValue().value);
// The logger has an issue parsing lines based on \n character. For this reason, we are going to send sensor data one reading
// at a time.
delay(TRANSMIT_DELAY);
}
digitalWrite(13, LOW);
}


If you look at the setup method on the "sending" device, I will have problems with those "p"s. However, I changed it to REPORTER R1 and the sensors to TEMP and POTS and I have not seen a problem in 3 days. That's about 10,000 transmissions.

The Baud rate is 19200. I raised in attempt to deal with data collisions. The idea is to run 10 - 20 "sending" devices.

Thanks again for any help. I can make due with using caps but I sure would like to know what the heck is going on.