sudo|Xanthippe

But once I caught him when he was open like Silenus' statues, and I had a glimpse of the figures he keeps hidden within: they were so godlike — so bright and beautiful, so utterly amazing — that I no longer had a choice: I just had to do whatever he told me.

First test of the balloon

Well, to be honest, I am very disappointed with it. I filled one balloon with hydrogen I obtained from reaction which occurred after mixing some sodium hydroxide dissolved in water with aluminium foil. Little displacement (about 5 grams) is probably caused by impure hydroxide which I used. At this moment buying that ingredient would be more problematic than buying whole bottle of helium so I decided to do it. While I’m waiting for the shipment I decided to do more tests, so tomorrow I’m going to use all supplies I’ve got to fill as many balloons as it will be possible. There is one more issue I need to consider. After buying these small balloons (30cm of width) I found on the Internet place where I can buy one that has 1 meter of diameter. I think of using two of them instead of plenty of these smaller. 

Raspberry Pi powering module (edit)

I noticed that there is a problem with my powering module when I’m connecting to Raspberry Pi devices that consume to much power. 7085 was limiting amperage to 1A so I decided to replace it with 78S05. You can do the same without modifying schematics I attached to last post which you can find HERE. I also installed small radiator which is leading away heat.

Using motion to stream image from a webcam

Motion is probably best capturing software if you need to store and stream image from webcam connected to your Raspberry Pi. It don’t consume much ram and it is fully configurable. To install it on Raspbian simply run as root that command:

apt-get install motion

Ok, we’ve got it installed. Now it requires little configuration. Edit /etc/motion/motion.conf with your favourite text editor (I use nano). Everything there is clearly described so I’ll show here only the most important options and describe some of them.

Motion should automatically detect your video device, if you’ve got more than one connected to RPI change that value. To check all of them type:

ls /dev/video*

  • width and height

These values are based on parameters of your webcam.

  • framerate
  • minimum_frame_rate

If you want to stream image slower than 2 fps put there value that in equal to number of seconds you want to wait between every capture.

  • ffmpeg_cap_new
  • ffmpeg_video_codec

That is useful only for those who want to keep not only images but also video. I turned it off on my device. To use it you’ll need to have ffmpeg installed.

  • target_dir

Location where motion will store its files. I strongly recommend to change default setting because /tmp on Raspbian is mounted on smaller partition (about 60MB). /tmp is also automatically cleaned during every booting so if you can easily lost your photos.

  • webcam_port
  • webcam_localhost

Set it to off to be able to connect from another computer.

  • control_port
  • control_localhost

You can use that to manage motion from another computer without editing motion.conf.

Save file (if you’re using nano press ctrl + x). Now type in console:

motion

After that you should be able to connect to it with your browser. Just type its address and port, for example:

192.168.1.67:8081

Image

Image

Working on your Raspberry Pi without using any peripherals

Raspbian has SSH daemon installed by default. It can be used to work on our RPI when we have no possibility to use any kind of control device. It will be also very useful for my balloon project which is actually almost completed. I’ll show you everything in the next post. This one is actually about Linux basics so if you are user of this system, you’ll find probably nothing helpful here.

Let’s start from checking IP of your device. Assume that it is connected to our local network. There are two options of checking its address. You can find it in managing page of your router or whatever you use. You can also use very useful command:

ifconfig

It shows configuration of your network devices. As you see I am connected through wlan, so interface I’m mostly interested in is wlan0. It shows the local address in inet addr field.

Image

Well. I’m already connected to my RPi from Windows 7. To do the same, download PuTTY there: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.

After doing that simply run program and you’ll see something like that:

Image

Type RPi’s address in Host Name field and click Open.

Then you can login into you account. By default it’s:

username: pi

password: raspberry

On your first connection you’ll need to accept RSA key.

On Linux or OS X connecting by ssh is even simpler. You need only to type in console

ssh username@host

In my case it would be:

ssh pi@192.168.1.67

Then you need to accept RSA key on first connection and give password on every.

Raspberry Pi powering module

I’ve build a powering module for my balloon flight. This is how it looks:

Image

Image

To build the same you’ll need:

  • 1x LM7085
  • 1x 1000uF electrolytic capacitor
  • 2x 100nF ceramic capacitors

Schematics for that:

Image

Well, it could be build better, 7805 is wasting some power, that is just the simplest way of building such device. You could use 6 AA batteries as well. When I checked voltage on TP1 and TP2 on RPi board it showed me ~4.90V value. Keep in mind fact that my battery is drained a bit.

————————————————

EDIT 29-07-2012 19:47

Something about 10 minutes after connecting device I found out that 7805 is incredible hot, after next 5 minutes it stopped. To decrease temperature I mounted on it little radiator:

Now it’s good even when I’m putting it inside that box (these are outdated photos made before adding radiator):

As you probably noticed I’m powering device with 6xAA batteries instead of 1x9V battery. In this configuration I’m able to connect that Pentagram Wi-Fi modem and PS3 webcam, it’s working well.

Stationary balloon with Raspberry Pi (Part I)

Plan is simple. I’m going to mount RPi to a couple of balloons filled with hydrogen or helium (still not decided) and raise it 50 m above ground level. RPi will be connected to the Internet with 3g module and it will be streaming through it image from webcam. At this moment I’m gathering needed stuff.

I’ll need:

  • Raspberry Pi +
  • USB HUB powered by batteries –
  • Webcam +
  • 3g module – (I’ve got one but it’s not working on Raspbian, I’ll try on Arch)
  • Balloons –
  • Hydrogen (obtained in home way, I’ll show later how to do that) + / Helium –
  • 50 meters of thick fishing line

Photos of stuff I’ve already got:

Image

Some electronical parts.

Image

Mine Raspberry Pi with webcam that is working fine on it.

