Oct 022012
 

BerryIO by Daniel Bull. As demonstrated to me at the Milton Keynes Raspberry Jam Sept 30th 2012.

Apologies for the high background noise level. This was shot live at the event, so we couldn’t ask everyone else to shut up or we’d have been lynched. ;)

If you want a closer look, you can download Berryio from here http://frozenmist.co.uk/downloads/berryio/

In a nutshell, it’s a web browser based IO control system for the Raspberry Pi.

  28 Responses to “BerryIO – a Browser Based IO Control System for Raspberry Pi”

  1. Very Cool !!!

    Great Demo !!!

    • Thanks Patrick,
      I’m hoping to get BerryIO up on Github in the next week or so, so others can contribute to the code. Hopefully this should lead to some more features :)

  2. Awesome!!!

    A couple of thoughts… If I may :-) please…

    Consider allowing the user to name the GPIO pins.
    Allow 1 or more pins to send out an email when state chages to a defined state. ie. send an email when a door opens or other abnormal condition exists.

    Thanks for sharing
    Dwight

    • Hi Dwight,
      Love your “name the GPIO pins” idea, will stick it on the to do list :)
      With reference to sending out an email when a GPIO pin changes to a defined state, unfortunately to the best of my knowledge its not really possible to generate an interrupt from the GPIO so you would need to write a program which runs in a loop, checking the GPIO state and sending an email when it changes. You could however use the BerryIO PHP libraries to do this, if I get some time I’ll see if I can give you some example code.

    • Hi Dwight,
      Here is your code to send an email when a GPIO pin changes using the BerryIO PHP libraries.
      What you need to do is copy this into a text file, for example called test.php
      Then change the file to be executable, for example: chmod +x test.php
      Then run it: sudo ./test.php

      I’ve put lots of comments in so you can understand how it works:

      #!/usr/bin/php
      <?
      /*——————————————————————————
      Example code to send an email when a GPIO pin changes state
      using the BerryIO Libraries
      ——————————————————————————*/

      // Your Settings
      define('GPIO_PIN', 4); // Set this to the GPIO pin you wish to monitor
      define('UPDATE_FREQUENCY', 1); // Set this to the number of seconds to wait between checks

      // Start up BerryIO
      define('EXEC_MODE', 'cli');
      require_once('/etc/berryio/paths.php');
      require_once(BASE.'/includes/configs/paths.php');
      require_once(CONFIGS.'common.php');
      require_once(SETTINGS.'common.php');
      require_once(FUNCTIONS.'common.php');

      // Load the BerryIO GPIO Library
      include(FUNCTIONS.'gpio.php');

      // Load the BerryIO Email Settings
      include(SETTINGS.'email.php');

      // Put the pin into input mode
      if(gpio_set_mode(GPIO_PIN, 'in') === FALSE) exit('Cannot set GPIO pin to input mode');

      // Now get the pin status
      if(($pin_status = gpio_get_value(GPIO_PIN)) === FALSE) exit('Cannot get the GPIO value');

      while(TRUE)
      {
      // Wait for a short while before checking again
      sleep(UPDATE_FREQUENCY);

      // Get the new GPIO pin status
      if(($new_status = gpio_get_value(GPIO_PIN)) === FALSE) exit('Cannot get the GPIO value');

      // If its changed send an email
      if($new_status != $pin_status)
      {
      // Send an email
      if(mail(EMAIL_TO, 'GPIO Information', 'GPIO Pin '.GPIO_PIN.' has changed to '.$new_status, 'From: '.EMAIL_FROM) === FALSE) exit('Cannot send email');

      // Record the new status
      $pin_status = $new_status;
      }
      }

  3. Additional comments/ideas

    Allow the RPi to send an email when an analog value exceeds a set limit.

    Allow the use of Dallas Semiconductor DS18b20 temperature sensor.

    I can supply example Basic Language code to read the DS18b20 if that would be helpful.

    thanks again
    dwight

    • Hi Dwight,
      Your request for the email send when an analog value is exceed is similar to the problem above. I’ll see if I can cover it when I cover the problem above.

      For temperature sensing with BerryIO I recommend using a TMP36 with an MCP3002 ADC. Both components are available from stockists such as SKPang: http://www.skpang.co.uk/

      • Is there currently/will there be support for the DS18B20? I am designing a Brewing Control System that utilizes these sensors in the process and would really like to integrate BerryIO into the project.

        Thanks for your work –
        DM

    • Hi Dwight,
      I’ll let you write the code for the analogue check but the library you want is:
      include(FUNCTIONS.’spi.php’);

      And the command is:
      spi_get_adc_values($chip_select, $channel)

      So for example:
      if(($spi_value = spi_get_adc_values(0, 0)) === FALSE) exit(‘Cannot get the SPI ADC value’);

      Will set $spi_value to the ADC value for the chip on chip enable 0 and chip channel 0

  4. Very nice, what devices do you use for the SPI ADC DAC ?

  5. BerryIO is now on GitHub! (Don’t blame me I didn’t name it)

    https://github.com/NeonHorizon/berryio

    Its my very first time doing source code version control using Git so hopefully I’ve understood it all correctly ;)

    The new installation instructions are here:
    https://github.com/NeonHorizon/berryio/blob/master/INSTALL.README.txt

    If you are using an older tar.gz version of BerryIO I recommend you upgrade to the GitHub version as all future updates will use the new upgrade system which is integrated with GitHub. To do this you can use the installation instructions linked above and it will overwrite any existing versions. (My apologies but this will reset BerryIO to defaults so you will have to apply any changes you made again. My next big project is improving the upgrade and install scripts so this doesn’t happen!)

    For those that don’t know Git is basically a system that allows lots of people to work on the same source code so they can collaborate on projects. Its was written by Linus Torvalds (the guy who started Linux) and is also used to develop the Linux Kernel.
    http://en.wikipedia.org/wiki/Git_(software)

    GitHub is place where people can share Git projects.
    http://en.wikipedia.org/wiki/Github

    Enjoy and feel free to contribute :)

  6. OK thats useful…
    Apparently git doesn’t preserve file permissions.
    If you have multiple users on your Raspberry Pi and downloaded BerryIO before 23:10 today you may want to fix the security permission on /etc/msmtprc so they can’t see your email password.

    The latest permissions I use are
    sudo chown root /etc/msmtprc
    sudo chgrp www-data /etc/msmtprc
    sudo chmod 640 /etc/msmtprc

    Its fixed in the latest installer.

    • Yeah. Someone kindly suggested I use GitHub for the Gertboard Python software I wrote. Apparently it makes life easier for pulling together all the masses of helpful suggestions and code people contribute.

      I laughed, and then posted a polite reply. I think I got two helpful comments about suggested improvements and zero offers of help throughout the project. ;)

      I’m not complaining, but the idea of learning Git for that was quite laughable. Oh and I don’t think you can even see how many people have downloaded your software either. I like to know about these things. :)

  7. Thank you,
    I do not know why it worked only after I manually create the the file “error.log” inside the folder “/ var / log / berryio.”
    The script was unable to create them and could not start apache
    ;-)

  8. Ohhh well spotted thank you!
    There is a mistake in the install script!
    Since I moved to the new github format it doesn’t create /var/log/berryio or /var/log/msmtp I will fix this!

  9. Just released BerryIO 1.6.0!
    Phew that was hard going….

    – I’ve added a fix to cope with the incorrect GPIO mode information coming from /sys/class/gpio/
    – I’ve added the ability to name GPIO pins which was popularly requested
    – There are new Hints and Tips sections which are essentially the previous help text plus a bit more
    – I’ve moved the check for updates button so its easier to get to (IE above the long changelog)
    – I’ve added a CSS fix for IE
    – ..and I’ve added a settings check to cope with the fact that /etc/berryio settings may be incompatible with newer versions

    By the way you will get an error because the /etc/berryio/gpio.php settings file has changed format slightly to allow you to name the GPIO pins but it will tell you what to do about that when you run it.

    Fingers crossed no bugs :)

    For fresh installs or versions prior to 1.5.0 go here:
    https://github.com/NeonHorizon/berryio/blob/master/INSTALL.README.txt
    Everyone else just click on check for updates under About and it will tell you what to do.

    I don’t actually have a blog for BerryIO yet, I guess thats something I need to sort.
    However people can follow me and talk to me on G+ here:
    https://plus.google.com/u/0/109352235257103413028/posts

  10. Hi Daniel,

    First, I just say your project is great, It make me more linux filesystem knowledge. Thanks again for your hard work open source project.

    BTW in case I would like to back to normal web server configuration, I tried to remove apache2 but it still has your script embedded in system , Could you please provide method to remove and return back as normal web server configuration?

    sorry for my English language.

    • Hi Thai,
      Please do the following.

      // This will disable the BerryIO site/settings
      sudo a2dissite berryio

      // This will enable the Apache default site/settings again
      sudo a2ensite default

      // This will restart Apache with the new settings
      sudo service apache2 restart

      Hope that helps :)

      Daniel

  11. H Daniel

    This is a great project and I have made a simple interface cct from the pins to a remote plug controller which works well from a Firefox browser.
    I am also using the command line which works fine but I get a php notice after every cmd. Is this the bug in ver 1.6.2 which is the version I am using?
    Can I re-install the script for a later version without having to re-input all the config data in it and apache.
    Cheers and well done.

    • Hi Gordon,

      Yes thats the bug which has now been fixed in the newer versions.
      To solve it you should just be able to type:
      sudo berryio upgrade
      …and the problem will go away (and you will get some new features).
      The upgrade will only change files in /usr/share/berryio so unless you have changed any of those (which you wont have unless you changed the main program) all your configuration should remain in tact. It is only the full install that resets the config.

      Hope this helps!

      Daniel

  12. Many thanks – did the upgrade and the php warning notice went away.

    The webpage semms faster and more positive too.
    Installed it all again on another Raspi (no problems) and wrote sone php code to follow its ip and keep it linked to my main Paspi server, so now its going off to france to let it control the house there, while I am in the Uk.

    Brilliant – thanks again.

    g

Leave a Reply to Daniel Bull Cancel reply