Can someone please advise me with this problem, it seems I have not figured out something...
I have used already in three projects the SerialCommand library (link below)
It is a very nice piece that I can recommend to anyone. It allows you to send and parse commands via a serial link (either wired or wirelessly e.g. through XBees), from one micro microcontroller to another in a very elegant way. Using the library, you can assign call handler procedures. These are called automatically, whenever a pre-defined command is received over the serial link. With this library I am able to control Arduinos wirelessly from a central "router"-Arduino. The router arduino itself receives the serial command messages through a iobridge IO-204 Web Gateway from my iphone... so much for the background.
Let's assume I have defined the command "LIGHTON", in order to flip on a relay whenever I send this command. I found out that when I send the command from the iobridge dashboard, I have to add "%0D" (the code for a carriage return) to the actual command in order to make it work. In other words, sending "LIGHTON" does not trigger the call handler, while on the other hand "LIGHTON%0D" does. No big deal, every command defined in the dashboard got he extra little bit of code. So far so good....
However, now I am trying to build a handheld "remote control" by using an Arduino Fio equipped with an XBee. From this unit I want to simply broadcast out serial command, e.g. on button presses, to switch stuff on and off. I found out though, that sending "LIGHTON" does not work. The message gets sent out but it does not trigger the receiving Arduino (it is not an Xbee configuration problem, because I use the Xbee that that works fine in passing on the serial messages from the iobridge). Here below a flow scheme in order to explain better:
iobridge serial message --- cable to--- sender Arduino --> (serial command "LIGHTON%0D" via Xbee) --> ... receiver Arduino (with relay) = WORKS! ![]()
Arduino sender (sends out serial commands directly: Serial.println"LIGHTON")
--> (serial command "LIGHTON" via Xbee) --> .. Arduino receiver (with relay) = does NOT work. ![]()
... also, adding the carriage return code to the command does not help:
Arduino sender (sends out serial commands directly) --> (serial command "LIGHTON%0D"" via Xbee) --> .. Arduino receiver (with relay) = does NOT work. ![]()
I found here on the Arduino website and in the forum several pages that show the use of "\r", as in Serial.println("... \r");, in order to send the carriage return (which actually should be sent by using "Serial.println" in the first place. However, also this does not work.
Arduino sender (sends out serial commands directly) --> (serial command "LIGHTON\r"" via Xbee) --> .. Arduino receiver (with relay) = does NOT work. ![]()
I also tried Serial.write(10) or Serial.write(13) for the carriage return or new line feed instead, both without success.
So, to cut a long story short: when I send the same serial command directly from an Arduino, instead from the iobridge, the receiver is not triggered. There must be something missing that I need to append in the Arduino code to the serial message, something like a carriage return or whatever, in order to get it to work.
Anyone any idea what my mistake is?