Search code examples
matlabarchitecturearduinoxbee

Project architecture of Arduino gets instructions from MATLAB using XBee


I need to transmit instructions from MATLAB to my Arduino wirelessly. I use an XBee shield on Arduino Leonardo, and my computer is connected via USB to another XBee (directly).

I can't determine on the right way to implement this kind of communication. I guess I need C code for the Arduino and another one running on my computer getting instructions from MATLAB? Or perhaps MATLABcan communicate directly with the Arduino?

Is it a matter of server and clients, and is there any protocol relevant to me?


Solution

  • You haven't given any idea about the XBee module that you are interfacing the PC.

    But if your XBee module is similar to https://www.sparkfun.com/products/8687 here is something that might help.

    MATLAB has a Serial library that can communicate with devices that are configured as serial communication devices with a COM port and a baudrate for communication.

    What you can do is simply create an object for serial communication with corresponding COM port and desired baudrate.

    Then simply send hex values that represents your instructions. You just have to write a code in Arduino to receive those instructions and perform the appropriate action.

    MATLAB serial - code example will help you understand more about MATLAB serial communication.