austinbv / dino

Dino is a ruby gem that helps you bootstrap prototyping with an Arduino
MIT License
389 stars 84 forks source link

Where should additional TxRx classes go? #15

Closed vickash closed 11 years ago

vickash commented 11 years ago

tl;dr

I'm using ser2net to proxy an Arduino's serial connection to a Telnet service on one machine. I want to connect dino running on another machine to that Arduino, so I'm writing a new TxRx class to connect via Telnet. Reading from the Telnet connection was a bit tricky, but I've got it mostly figured out now.

Where should I put this class?

1) Currently I'm calling it Dino::TxRxTelnet. This seems clunky.

2) We could make TxRx into a module, so the current TxRx class becomes something like Dino::TxRx::Serial, and the one I'm writing becomes Dino::TxRx::Telnet.

3) Maybe the best place for this would be in a separate gem?

Thoughts? Also, any ideas on how to write tests for something like this?

Thanks!

What I'm Doing WIth This

I have a somewhat large home automation project in mind, so I need a way to put Arduinos everywhere that won't cost a lot. Ethernet won't always be an option, much less USB. ZigBee shields are pretty expensive, not to mention the security issues. WiFi feels like the right solution, but WiFi shields aren't much cheaper.

What I've settled on is connecting each Arduino to the USB port of a small WiFi router, with Linux installed and running in client mode, connected to my main AP. Then run ser2net to proxy the Arduino serial connection to the network via Telnet, optionally wrapping the whole thing in SSH.

I intend to write this up somewhere when done, but in the meantime, here are some tips for anyone interested in doing something similar:

Basic guide for installing dd-wrt and ser2net on a router: http://todbot.com/blog/2010/12/16/wifi-for-arduino-with-asus-wl-520gu/

The router I plan on using http://wiki.openwrt.org/toh/tp-link/tl-wr703n

It's a Chinese-market-only model, so the factory firmware comes in Chinese, but openwrt provides easy instructions for flashing. Once flashed, everything is in your language of choice. Also because of this, you'll have to search for grey market models on eBay or get them shipped in from China, but they're not too hard to find.

These are cheaper than WiFi shields, and tiny, about half the total volume of a Roku player. I can hide them almost anywhere. I haven't taken one apart yet, but on paper it looks like an Arduino Nano should completely fit inside. Mod the case to bring the pins to the outside, and it should be a pretty neat box.

Note:

DON'T use dd-wrt if using this particular router. There won't be enough space left over to install ser2net. Likewise, don't buy the ones on eBay which are pre-flashed with dd-wrt. Instead, buy the stock ones, and use the modified openwrt firmware from here: http://www.madox.net/blog/projects/tp-link-tl-wr703n/ This also saves you the trouble of installing ser2net, since it's part of the firmware by default.

Also, make sure not to get the WR702N instead of WR703N. The WR703N is blue, while the 702 is green. The 702 doesn't have enough flash memory to install dd-wrt or openwrt in the first place, so you'll be stuck with the factory firmware, which won't work for our purpose.