Fonera relay control

In my previous post I’ve described how to access the serial port of a Fonera 2100 by using a Raspberry Pi with minicom. Being able to access the serial port makes it very easy to flash DD-WRT on the Fonera because according to these instructions we can skip to Step 6.

Following these instructions I’ve flashed my Fonera with DD-WRT v24 (05/20/08) std – build 9517M.

Then, I have put my DD-WRT-Fonera in Client Bridge mode following these instructions. I’ve also enabled SSH, so I can login over the network.

The interesting part is that the fonera has some free GPIO pins, that can be controlled by software. For example:

set GPIO3 to output : echo 1 > /proc/gpio/3_dir
GPIO3 = on (3.3V)   : echo 1 > /proc/gpio/3_out
GPIO3 = off         : echo 0 > /proc/gpio/3_out  

set GPIO4 to output : echo 1 > /proc/gpio/4_dir
GPIO3 = on (3.3V)   : echo 1 > /proc/gpio/4_out
GPIO3 = off         : echo 0 > /proc/gpio/4_out  

set GPIO1 to output : echo 1 > /proc/gpio/1_dir
GPIO3 = on (3.3V)   : echo 1 > /proc/gpio/1_out
GPIO3 = off         : echo 0 > /proc/gpio/1_out  

set GPIO7 to output : echo 1 > /proc/gpio/7_dir
GPIO3 = on (3.3V)   : echo 1 > /proc/gpio/7_out
GPIO3 = off         : echo 0 > /proc/gpio/7_out

To finish this story, I’ve ordered a 4-Channel Relay board at dx.com and connected it to the Fonera.

Although the voltage output of the Fonera GPIO’s is 3.3V this works very well.

8 comments for “Fonera relay control

  1. Aldo
    December 16, 2012 at 2:21 am

    Dear Jan,
    Thank you for sharing this on your blog. I got the same board you suggested, and it perfectly works!
    Unfortunately i was not able to create some sort of web interface to drive gpio.. in the /jffs folder you can place your html files but cgi-bin it is disabled there fore it won’t work. Did you create a web interface to control gpio?
    Thank you,
    Aldo

    • December 16, 2012 at 5:13 pm

      I’ve not created a web interface to control the GPIO’s of the fonera. Instead, I control the GPIO’s from the command line or script using expect.

      A webinterface on the Fonera to control and/or view the status of the GPIO’s would of course be very interesting. So, if anyone has created something like that, I hope they will shared it with us.

  2. Aldo
    December 26, 2012 at 8:49 pm

    Hi Jan,
    I found this: https://code.google.com/p/firmware-mod-kit/wiki/Documentation?tm=6
    It is possible to extract the original interface and hopefully rebuild the firmware image.
    I have unpacked it, and I’m trying to see if I can add in Info.htm (http://svn.dd-wrt.com/browser/src/router/kromo/common/Info.htm) the status of gpio. Most of the infos are retrived using nvram_get function but in nvram no info on gpio.
    On the other hand I added some custom pages using this tutorial http://www.dd-wrt.com/wiki/index.php/MyPage. I edited mypageX.sh in order to enable or disable gpio, and when opening MyPage.asp?X I turn on and off the gpio (i also added a redirect to another page where I read the status). But this is not an efficient way..
    Maybe you have some more ideas..
    Have a nice day!

  3. Crypto
    January 9, 2013 at 3:12 am

    I did this a few years back. http://www.dd-wrt.com/wiki/index.php/LaFonera_Hardware_Controlling_AC-Loads_via_webinterface
    You can modify the script to control multiple gpio pins

    • Aldo
      January 9, 2013 at 11:58 pm

      Hi,
      Yes, thanks, I saw the post you mention.
      Unfortunately it is no more possible to use the cgi script described.
      From DD-WRT V24 pre SP2 cgi support has been disabled as a fix for an exploit (http://www.dd-wrt.com/wiki/index.php/Web_server). An alternative could be to install an additional webserver, but don’t know if the space on the fonera jffs is enought.
      The alternative for now write a small scritp to connect via ssh to the fonera (using a certificate) and run command from remote, it works well (with a delay of a few seconds).

  4. Shorosky
    January 8, 2015 at 12:01 pm

    Hello:
    Im searching for a router that let me control GPIOs by wifi.
    I can see that it is possible with La Fonera router but I have a question.
    Is it possible to control GPIO while it is working like a normal router? for example, while Im navigating with my mobile, I send a command to switch on/off a GPIO.
    Thank you

    • January 9, 2015 at 2:59 pm

      I think it’s possible, but I don’t know for sure because I’ve never tried it.

Leave a Reply

Your email address will not be published. Required fields are marked *