Re: Patch for New Arduino Leonardo Board support

195 views
Skip to first unread message

Ziyang Li

unread,
Apr 23, 2014, 5:13:21 AM4/23/14
to xbee...@googlegroups.com
Hi all,

Is this patch added or not? I have a Leonardo board and a Xbee S1 module. But I have no idea how to send message via API mode. I try the Tx example but it does not work. Anybody minds sharing a piece of code?

Best,

Ziyang

在 2012年8月26日星期日UTC+8下午2时37分52秒,Charles Walker写道:
Hello,

I ve bought a new Arduino board "Arduino Leonardo" : http://arduino.cc/en/Main/arduinoBoardLeonardo
This card is the same as Arduino UNO with a Real USB stack (I think it will become popular in a near future). Due to its USB support the serial has been change (default serial is USB) and to be able to use it with the Xbee library I had to change some things in the Xbee library.

Here is the patch :

Index: XBee.cpp
===================================================================
--- XBee.cpp        (revision 42)
+++ XBee.cpp        (working copy)
@@ -766,7 +766,12 @@
         _response.init();
         _response.setFrameData(_responseFrameData);
         // default
-        _serial = &Serial;
+#if defined(USBCON)
+   _serial = &Serial1;
+#else
+   _serial = &Serial;
+#endif
+
 }
 
 uint8_t XBee::getNextFrameId() {

It is still compatbile with Arduino Uno. It break nothing...only add the support of Arduino Leonardo. This patch was originaly propose on Arduino support forum here :

http://arduino.cc/forum/index.php/topic,111354.0.html

Can you please integrate it on the repository ?

Thx

Scott216

unread,
Jul 2, 2014, 1:29:23 PM7/2/14
to xbee...@googlegroups.com
I had my Xbees series 1 working well with a Leonardo and the older version of the xbee library.  I recently updated the libraries and now I can't get it to work. I'm guessing it's something with the new way serial is handled, I'm trying to figure it out. 

If you use this older version of the library (which does have the patch you mentioned): 
xbee.cpp: bit.ly/1pX7cbJ 
xbee.h: bit.ly/1z82j5A
And use xbee.begin(9600); not xbee.SetSerial(Serial);
It should work for you.
Message has been deleted

Scott216

unread,
Jul 2, 2014, 2:04:29 PM7/2/14
to xbee...@googlegroups.com
 think I figured it out.  Use the latest libraries (v.05) with the Series 1 Tx and Rx example programs.  For the sketches using a Leonardo, use Serial1 instead of Serial, like this:

Serial1.begin(9600);
xbee.setSerial(Serial1);
Reply all
Reply to author
Forward
0 new messages