XBee API Mode

Support forum for MegunoLink
Post Reply
JohnE
Posts: 5
Joined: Wed Feb 06, 2019 9:22 am

Wed Feb 06, 2019 9:55 am

Hi Everyone just found MegunoLink an I am in the process of evaluating it. So far very favorable but I have hit a major snag.
I need to use xbee's in API mode. So far I have spent 2 days with little progress.

I initially set my Teensy 3.2, communications and interface panels up to use serial and that works great. Progressed up to using Xbee's in Transparent mode, again works great.
I have reconfigured the XBee's to API, and there it falls apart.
Set the Xbee's to API mode 2
Used connection manager to connect to the local Xbee with the address of the remote XBee
I can send commands via XBee from the interface to the Teensy.
I can not work out how to send commands from the Teensy to the Interface.

I can send data to the Message Monitor if I use the wifi library, but don't know the protocol for sending to the interface.
So XBees are set up and talking but cant get the data through.

My question really is how do I tell Arduino (Teensy) to use XBee protocol and destination address 0 (Coordinator).
I would be grateful if any one is using this configuration, could supply me with an arduino sketch for Megunolink and arduino with an XBee in API mode.
I can't find documentation anywhere to solve this.

Regards
JohnE
philr
Posts: 446
Joined: Mon May 26, 2014 10:58 am

Thu Feb 07, 2019 6:25 am

Hi John, have you tried this sketch?
https://www.megunolink.com/documentatio ... ies-2-pro/

Cheers
Phil
JohnE
Posts: 5
Joined: Wed Feb 06, 2019 9:22 am

Thu Feb 07, 2019 8:20 pm

Thanks for your reply Phil.
I have run the sketch you suggested and can see plot data in the monitor in Megunolink. So I know the link is working.
Lines 46 and 47:-

TimePlot Plot("", Payload);
Plot.SendData(NodeName, dY);

Constructs the packet to send Plot data to Megunolink.
I can't work out the syntax of a packet to update a control on a panel, any suggestions

Regards
John
philr
Posts: 446
Joined: Mon May 26, 2014 10:58 am

Fri Feb 08, 2019 5:25 am

Should be the same

InterfacePanel MyPanel("", Payload);
MyPanel.SetText("ControlName", "my text");

You should be able to use any of the functions like SetText.

You would need to reset the pstring each time. I think it's mypstring.clear()...

Cheers
Phil
JohnE
Posts: 5
Joined: Wed Feb 06, 2019 9:22 am

Sun Feb 10, 2019 8:12 am

Hi Phil

Once again thanks for your help. I now have communications, both ways, between Megunolink and my Teensy. It works very well.
However moving on just encounters more problems.

On my Xbee network I have 3 routers (remote Xbees). I have setup a connection to the first. Using the connection Manager how do I make connections to the other remote xBees.
Regards
John
philr
Posts: 446
Joined: Mon May 26, 2014 10:58 am

Sun Feb 17, 2019 3:05 am

Hi John, the xbee connection needs to know a destination to transmit a message too. In order for our connection manager to know where to send you need to do a node discovery ("Node Disc" button) to discover all of your nodes. Then select the node you want in the "Destination Address" drop down which will be populated by the discovered nodes. Once you select a particular node you will be able to talk to that unit. Unfortunately you can't talk to all at once.

https://www.megunolink.com/documentatio ... ies-2-pro/

This page talks more about discovery and selecting the device you want to talk to.

Cheers
Phil
JohnE
Posts: 5
Joined: Wed Feb 06, 2019 9:22 am

Sun Feb 17, 2019 11:19 am

Hi Phil

Thanks for your reply.
I have read the article you suggested.
Am I right in assuming that Megunolink can listen to multiple nodes but can only speak to one at a time.
Would a solution be to create several connections in connection manager. one to each remote node. Then just enable the connection for the required node when I need to send data to it.

Regards
John
philr
Posts: 446
Joined: Mon May 26, 2014 10:58 am

Sun Feb 17, 2019 5:34 pm

Yeah pretty much. Usually the remote nodes need a destination too. Are you using a library? Does it specify a destination? Probably broadcast or maybe a special one for the coordinator.

Cheers
Phil
JohnE
Posts: 5
Joined: Wed Feb 06, 2019 9:22 am

Mon Feb 18, 2019 8:57 pm

philr wrote: Sun Feb 17, 2019 5:34 pm Yeah pretty much. Usually the remote nodes need a destination too. Are you using a library? Does it specify a destination? Probably broadcast or maybe a special one for the coordinator.
I am using the <XBee.h> library. The destination address for the coordinator is always 0,0 so that is the destination address used by all remote nodes.
The work around for talking to each remote node does work okay. A bit of a pain swapping connections, but it is workable
Regards
John
philr
Posts: 446
Joined: Mon May 26, 2014 10:58 am

Wed Feb 20, 2019 4:12 am

Sweet, nice work
Post Reply