martes, 12 de mayo de 2015

WebIOPi - Haciendo que la Raspberry Pi tenga una página web

Parte 1

Inicialmente instalamos WebIOPi siguiendo integralmente el siguiente tutorial: 

Installation

WebIOPi is developed and tested on Raspbian. You only need Python, either 2.7 or 3.2. Download, then extract and install WebIOPi. The setup script will automatically download and install required dependencies using apt-get. You may have to manually install GCC and Python development headers if you are not using Raspbian.
Update note: Stop your existing WebIOPi service, then process with the setup. Your configuration will be kept but others files will be override.
See downloads page to get latest package, and adapt x.y.z with the version you download.
$ tar xvzf WebIOPi-x.y.z.tar.gz
$ cd WebIOPi-x.y.z
$ sudo ./setup.sh
Setup may take a moment.

Running WebIOPi

Finally, use webiopi command :
$ sudo webiopi [-h] [-c config] [-l log] [-s script] [-d] [port]

    Options:
      -h, --help           Display this help
      -c, --config  file   Load config from file
      -l, --log     file   Log to file
      -s, --script  file   Load script from file
      -d, --debug          Enable DEBUG

    Arguments:
      port                 Port to bind the HTTP Server
For instance, to start with verbose output and the default config file :
$ sudo webiopi -d -c /etc/webiopi/config
You're done, and ready to enjoy WebIOPi ! But the server and GPIO state will be lost when you'll stop the script (CTRL-C) or close the terminal.

Running WebIOPi (Daemon)

You can also start/stop the background service, the configuration will be loaded from /etc/webiopi/config.
$ sudo /etc/init.d/webiopi start
$ sudo /etc/init.d/webiopi stop

Auto start at boot

To setup your system to start webiopi at boot :
$ sudo update-rc.d webiopi defaults
To remove webiopi start from boot :
$ sudo update-rc.d webiopi remove

Access WebIOPi over local network

If your Raspberry Pi is connected to your network, you can open a browser to http://raspberrypi:8000/ with any device of your network. Replace raspberrypi by its IP.
Default user is "webiopi" and password is "raspberry"


Parte 2


A continuación, dentro de lo ya instalado por parte del sistema, accedemos a la ruta dentro de la carpeta WebIOPi del Serial monitor cd /home/pi/webiopi-trunk/htdocs/app/serial-monitor   Ahí podremos modificar el archivo index.html con lo que deseemos, que en nuestro caso, se puede mantener así ya que lo único que requerimos es enviar un número, el cual será procesado en el microcontrolador para así poder enviarlo a los motores.
La página que se desplegará será la siguiente:


Lo que sigue es el routeo para que se despliegue inmediatamente al usar la dirección de la raspberry pi, que en nuestro caso es 10.25.85.181:8000.

Para mayores referencias visitar: https://code.google.com/p/webiopi/wiki/Tutorial_Serial

1 comentario:

  1. No se debe olvidar remover "console on ttyAMA0" en la carpeta /boot/cmdline.txt y también desabilitar 'getty' en ttyAMA0 en /etc/inittab. Al terminar de realizar los cambios se debe reiniciar la RaspBerry para que los cambios surtan efecto.

    ResponderBorrar