There’s a link to post with powering module: LINK.

Writing dice rolling ircbot in Java (Part I)

Some time ago I needed a bot for rolling dices. I found only one, written in Ruby, which I don’t know at all. That determined me to write my own bot. In that time I was working on Bukkit plugin so I decided to stick to the Java. I found out that there is magnificent API called PircBot. I’m going to show how use it to write your own bot.

Environment I use is Eclipse. I’ll also show here how to configure it.

Let’s begin with creating new project.

Image

Name it and click Finish.

Image

Now you need to right click on src and choose New > Package.

Image

Name it as you wish and click Finish.

Image

Now click with your right button on fresh package and select New > Class. Let’s call it Main to keep everything clear.

Image

Before we start writing our bot we still need to do couple formal tasks. We’ll start from importing PircBot jar to our project. Download newest version of it HERE. When I am writing that article, the newest version is 1.5.0. In archive you will find jar file and folder called javadocs. Let’s start from importing jar to our project.

Click with right mouse button on the top of DiceRoller tree and choose from context menu properties. Then  go to Java Build Path and click on Add External JARs… there.Image

You’ll see window in which you need to show Eclipse localization of pircbot.jar. To maintain order keep it in Eclipse workspace folder. After doing that you should see something like this:

Image

Apply if asked for and go to Javadoc Location now. You’ll find it in same window on left side. Browse again to find its folder.

Image

And there is last thing to do in project properties. We need to show Eclipse which class is our main. But we can’t do yet, we need to write our class.

Close that window and make sure that you are editing Main.java. Inside public class paste this:

public static void main(String[] args) throws Exception {

MyBot bot = new MyBot();
bot.setVerbose(true);
bot.connect(“irc.server.you.want.connect.to”);

bot.joinChannel(“#somechannel”);

}

Eclipse will show you that error occurred but nothing to worry about. It’s because we are referring to non-existent class. It begins with throwing exception mechanism. Java needs to have some instructions held inside it in case there will happen exception. Then we invoke new class, then turns on errors visibility, then connecting to server, then join specific channel.

That is everything we need in our Main class. Now let’s create new one called MyBot.

Begin with adding extension to public class MyBot, modify it like this:

public class MyBot extends PircBot {

}

Now Eclipse should highlight PircBot and show such message:

Image

Click on Import ‘PircBot’ (org.jibble.pircbot) and… It’s done! New import just appeared:

import org.jibble.pircbot.PircBot;

If you copied public class code from here Eclipse could automatically did that import, there is nothing to worry about. Just be sure that you’ve got such import.

Now we need to name our bot. But this inside public class MyBot:

public MyBot() {
this.setName(“Bot”);
}

So whole code should look like:

package roller;

import org.jibble.pircbot.PircBot;

public class MyBot extends PircBot

{
public MyBot()
{
this.setName(“Bot”);
}
}

We’ll. That’s the moment when we can finally check how our bot works.

Remember how we were editing project properties? Let’s go there again. Choose from the menu Run/Debug Settings and then click on New… button.

Select Java Application and click OK.

Image

New window will appear. Call it somehow and then click on Search… button.

Image

In new window you should see you main class. Double click it. Apply and exit. Now we are ready to test our bot out. Right click on your project in Package Explorer on left side and choose Export. Double click Runnable JAR file.

From launch configuration chose class we set as main. In library handling select the option in middle. Choose your export destination and click Finish. That’s it.

Now we need to run it. Connect to server and channel you selected for that test and run command line. Go to catalogue you’ve saved your bot and type:

java -jar bot.jar

In couple seconds bot should appear on channel.

Whole code of MyBot.java:

package roller;

import org.jibble.pircbot.PircBot;

public class MyBot extends PircBot {
 public MyBot()
 {
  this.setName("Bot");
 }

public void onMessage(String channel, String sender,
 String login, String hostname, String message) {

}

}

Mechanism of rolling dices will be shown in part 2.

Changing keyboard layout on Raspbian

Default keyboard layout can found out as strange to some users. This can be fortunately fixed really fast.

1. Edit /etc/default/keyboard file:

sudo nano /etc/default/keyboard

Change value of locale to yours.

2. Use Debian’s manager to set layout:

sudo dpkg-reconfigure keyboard-configuration

3. Your keyboard layout should be already set but if you’ll reboot device now it will take ages to end booting. OS will be doing remap at every start. To hold this back use just once setupcon:

sudo setupcon

4. Reboot and be able to use special characters.

Easiest and fastest way to get linux on Raspberry Pi

You are fledgling owner of Raspberry Pi? Well it was finally delivered to me, I really wasn’t interested in arduous configuring my operating system. I just wanted to test it out. RPi team gives us opportunity to have everything working in less than 10 minutes. On Raspberry Pi official page you can download Raspbian, dedicated distribution based on Debian.

Image

Inside zip archive you will find an img file. We still need to “burn it” on our SD card. Unix program called dd will do that for us. I’m using OS X for that so I’ll describe how to do it on mac, but dd is also available on Linux and it’ll work without changing anything.

1. Begin with checking how OS describes your SD card. Type in console:

ls /dev/ | grep disk

Last from that list will be probably the one you are looking for. This can be checked also with any   graphical tool that is used for disk management (for instance, gparted).

2. Unmount (but not eject!) selected disk by doing:

sudo diskutil umountDisk /dev/disk2

3. Now we are able to use dd. Type something like:

sudo dd if=~/Desktop/raspbian.img of=/dev/disk2

First parameter if must indicate img file location, second of location of SD card.

Whole process will last a few minutes. That’s all, now system is ready to boot. If your card is bigger that 2GB remember to expand / partition in gparted.

On Windows it is even simpler. You can use software that is called Win32 Disk Imager.