Tuesday, April 28, 2015

Wireless Arduino-To-Arduino Communication

For my project, one of the arduinos needed to freely rotate, so I couldn't just run a wire from one to the other. So, I started looking at different wireless modules and found this post on stackexchange really helpful in explaining the differences between all of them. In my case, I could have gone with the XBee, the Nordic nRF24L01, or a barebones radio transmitter and a receiver. The latter might have been too unreliable due to interference, and the XBee was a bit expensive (also I had heard they were hard to configure.) So, I ended up going with this nRF24L01 breakout from Sparkfun, and I'm really glad I did. (You can even get them way cheaper on amazon if you're fine with an on-chip antenna).

The first step is connecting to your arduino. To figure out which pins to use, read the Connections section here. I used the muli-purpose IO pins (11, 12, & 13) for one arduino and the ICSP pins for the other; either works fine. Also, the library I used defaults to pins 7 and 8 for CSN and CE, respectively, but you can change these to whatever you want. I used 8 and 9.

Speaking of libraries, here it is. I like this one better than some of the alternatives because it seems like the interface is as simple as possible, while still using the nordic's auto-retransmit and auto-acknowledge features to ensure your packet always gets where it needs to go. The first link in the github readme gives some example code, which is more or less exactly what I used. To see specifically what I did, check out my code on github here.

No comments :

Post a Comment

Note: Only a member of this blog may post a comment.