Sending API packets to an XBee.
Does anyone know how i would go about making a patch for getting API packet communication using an Xbee explorer with an xbee with coordinator api firmware loaded, to read data from 2 xbee end devices set up with AT commands.
Any information would be greatly appreciated, i am pretty stuck on this one
If you don’t find any other solutions (but I hope you do as I would also like to delve into these things :D ), you can use Processing where, I am guessing, there are libraries and then use maxlink (http://jklabs.net/maxlink/) to communicate between Processing and max. It’s a long roundabout but it is better than nothing!
For the moment I really don’t know anything about the XBees but did you also try the [serial] object?
At one point I spent some time working with XBee radios. You will want to get cozy with the serial object and parsing the data. Below is a simple patch I wrote to send AT messages to the Xbee board for configuration.
I don’t think I ever got so far as actually parsing the API messages coming from the board though. Would be nice to put my little box of Xbees to use eventually!
----------begin_max5_patcher---------- 1619.3ocyat0aaaCE.9YmeED9034wq5xvdIaFEK.asCCEXXXaXP1lwQa1Rdx zKosn+2mDIkibZji3w1x7gJEopKmymNWIo+zUCFNM+Q4lgnuA86nAC9zUCFn OU0IFXOdvvUIONaYxF8kMbV9pUxL0vQl+Ok7Qk97qxmKqOY11U4aUKkJ8sfs mcchZ18oYK9qB4Lk4Ux4wiwiPTLqZGSTskDMFi9S68bWdlZS5GkUWNAOt9Qk NW+Nym92eUDaXiqMKYk9ZGdSQZxxFxSZVs3PpN2mu5ppMiNRkdcZl65LF2Pm oAPzY5ETm2HUnI29NTotilJuO4+RyKbGBAlO7bpV8EX.THLtGnvzsJUdKejI sqeLiFQqTopu00a2odM0iv5Gu4Yq9vZo4oLbZR1hg6tmiVY1V9Ac6tOnkuFq mey2PC8icHG2PsJYzLVHjOehVU6zJyNzP8+16I9xejSUxUVMoTLFNp79H18T 6dlcO2tWb5fZ4CXprEO.5ArPhiaPPXN.7Wif6a+bFcSxjOTJQeQrhxXHSSyj nad+DDFgcGRV2HNQiGBH6LZqTpqFX6gG1oCOJzrkxjB2itXSgnoBKBBTHsBE iH0GFM.isRh0ZbGhrFD0WQVaKYo7wTEZcQ9hhjUkuhENmnjEqyPRiLl9DHwI BBtfkK7PQY3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vJrk.kbn0 3xgReYWtilU4J7hfd0kW+4tffllY56sra3rm+qMRCfpyuOm2jusXVs.W2JI5 IQnwBoq4EI16htOc9bYVyhNWkNecdo9u6G9vK9UuyxDtKxDoWkIdGDovdWhn mVIpJ7pnZVF0kJaVhz6efwIJJVeYQZi2iRIB6.Vi5UrV0e3qJR790ePzAQJt eEot7gqZTd6yubcQj5UIh4cRTWh1+LOfysHE6ePx+rjnb+KMc0zB6axDC6gb J1+jINyCkIgGJSdnMN2GiED5gbx+xrHn9GlDdnamvCc6DdnItHx6Lw6hDQ6W QJnSTB2u0X1kJwCcjSTbndsIEZF+Ob7tiN11zImABZkOyOmHZbvS+1hpOvNH cZkhcBzBOL5aXmFXoJAmzexjnqxDs+jovtJS8XzWuK3aWRadL12kG74q9ef+ 6EbI -----------end_max5_patcher-----------
Thats a quality patch
thanks for that.
I’ve managed to see incoming data now through X-CTU,
but i can’t seem to find how to access it through max/msp
Thank you all for posting so quick and sorry for my late reply
i can now see the incoming data through [print] in the max window,
i just don’t know how to interpret the data stream.
its all a bit greek to me
Did you figured out this?
i am trying to use xbees without any micro controller (arduino,funnel) with max. i found tutorial and AT commands to get 2 xbees talking together but i didn’t figured out how to get xbee value into max with the serial object or how to send value to control the digital out .
if you successed on this, please give some step or examples to follow.
I used 2 XBees S1 and I know that once you pair them it is pretty easy from then on. If you have more than 2 or if you have XBee S2 it might be a bit more difficult to get them rolling. (Did you test them with the Arduino IDE Serial Monitor and they work?) One will send serial data and the other one will grab it.
----------begin_max5_patcher---------- 1582.3ocyZ0siahCE95jmBDWmNx1.AXua2q12gQUib.mLtkfyBNSm1p9tu9G f.DLgP.TpTy.1f84667iO9X985U16XeRxss9KqWsVs52qWsR0jrgUE2ux9H9 ynDbt5wr2clyYo1azckd9HMMgvU8AuzH6Lucq5l3+7DQOc16voGrs9ZQ2zX0 vy18su34VN7mv7n2ooGdKiDw0ulm+KfMVHni5Ofxes9p7M9y50xe1LPrjR9g X9JmLN4S0bXys.SA9no7N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YmAKyCTjORiOwD9fElAdphF.CUdTPgIWPQtsplZNuOOfE8znebGp afySjLKMuQCw00ebFUPf5DKfHUF+ElXH3haO0QnmGDn2RluDpMVUuPRZzOeK BG8dgXoKXUUsPrywePheSHBhn9ug47L5tybcH55Epo+5UzwFsGPML5oqaW9D C64+582eHgsCmTT+opoqgPbEf5LiFMIOMk5StiEfEryZ74beEA23dTZryO2w UIbc09bTE6qb+eS64pbjjmiOPthghRX4jN4GzTTmaXm7w+RR9fvoQ3ayIPgc gjTzKascZIEN6vgDxbddv8crnEGfl53OPNC63OlPMu7.NrNmuSWL7YyD.MdS .WesEfZYkhCFXhs.LD23+DDeFq1twuGdIhknqR9qVfW7cCAnMcbQsEIuiyNA MtSSPuOJe0AUG.miyMxX.XojYgsB2B.i3nVl.tr7zK6L9TOwqs9GVRbetuZC ROUPaHTW7CeSrZPCVU8LM2jlljam3SAUeUBOMRiwThntMdnqxy4pj4DaDPBE 8YN4d4lKyS6jhtxHYnxu7.Pmb.ffgKG.bG..7tE.VX4QdVjKk7.eDELzfEpq aoNETWAClAELJbFrP2pVrGB7qYfJuYNje3LH+daWL9GND9W9cLsPFzng3f0x p+ZC5IVdf2heVPG9fAHOsB6OmxyPTWnkid7BmB4ok6XfZ8NcPkK+NCNiAChM WtU6BFTv4f6b0khT4.53Z5O5ll24ntAoaSdyM4Zclds9Najvp02WSqusl1eW MhQ6Oq+e.SX.5WA -----------end_max5_patcher-----------
1. Select proper port (ex: a)
2. Type the right baud (ex:9600)
All the best,
thanks for your reply !
til now the only situation i have been using xbee was with funnel or minibee.
configuring the xbee wasn’t really hard for this purpose ( baudrate, pan id and if you want it as coordinator or end device)
but now that i try to use the xbee as an end device without funnel or micro controller, everything get confusing.
i have been messing around with x-ctu on windows trying to follow this : http://fusion-artist.com/XBee/XBeeTutorial.htm
but when i come back to osx and tried to get the data inside max with the patched linked on the tutorial nothing is showing up.
i tried to look with with arduino IDE serial as well but nothing….
It would be nice of you, if you could describe me the exact configuration you had on both xbees and all the important steps you did to get it working :)
my goal at first would be to set a digital input on the xbee end device and receiving the information inside max.
i am on a macbook pro 10.7.4, i think the 2 xbees i use are from serie 1, the coordinator is plug on an usb xbee explorer, the end device is on usb explorer as well ( usb not plugged) and i do all my wiring on the pins of the explorer ( gnd, 3,3v, Di2)
I really depends what you are really trying to achieve. You said, for example that you changed your OS. Did you install the FTDI chip driver for that usb xbee explorer?
I would recommend trying to get it working within the Arduino IDE before working inside Max.
yeah sure, what count for now is having something showing up on the serial monitor.
drivers might be ok on the both side windows/osx as i already used it with xbee plugged on funnel on osx ( i can choose the explorer in the serial port of the arduino ide) and as x-ctu was working on windows. i do think the problem really comes on the confinguration of the xbees.
(but we agree that arduino IDE would be only to use the serial monitor right?)
If you think you have problems with the configs that is what you should solve first. I would recommend using some microcontrollers and the SoftwareSerial.
AH! but that’s exactly my problem. its working perfect with microcontrollers. The problem only come when i try to use the xbee without micro controller.
i got it !
found a soft called moltosenso for osx, and it now works….
I did a whole project with api mode xbees and ended up building an mxj object that did all the stuff. I’ve been meaning to give this away… Let me dig around the hard drive..
Here it is, you need to copy some files to your support directory to make RXTX work in mxj, it only works with named XBees so you need to give them names in XCTU or whatever you’re using to set them up. Works pretty reliably for me even at high baud rates but YMMV.
so if i understand by saying" ADC_IO support can easily be added by fiddling the source code" you mean that as it is now, its done to be used with a microcontroller right?
It works fine with arduino’s on the other end, I’ve done a whole project with them
There I’m sending packets that control the LEDs and stuff and receiving packets that describe the knob twiddling. Works fine with up to ten and at baud rates of up to 57,600. Any faster and the arduinos can’t handle the serial buffer correctly, would probably need a really tight main loop to hit 115,200 reliably.
The ADC_IO thing is for people who sample directly on to the XBee and don’t use microcontrollers, there’s an XBee firmware that allows you to just wire up sensors direct and send the data back at a sample rate you set with some message. I never bothered implementing it cos I never needed it but I figured some people might want it so I thought I’d tell them where to look. It’s just a matter of handling those packets back from Andrew’s api in the source code I wrote, not a big task.
Hope it helps you.
Ok, in the meantime this is exactly what i try to achieve, using xbee without microcontrollers.
i tried this http://fusion-artist.com/XBee/XBeeTutorial.htm but no luck all the value i got from the serial are totally random.
"there’s an XBee firmware that allows you to just…." do you remember what firmware it is?
on the other hand, if i still understand you correctly, i could use for example two funnel FIO in same time by naming my xbee and using your mxj object?
and yes you help a lot! there is not so much going on about xbee and max/msp sadly…
Yeah I remember that page, you want it without microcontrollers? So you read the analogue data to a pin and send it back? Like this guy
The firmware will be in the list for your model in XCTU it’ll probably have a name with IO or ADC in it, then you just wire the sensor to the right pin, make sure it’s voltage is in the correct range for the XBee (you might need to wire something to vref) and it should start sending data back which you can pretty easily adapt my code to receive… Look for the part where mine handles incoming packets, it checks for type and does something for node discovery responses and something else for actual data, you need to add a response for ADC_IO packets and then send the data out of an outlet in the same way it does already.
Keep going you’re nearly there.
OLALALA! finally got it working with processing atleast using that lib
(its actually the ame guy that you mentionned in your example just before)
, now i need to figure out what to do with the packet inside max/msp.
Note that there is no special firmware to do this , the version just need to be atleast version 10A1.
So now i basically need a serial object guru , that will help me to unpack all this mess, byte blabalbalbalbla
If you’re sending API data you’re better off adapting my external IMHO, doing it through the serial object is likely to be a pain, though if you’re only using one XBee it might not be so hard if all the packets are the same length, there’ll be a load of header data which you can discard and then the data you want probably split between two bytes (I think it sends 10 bit data from the ADC) just left shift the MSB and add it to the LSB et voila. Download the XBee API pdf off here and look for the ADC_IO packet description it’ll tell you which bytes to go for.
But tbh if you’re only using one remote XBee to do ADC sampling and not sending anything back I’d just stick to serial mode and ditch API mode, there’s more overhead with API packets compared to serial. API mode is more useful for mesh networking where things can drop in and out and other funky stuff.
i am just in the first step, experimenting and trying but the final goal is to use 2 or 3 xbees without microcontroller that will talk to max. I will use some one xbee for input but the others will be pwm output, so it sounds like your external will be helpfull at some point!
But for some reason its not working on my machine. the mxj is greyed out. i puted the files as you described in the txt file. i am remember i already had this kind of problem with mxj but don’t remember how i fixed it.
i am on mac 10.7.4 using max 6.
Restart max? If Max was already running when you copied them then it won’t know the new jars have been added.
Awww i am more Keen than that to try new external, i already rebooted the computer 6 times :)
What does the max window say? It should list the jars it has access to and any trouble it’s having loading mxjs.
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.security.AccessController.doPrivileged(Native Method)
… 1 more
(mxj) unable to alloc instance of XBee4Max
better but still not working.
this sounds like its coming from the src files i had to drop in my library. i puted it in the main library maybe i have to build a java folder in the users/library ????
restart count : 8
This looks like it’s having difficulty opening the serial port I remember this was a complete bitch when I first ported the library to a different machine, have you defo copied contents of the support folder to support?
You might have to copy them somewhere else too…. brb
Try copying the stuff from support into /Library/Java/Extensions see if that works…
it is already there, as you said in the txt file. but this is the only sot i puted these files.
"have you defo copied contents of the support folder to support?"
what do you mean?
ahahahaha. maybe we should link that topic to your blog then :)
i don’t have red error anymore. but i got a tiny error
XBee4Max: Cannot open port
i changed my /dev/tty.usb… and baudrate tho.
maybe reboot 9
i gotta run so i try later and let you know!
thanks for your great help i appreciate.
Will probably work now when you give it the right /dev/tty.usb——- just copy it out of Arduino. Will update blog, cheers for being a guinea pig! Let us know how you get on.
Yes seen that one, when i was doing the research.
but thank you for point it again!
have a good day
The XBee4Max external looks great! Can it send a simple on/off message to a mesh network of Xbees or does there need to be an Arduino on each node? I’m not receiving data into Max, just sending it out.