Linkduino

Hi,

Another example, this time how to control a LCD from internet/lan:

Kind Regards,

Igor R.

Igor, this is awesome!

I made a similar setup using a Fonera (Fon2100) router running OpenWRT that talks serial to the Arduino. It works just fine connected directly.

I just wish there were some very small and cheap routers for all this that could be standardized on or sold as some bare-bones kits.

Hi nemik,

Thank-u!! I´m doing the same as you (not directly because is 3v3). At the moment, I´m triying only with DD-WRT, in stead of OpenWRT, because it has an easy configuration web page.
I also try to do the router programmation using bash scripting.

The idea is to have a "generic hardware" for the prototype phase of an electronic project (always trying the easy way to resolve things).

What have you done with arduino+Fon?

Kind Regards, :wink:

Igor R.

The Arduino (or ATMega168 chip) seems to accept 3.3v TTL serial signals just fine and the FON router I'm using reads Arduino's 5v signals just fine too. I haven't noticed any problems using both directly but it's probably better to have a proper converter like in your circuit.

I'm using OpenWRT and the ATMega168 with Arduino firmware to monitor and control a hydroponics setup for growing plants. My code is here: GitHub - nemik/arduinoponics: Arduino code to control a pump for hydroponics purposes.

I initially tried to use DD-WRT but found OpenWRT to be much easier to use and modify, plus very lightweight. Their LuCi web-admin pages are powered by a Lua-based MVC framework that I found very easy to extend. Plus Lua is very lightweight and I use it as a 'daemon' script to send and receive over serial from the Arduino. I have some pictures of it here too: hydroponics | Flickr

The software is pretty hackish and very specific to my needs though. Something more generic like Firmata would be more appropriate for a general prototyping solution.

Cool!! :wink:

