Frage

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?

War es hilfreich?

Lösung

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.

Andere Tipps

You can run XBee modules in a "transparent serial" mode which is like a wireless serial cable. Take a look at the Basic Chat examples on Digi's XBee Examples website for step-by-step instructions on how to configure the radio modules.

When building a system like this, it can help to have a wired solution in addition to wireless, so you can do a level of testing and debugging to confirm that your code is working with a direct connection, isolating possible problems to the radio link.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top