I am developing a project, which requires changing output to pins wirelessly via MATLAB. For this, the video I am attaching shows a perfect example. Essentially, what it has is an Arduino microcontroller connected to PC via USB Cable. This arduino has a Xbee mounted on it. And hence this pair of Arduino+Xbee acts as relay.
On remote site is an Arduino with Xbee mounted for data receiving from computer. My question is: Do I need to specifically configure my arduino or the Xbees so that the first arduino just acts as a relay? If yes, what kind of changes are required? Any kind of help would be appreciated.
Sorry for the regular users, since I am replying to myself; but I spent considerable time on the issue and just wanted to save time of other people who might encounter the same issue in future.
First of all, I was able to get it done without the use of 2nd Arduino. Just the use of two Xbees + one Xbee explorer + Arduino Mega 2560 (or Uno) did the job. Unlike when using Arudino IDE where reset is used to upload sketch onto the chip, that's not quite the case with MATLAB. When communicating with MATLAB, Arduino just communicates via serial protocol; so even when a new MATLAB code is uploaded on arduino, its not a new sketch (so no reset required), but just serial communication.
Doing following steps did the trick for me:
Obtain adiosrv.pde from Arduino support package from matlab website, and upload the sketch using IDE over a USB cable.
Disconnect the USB cable from either end as it isn't required for further wireless communication.
Mount Xbee on Xbee explorer and just ensure that baud-rate is 115200. This is the baud rate matlab is using for serial communication. (I haven't tried other rates, but this definitely works). Default baud rate for Xbee is 9600, but it can be changed by using XCTU. Plenty of tutorials available for this. Do this for both Xbees.
Mount one Xbee on the arduino. I did it using Wireless Shield and mounting Xbee on it, and keeping the switch setting to 'Micro', rather than 'USB'. While wireless shield is an option, it's not a must. Just connect the 'DIN' pin of Xbee to Pin 0 (RX) of arduino, 'DOUT' pin of Xbee to Pin 1 (TX) of arduino; and connect 5V from arduino to Vcc of Xbee, and connect ground of arduino with Xbee.
Supply external DC power to arduino, and connect the other Xbee to computer with use of Xbee explorer.
Just typing a = arduino('COM4'); should give the wireless connection required. I said COM4, but correct port can always be identified using Device Manager.
I apologize to regular members if I wasn't posting here the right way, but my main intention is to share what I learnt, even though if it might be obvious for some veterans as I came through many threads on these forums where I found the related subject topic but they were still unresolved.
HELLO, first thank you for your time sharing this.
i would like to know if the only way to send data to matlab with xbee is to use the adiosrv arduino code.
is it any way possible to use my own code on arduino and still sending data to matlab?