It would be fantastic if you explain a how-to tutorial!! Maybe it´s a specific application, but it helps to other people....(always it's good learn how other people have resolved their projects).

Thank you.

There is still a long way to go in terms of documentation for the project; like drawing a schematic, BOM, etc.

I'm planning on creating another hydroponics setup using Deep Water Culture and an air pump for the roots, so I'll try to document that as I go along.

Yes, please!!

There are a lot of people working with linux based routers, but not info...

People, as me, who are not familiar with linux, is not easy to start with it. And all information around openwrt,x-wrt, luci,... are quite confused.

Kind Regards,

Igor R.

I'd seriously recommend starting with OpenWRT since their systems seem very organized and easier to modify than DD-WRT.

If you want examples from my code, just pretend the openwrt stuff is in /

So the etc directory and everything inside it would be like '/etc/' on the filesystem for OpenWRT.

My startup scripts that get run when the system boots up for setting up serial and the daemon for talking with the Arduino are in /etc/init.d/ for example.

Plus the aptitude-like opkg package management system on OpenWRT is very awesome. You get a minimally but perfectly functional system and then add on whatever else you might need, or strip some things away.

Hi,

I´d like to have a firmware with:

  1. Advanced bash commands (wget with post, curl, ....). Because with it I could use Pachube, change twitter status, mail,...
  2. Web interface to configure it (like Tomato,Gargoyle,Luci,...)
  3. I should be able to use the serial port
  4. Web server compatible with cgi scripts
  5. Send the firmware as dd-wrt, with a *.bin file or similar

Because using bash scripts is something "universal" and with documentation. It should be "easy to do".
Is it possible?

Thank-u for the information.

Kind Regards,

Igor R.

  1. I'm using a bash script with curl to send updates of temperature and light readings to Pachube, it is working nicely. Cron'd to go off every minute. Curl was installed via the OPKG package management system that comes with OpenWRT and they had curl (as well as many other common utils) in their repository.
  2. LuCi is pretty great and easy to modify. I found the Lua language to be very intuitive.
  3. That's working fine for me. I had to get a binary of the 'stty' program to configure the serial port to the correct baud rate for the Arduino. Once that was done and the default serial console in OpenWRT was disabled, everything worked great. I can even tail read serial /dev/ttys0 port and cat or echo data to it which the Arduino receives fine too.
  4. LuCi runs on top of CGI so that works as well. Not sure what language you prefer to do this with, but I think the OpenWRT's team's decision to go with Lua is excellent. It is a fast language with a very small run-time executable, very good performance and still has many libraries. It is also very easy to extend and write lower-level C code to interact with it, should you ever need such advanced functionality.
    Others like Python and Perl are wayyy too heavy-weight for use in a device with as little memory as a Fon2100 and even then they need certain things stripped out of the language for them to even fit on the router. I don't even want to think about something like Ruby on there.
  5. The changes you make to the OS and firmware can be packaged as a .bin, that's fine. OpenWRT has a great toolchain to enable such custom builds. I plan on trying that out sometime but from some reading it doesn't seem to be too bad at all.
    Even better (IMO) is starting with a default OpenWRT package and then packaging your code as an OPKG package that can be added to some repository. That way it could be updated easily later without having to re-install the entire firmware when you want to add updates and new features. The opkg package management system can take care of such things very easily for you.

Also, plain old bash scripting is pretty universal, but IMO a pain to program in. I'm not a big fan of bash. I'd much rather use a higher-level language and Lua on an embedded device fits that requirement perfectly being very lightweight and still having excellent performance.

Hi nemik,

Thanks for encouraging me....I´m tinkering with it.

My first step has been install Gargoyle package (kamikaze 8.09.1 + graphical enviorment). It´s working good and it was easy with the *.bin archive (as dd-wrt).
What do you think about it? It´s very easy to use....http://www.gargoyle-router.com

I´m not idea about linux...Maybe some of my doubt are very basic, but I´m a rookie.... :smiley:

I´ve achieve install curl.... ooooeee!!!!. I´m not sure how, but now it´s working ;D.
I had a problem, because when I tried opkg install curl, the answer was :
Only have 760 available blocks on filesystem /, pkg libopenssl needs 1270

I´ve search about it, and I´ve added to /etc/opkg.conf:
option force_space
Bad idea??? :o

How I know my free space to install packages?

After the change, I´ve tested again and.....
Now:


curl -u real2electronic:mypassword -d status="Thank-u nemik! Sended from:LINKDUINO" http://twitter.com/statuses/update.xml


And.... it works!!!! he,he,he (You can see => http://twitter.com/real2electronic) :wink:

Best Regards,

Igor R.

Igor, nice! Glad you like it.

I have never heard of Gargoyle, it seems like a pretty cool interface and intuitive for end users, but not sure it's as easy to use as LuCi to extend it as a developer. Seems like it uses some native C/C++ utilities to generate HTML files from the config files in /etc/ whereas LuCi is more of a web MVC framework based on Lua (with Models, Views and Controllers). The MVC architecture for me is fairly intuitive and nice to work with, though I'm sure the performance isn't as good as with Gargoyle.

Which device are you trying to install on? A WRT54G router? curl does require libopenssl to make SSL connections, but not sure why your space is so low? Your router should even have more memory than the tiny Fonera I'm using and i got both on there just fine...

To see how much space you have, you can run the df command and it'll show the total, used and available space on each partition. You can also run it as df -h to show the sized in human-readable format (KB, MB, GB, etc versus just number of bytes).

One warning though, the filesystem is based on jffs2 which I found to be pretty fragile sometimes. Doing an opkg install once screwed up everything for me, to the point where the filesystem wouldn't mount, so it reverted to a read-only one that gets reset every time you reset the router. I made a blog post here on how I eventually recovered my data (didn't save my code at that point, lesson learned). The post is here: http://blog.nemik.net/2009/11/fixing-broken-jffs2-partition/
So I would really not recommend forcing the install of the package if it doesn't fit, you might have to start over if the JFFS2 partition decides to choke; I'm not sure how it handles becoming completely full.

It is better to perhaps see why you have so little space and see if you can remove some packages you might not need. OpenWRT on its own is pretty lightweight, perhaps Gargoyle takes up a lot of space? I'm not sure. Either way, it is surprising that it actually worked! I would just not recommend doing that in the future.

I think you have 8Mb of flash and my router only 4Mb (WRT54GL).

root@OpenWrt:/jffs/usr/bin# df -h
Filesystem Size Used Available Use% Mounted on
rootfs 2.1M 2.1M 0 100% /
/dev/root 2.1M 2.1M 0 100% /rom
tmpfs 7.0M 60.0k 6.9M 1% /tmp
/dev/mtdblock/4 1.2M 1.1M 92.0k 92% /jffs
mini_fo:/jffs 2.1M 2.1M 0 100% /

I´ve to read and search in internet all the info you post here... :wink:
I´ll keep you updated.

Thank-u!!

Igor R.

Hi again,

I´ve just received the SD Sniffer board from Sparkfun and I´ve working the SD hack for the router.

I´ve achieve work with DD-WRT and an old 1 Gb SD card.
There is a Tomato firmware which has a driver for moderm SDHC (I´ve tested 4 Gb), but I don´t know yet if I can use Optware with this firmware.
http://gemini.net.pl/~slodki/tomato-sdhc.html

May I install with opkg a package for using sd/mmc HC with Kamikaze?
Because the problem of DD-WRT is that only work old SD...

Now:

root@ARDUINO:/jffs/opt/bin# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 2.8M 2.8M 0 100% /
/dev/mmc/disc0/part1 960.7M 5.9M 906.0M 1% /mmc
/dev/mmc/disc0/part1 960.7M 5.9M 906.0M 1% /jffs
/dev/mmc/disc0/part1 960.7M 5.9M 906.0M 1% /opt

Thank-u!!

Best Regards,

Igor

I´ve found Harsel as optware package.

Haserl is a small program that uses shell or Lua script to create dynamic content with CGI scripts. It is intended for environments where PHP or ruby are too big. On nslu2, because of the limited RAM resource, CGI can sometimes outperform other solutions. The webif project for openwrt firmware uses haserl to build web interfaces for routers.

Nemik,Is it what you recommend me? :smiley:

http://www.nslu2-linux.org/wiki/Optware/Packages

The card thing looks cool. Not sure if you can install packages on it since the package contents from opkg tend to go to a specific place on the OS. A better thing might be to see if you can somehow make the root filesystem be the SD card's one. JFFS2 is already the rootfs partition on OpenWRT and it is a filesystem which has been known to work very well on cards. Then some kind of parameter would have to be passed to the bootloader to tell it to boot the kernel and such off the card rather than the smaller flash memory. I'm not sure how easy all this is to do...but might be worth looking into. Since then you could essentially replace the small flash memory on the router with a large one from a large card.

As for Haserl, I have not heard of it, but it sounds pretty good. I don't know what LuCi web interface on OpenWRT uses, but this sounds like a great solution for you since it sounds like you just want something minimal to run CGI scripts off of. Let me know how it works out, good luck!

You have to install ipkg-opt and redirect some folders with mount --bind :
mount --bind /mmc/jffs /jffs
mount -o bind /jffs/opt /opt

Now /jffs and /opt point to MMC folders.

I´ve installed:

  • setserial
  • php-httpd (port 8080)
  • curl

I continue with routers`s configuration web server in port 80.

You can look the optware packages (1241 :wink: ):
http://www.dd-wrt.com/wiki/index.php/Quick_list_of_Optware_packages

It´s an easy and perfect solution!!!
Although I have to learn how-to with openwrt...step-by-step ;D

Thank-u!

I´ll keep you updated

Best Regards

Igor

Oh wow. Very nice. If you can do all this with DD-WRT maybe there is no need to go with OpenWRT then. I just liked OpenWRT for its minimalism and package management system. Though DD-WRT with optware looks very nice. I'll have to check it out. Thanks!

The Arduino (or ATMega168 chip) seems to accept 3.3v TTL serial signals just fine and the FON router I'm using reads Arduino's 5v signals just fine too. I haven't noticed any problems using both directly but it's probably better to have a proper converter like in your circuit.

Not to threadjack, but I am considering connecting my Arduino to my WRT54GL which has on board connections for 3.3v TTL from what I understand.

Excuse my ignorance, but do I need to go through the trouble of getting a max232 or max3232?

Thanks!

displacedtexan, I'm currently using it on a FON2100 router (which also does 3.3v TTL) without any sort of converter, just straight from the ATMega168's Tx/Rx pins to the router's. It's working just fine.

Supposedly the ATMega168 reads 3.3V TTL just fine (and my setup supports that) but outputs at 5V levels which can supposedly fry some 3.3-only devices. My router doesn't seem to care. Though if you're concerned, you could just put a resistor in series between the Arduino's Tx pin and the router's Rx just in case.