Pages: [1]   Go Down
Author Topic: XBee to XBee via Arduino Uno to Arduino Mega running Firmata  (Read 748 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I currently have Firmata in Arduino, connected to it is a coin vibra motor, which is powered by sending signals through a processing program through usb cable. This works ok in realtime using processing I can power on/off motor.

Now I've set up an xbee S2 module on xbee shield plugged in arduino board, the intent is to remove the vibra motor and plug it into the second arduino board, naturally having another xbee shield and xbee module s2.

Through processing I still send signal to first board like I could do but need to forward signal to second board wirelessly and thus having motor being turned on/off w'lessly.
I managed to power an led on board 2, via switch on board 1 wirelessly, so comms is ok, But important that I switch jumpers on both libellium shields to xBee position and not USB - this is just an example I tried for verifying communication.

Back to my project, I'm running into difficulties in forwarding signal, important to point out that due to processing sending signals to first arduino board, I must have the jumper on libellium shield of board 1 set to USB as I'm getting commands from PC. But on board 2 I put jumper to Xbee as that board is wirelessly dependent on xbee. Vibra motor works using firmata, as processing interacts directly with firmata to send on-off signals. I've tried everything, uploading firmata on both boards, anything...

Anyone seeing any odds?

Thanks sincerely!
Ian
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 650
Posts: 50833
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

On one Arduino, you have the XBee and the PC both connected to the same port. Having two devices connected to the same serial port is rarely a good idea.

There are several ways to deal with the problems you are having. Simplest would be to use just one Arduino, with the motor connected to it. On the PC end, use something like this: https://www.sparkfun.com/products/9819

Then, assuming that the XBees are configured correctly, the XBee pair simply replaces the wire that you were using before.

Personally, I'd take a hammer and pound those stupid shields you have into tiny pieces. Of all the XBee shields around, they are undoubtedly the worst. I know, I have two of them.

These are far better: https://www.sparkfun.com/products/10854

With them, you have a choice of using hardware serial or software serial to talk to the XBee. Of course, the problem is that the only choice of pins for the software serial instance is pins 2 and 3, which are not supported for SoftwareSerial on the Mega.

Of course, you could jumper from pins 2 and 3 to another pair of hardware serial pins. But, then, you'd need to change the code on both the Arduinos. Which would mean that you couldn't use Firmata. But, so what? No big loss. It isn't rocket science to develop and implement your own protocol for turning a pin off or on. Or for reading the state of a pin.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for taking time to reply mate. If I interpreted you well, I'd transmit signals from processing to the xbee directly using the xbee usb 'dongle', which in turn would forward data w'lessly to the other xbee onto the board which in turn powers the motor. Sounds cool to me. Prob is, I've a fairly complex program on processing which communicates directly with firmata on arduino that's why it's intended to have a wired board to the pc. According to your reply I'd have to re-write the code again ey? I didn't write the code myself, which really stands as an obstacle in such moment.

What about hardware serial pins and software serial pins? sorry for asking not that much experienced, but am willing to improve. I've read the wireless book by oreilly, helped a lot but not in my situation.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 650
Posts: 50833
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you use the dongle, or any of the similar wired variations, the Arduino with XBee shield would still have the XBee connected to the hardware serial port, but that would be the only thing connected to the hardware serial port, so Firmata would still read from the serial port (getting the data that the XBee put there) and would still write to the serial port (which the XBee would then broadcast).
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks man, so the with the dongle I'll be able to use the same processing prog, which would send serial data to the only serial device connected to pc being xbee dongle which in turn would be Tx to the xbee on the board with the vibra motor. Wow, that sounds like it could work.

One last thing, on the only arduino board I'll be using be it Uno or the Mega, I'll stil lhave to upload standard firmata as to operate the vibra motor accordingly. Would firmata read from the connected xbee or should I tweak firmata which is not suggested? - to have it read serially. I have sample code that I tested xbees indepednetly with, which on the Rx XBee it had code that checks a pin and in loop() it would output with an if condition. But firmata naturally doesn't cater for this. Sorry guys for disturbing
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 650
Posts: 50833
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Would firmata read from the connected xbee
The XBee puts data it receives over the air on the RX pin, and broadcasts anything that appears on the TX pin. Firmata won't know that the data came from/goes to an XBee instead of a wire connected to the same pins.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Straight and simple, understood. I know this might be far-fetching it a bit. I'll buy the usb dongle earliest possible. During such time, is there anything I can try/mend/tweak to achieve same or similar results with my current resources:

Arduino Uno R3
Arduino Mega 2560
x2 XBee Libellium Shields
x2 XBee s2 modules

firmata/ processing software..

my project does send varying frequency for achieving different vibration effects = "tactile technology". But I'd be happy if till now I'll just be able to turn on the motor wirelessly. Sincerely appreciated!


Thanks man, I see you've been enlightening quite a number of users here on the forum. I must praise you sincerely.
Logged

Pages: [1]   Go Up
Jump to: