Tuesday, March 5, 2013

Raspberry Pi Performance to Pachube version 2.0 [UPDATED]

What's this?

rpi2pachube is a set of scripts written in Bash that gather and push performance data from your Raspberry Pi to Pachube.

My own feed

Requirements


  1. Raspberry Pi connected to the Internet.
  2. Debian-flavor "ifstat command". Run "ifstat -v"; You should have version 1.1.
  3. realpath command for setup.sh. Run "realpath --version" to see if you have it installed. Use apt-get or pacman to install it depending on which linux distro you are using.
Arch Linux users: You WILL have to download the source code for ifstat and compile it yourself if you want to monitor a network interface with this script. Arch Linux's ifstat command output format is significantly different from Debian's ifstat. You will otherwise have to modify rpi2pachube to work with whatever flavor of ifstat Arch Linux uses if you do not wish to do this.

How does it work?

rpi2pachube gathers performance data from your Raspberry Pi (temperature, load, network throughput, etc.) at 5 minute intervals and pushes this data to Pachube. From Pachube, you can watch how your Pi is doing from basically anywhere in the world.

What's new in version 2.0?

  • Temperature can now be pushed to Pachube in Fahrenheit.
  • Enable/disable monitoring of any performance value.
  • Monitor multiple network interfaces.

Where can I get it?

Remove any files from any previous versions before installing version 2.0.

There's two ways to get rpi2pachube v2.0.
  1. Cloning the Github repository and switching to tag v2.0
    git clone https://github.com/Cameri/iot_push.git
    git checkout v2.0
  2. Download v2.0 from Github using wget:
    wget https://github.com/Cameri/iot_push/archive/v2.0.tar.gz
    tar xzf v2.0.tar.gz
If you'd like to run the development version of rpi2pachube, simply clone the Github repository without running the command "git checkout v2.0".
After that, run the configuration utility:
cd rpi2pachube*
./setup.sh

Now rpi2pachube.sh will be executed every 5 minutes in the background. Take a look at my feed, populated with performance data from my own Raspberry Pi.

Found a bug or have an idea?

If you have found a bug or you have an idea to enhance rpi2pachube, please open a new issue on the Github repository.

Thursday, January 17, 2013

Auto-reboot a hung Raspberry Pi using the on-board watchdog timer

A watchdog timer is a special kind of timer commonly found on embedded systems that is used to detect when the running software is hung up on some task. The watchdog timer is basically a countdown timer that counts from some initial value down to zero. When zero is reached, the watchdog timer understands that the system is hung up and resets it. Therefore, the running software must periodically update the watchdog timer with a new value to stop it from reaching zero and causing a reset. When the running software is locked up doing a certain task and cannot update the watchdog timer, the timer will inevitably reach zero and a reset will occur.

Luckily for us, the Broadcom BCM2835 SoC on the Raspberry Pi comes with a hardware-based watchdog timer that can do just that. You will find this specially useful if you have a Raspberry Pi in a remote location and the operating system hangs and there's no one around to reboot it.

Load the bcm2708_wdog kernel module

To load the watchdog kernel module right now, issue the following command:
$ sudo modprobe bcm2708_wdog

If you are running Raspbian, to load the module the next time the system boots, add a line to your /etc/modules file with "bcm2708_wdog". The -a option makes sure tee appends instead.
$ echo "bcm2708_wdog" | sudo tee -a /etc/modules


If you are running Arch Linux, add a file called "bcm2708_wdog.conf" with the text "bcm2708_wdog" in /etc/modules-load.d/ with the following command:
$ echo "bcm2708_wdog" | sudo tee /etc/modules-load.d/bcm2708_wdog.conf

Install the software watchdog daemon

In Raspbian, run the following command:
$ sudo apt-get install watchdog
But in Arch we use pacman:
$ sudo pacman -S watchdog

Then, make sure it runs after every boot.
In Raspbian, run:
$ sudo update-rc.d watchdog defaults
OR
$ sudo chkconfig --add watchdog
In Arch run the following:
$ sudo systemctl enable watchdog

Configure the watchdog daemon

Open /etc/watchdog.conf with your favorite editor (mine is nano).
$ sudo nano /etc/watchdog.conf

Uncomment the line that starts with #watchdog-device by removing the hash (#) to enable the watchdog daemon to use the watchdog device.
Uncomment the line that says #max-load-1 = 24 by removing the hash symbol to reboot the device if the load goes over 24 over 1 minute. A load of 25 of one minute means that you would have needed 25 Raspberry Pis to complete that task in 1 minute. You may tweak this value to your liking.

Start the watchdog daemon

In Raspbian:
$ sudo chkconfig watchdog on
or
$ sudo /etc/init.d/watchdog start

In Arch:
$ sudo systemctl start watchdog.service

That's it!

You are done! You may play around with the settings in /etc/watchdog.conf if you'd like.
The watchdog daemon performs other tests that you will probably want to configure.

Arch Linux users: I'm well aware that the watchdog daemon is not necessary in Arch because you can enable watchdog features with systemd by editing /etc/systemd/system.conf but I prefer the watchdog daemon as it is much more featured.

Updates:
2013-01-17 11:45 AM EST: Fixed the chkconfig command to start and enable the watchdog daemon at startup.

Source: Raspberry Pi @ Gadgetoid

Monday, January 14, 2013

Pushing Raspberry Pi Data to Pachube using bash and cron



Pachube
The Pachube API makes it very easy for you to make your Raspberry Pi part of the Internet of Things (IoT). After successfully following this short tutorial, you or any computer connected to the Internet will be able to keep track of how your Raspberry Pi is doing. Even more useful if you have more than one and wish to track them all at once.
This blog post is the result of a brief tutorial I made in Google+'s Raspberry Pi community for +Kim Huebel.


Requirements

Raspberry Pi
  1. Raspberry Pi connected to the Internet.
  2. Debian-flavor "ifstat command". Run "ifstat -v"; You should have version 1.1.
  3. realpath command for setup.sh. Run "realpath --version" to see if you have it installed. Use apt-get or pacman to install it depending on which linux distro you are using.
Arch Linux users: You WILL have to download the source code for ifstat and compile it yourself if you want to monitor a network interface with this script. Arch Linux's ifstat command output format is significantly different from Debian's ifstat. You will otherwise have to modify rpi2pachube to work with whatever flavor of ifstat Arch Linux uses if you do not wish to do this.

Create a feed on Pachube

  1. Create an account on Pachube if you don't have one already and log in with your account.
  2. Add a new device/feed by clicking on the +Device/Feed button.
    1. Select "Something else" when prompted for device type.
    2. Select "No, I will push data to Cosm" when asked for an existing data source.
    3. Give your device/feed a title. (e.g. raspberry-pi-1)
    4. Optional: Add tags to your new device. (e.g., raspberry pi, network, performance)
    5. Click Create.
    6. Write down the feed ID, as you will need this later for configuring the script.
  3. Click "Keys" in your console and then click the +Key button to add a new key.
    1. Label your key. (e.g. raspberry-pi-update)
    2. Set feed restriction to "Use specific feed(s)" and select the Device/feed you created earlier.
    3. Only "update" is needed in Access Privileges.
    4. Click Create.
Github

Download rpi2pachube from Github

  1. Make a directory where you want rpi2pachube folder to be located. (e.g. ~/scripts).
    • mkdir -p ~/scripts
  2. CD into that directory: (e.g. cd ~/scripts/)
    • cd ~/scripts
  3. Clone the git repository.
    • git clone git@github.com:Cameri/rpi2pachube.git
  4. Run the configuration utility.
    • cd rpi2pachube
    • ./setup.sh
  5. When prompted, answer with your Pachube API Key, Feed ID and a Network Interface to monitor.
The configuration utility creates the file ~/.rpi2pachube.conf where your configuration is stored.
It is also possible to manually create a global configuration file in /etc/rpi2pachube.conf but that is unnecessary and not recommended.
Run the configuration utility (setup.sh) instead of manually editing ~/.rpi2pachube.conf.
Your Raspberry Pi performance values will be pushed to Pachube every 5 minutes. To change it, edit your user's crontab file (e.g. crontab -e).

That is all! Feel free to leave a comment.

Links:
Official Google+ Post in the Raspberry Pi community.

Update (Wed, Jan 23rd, 2013): Added "realpath" as a requirement. Renamed script to rpi2pachube and moved repository to a new location.

Legal disclaimer: All mentions of the letter sequence "cosm" on this post or Github repository (or in combination with other letters, or any other representation) refer ONLY to the on-line database service called Pachube and NOT to Cosm®, a trademark that is registered to Mithral Inc.

Wednesday, February 23, 2011

Femtoduino - Ultrasmall Arduino compatible board


The Femtoduino is an ultrasmall (20.7x15.2 mm) Arduino compatible board licensed under Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0).
It is being developed by Fabio Varesano after he needed to add Arduino functionality to small objects.
The result is what you can see on the picture of this post.

Unfortunately, the board is not being sold, meaning you will have to buy all the parts, make the PCB or order it from a fab house and solder all the components yourself.
Luckily, Fabio has shared everything you'll need to build this little devil.

You can buy all the parts by visiting the following link: https://www.mouser.com/ProjectManager/ProjectDetail.aspx?AccessID=b90666b717

For Bill of Materials, Gerber files, schematics and KiCad sources please visit Varesano's website.

Original post: http://www.varesano.net/projects/hardware/Femtoduino

Saturday, January 15, 2011

ITG-3200 Gyroscope Library for Arduino updated

ITG-3200 breakout board by Sparkfun Electronics

I've updated the library to communicate with the ITG-3200 gyroscope by Invense.
In this new version I've included all necessary functions to use the gyroscope's interrupt.

Note: Default values (including I2C Address) are set up to work with SparkFun's ITG-3200 breakout board.

Also, included with the library are two examples, one with interrupts, and one without them.

The following link will take you to the GitHub repository: https://github.com/Cameri/Itglib

You can download the source code by clicking here.

Feel free to post your comment below.

Wednesday, October 27, 2010

ITG-3200 Gyroscope Library for Arduino

Here's the first revision of a library I made for the ITG-3200 3-Axis Gyroscope made by Invensense.

The sensor communicates using the I2C protocol with other devices, for which I'm making use of the Wire library.

You will have to include Wire.h in your sketches if you plan to use this library.

Here's an example of how to use it (assuming you have already made the electrical connections):

#include "itg3200.h"
ITG3200 gyro;

void setup(){
Serial.begin(9600);
gyro.begin(0x69); // as for SparkFun breakout, all default values
delay(1);
}

void loop(){
Serial.print("X=");
Serial.println(gyro.getX());
Serial.print("Y=");
Serial.println(gyro.getY());
Serial.print("Z=");
Serial.println(gyro.getZ());
delay(400);
}

Running this sketch will make the Arduino transmit the readings for each axis through the first serial module every 400 milliseconds.

To download the library, visit the GitHub repository.

UPDATE: This library has been updated as of January 16th, 2011.

Thursday, October 21, 2010

SMD Resistors Cheat Sheet

Here's cheat sheet for reading SMD Resistors that I came up with recently.
If you have trouble reading these components, try using a magnifier.
Here's the link to view it.

If you think you can't solder these think twice, these are actually pretty easy after you practice a couple of times. Here's an 8-part tutorial from the folks at Sparkfun Electronics.