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.

Month: July, 2012

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.