Month: May 2013

Things to do with Raspberry Pi!

  1. Time-lapse Star-gazing photography
    Set up telescope and tape the camera module to the lens. take photo every 10 seconds and make them into a video.
    Things i need: camera module and this reference link.
    And convince my professor to lend me his telescope? :s
  2. My Raspberrian Diary
    A not so small tablet with raspberry pi hidden beneath a small-sized screen.
    A nice web app that allows me to store “things to do” or diary in my raspberry pi. or post it somewhere in skydrive or dropbox?A very vintage Note App indeed. ==
    who bother about it when everyone is using smartphone’s note app everywhere! geez.
  3. Fake barking system
    When people walking by my gate at night, the sensor will sense the person and a mini speaker will give out a dog barking sound. 😀
    Wooof!! grrrrrrrr~!!!
    Also, it will have a sets of sound so that it will not be the same all the time. :p May be during vacation mode!

Basic concept on CherryPy

A python script called hello.py is created as follows:

import cherrypy

class HelloWorld:
def index(self):
return "Hello world!"
index.exposed = True

cherrypy.quickstart(HelloWorld())

The application can be started at the command prompt by typing $ python hello.py
At the web browser, “Hello World” can be seen when it is directed to http://localhost:8080.

import cherrypy // imports the main CherryPy module

class HelloWorld: //declare a class named HelloWorld
def index(self): // contains a single method called index which will be called when the root URL for the site is requested (http://localhost/)
return “Hello world!” // return the contents of the web page (“Hello world!” string)
index.exposed = True // to tell CherryPy that index() method will be exposed and only exposed methods can be called to answer a request. This allows user to select which methods will be accessible via the web.

cherrypy.quickstart(HelloWorld()) // mounts an instance of the HelloWorld class and starts the embedded webserver. It will run until explicitly interrupted.

When the web application is executed, the CherryPy server will listen on localhost at port 8080.
The default configuration of CherryPy server can be overridden by using another configuration file or dictionary.

When it receives the request for the URL http://localhost:8080, it searches for the best method to handle the request, starting from the first instance (HelloWorld). The root of the site is automatically mapped to the index() method. The HelloWorld class defines an index() method and exposes it (@cherrypy.expose). Therefore CherryPy will call HelloWorld().index() and the result of the call is returned to the browser as the contents of the index page for the website.

In order for CherryPy to call a page handler, it has to identify which and where to call for a given Uniform Resource Identifier (URI). A Dispatcher object is used to understand the arrangement of handlers and to find the appropriate page handler function.
The arrangement of CherryPy handler by default is a tree which enables the config to be attached to a node in the tree and cascade down to all children of that node. The mapping of URI to handlers is not always 1:1 and thus it offers more flexibilities.

The Little Black Sheep

black cute sheep

Dearest Jesus,

It’s me again. Thank you for accompanying me crying for hours last night. I know I have been silly for having those thoughts but thanks for bearing with me.

Every time when the darkness engulfs the earth, I would whisper to you till I fall asleep quietly. Although I have never seen you in my whole life, I know you are listening. I know you understand my heart more than anyone else.

This little faith of mine. That great love of yours.

Sometimes I am envious. Sometimes I am worried. How could I ever be by your side? How could I love you more than anyone else? How could I stand out from the herd of sheep that you are taking care of?

Soon I turned grey. I stayed out from the herd. I watched you from afar. I wasn’t moving along and you waited for me. You called out for my name and I turned a deaf ear.

I refused to be bathed, to be cleaned from the dust and mud of the earth. Soon, I got darker and darker. The herd of sheep avoided me. They called me the Black one, the Sinned one.

I was angry and upset and I turned away. On my feeble legs, I climbed up the cliff. I could see you going through that herd of sheep. Were you looking for me? I sneered, you will never see me ever again so just leave me alone.

Why were I crying for each steps that i walked away from you? Why every lift of foot become heavier? What force is holding me back?

I could hear you calling out my name. It was becoming clearer and clearer. Soon, the sound fainted out. I was almost there, to the top of the mountain. Just a few more steps and I would be at the top of the world. I collapsed on the ground. Instead of a force that was pulling me back, it became a pulling force. Like a corpse, lifelessly been dragged to the pile of skulls.

I saw death. I felt what it is called hopeless. I saw fire was engulfing the skulls, mountains are collapsing. And I heard a faint call of my name.

No, don’t turn back. I refused to turn back. I am a disgrace. You will never love me again. But I couldn’t move. Tears couldn’t be held back.

Deep in my heart, there was fear. Fear that I will never see you again. Fear that you would never love me again.

Fear of rejection.

You lifted me up and said, let’s go.

Let’s go home.

For that moment, everything turned white. And I slept soundly and peacefully in your embrace.

Double deck phone case

It’s very inconvenient to bring and use two or more phones at the same time. It’s a trend today that a lot of people are owning iPhone and a Samsung phone at the same time. (Because they just can’t decide which one is better or they just want to be comparable to everyone?).
I would love to have a phone case which allows me to put two or more
phones (one on top of another) and I can just flip over to use whichever phone I like. Awesome.

Double deck phone case

It’s very inconvenient to bring and use two or more phones at the same time. It’s a trend today that a lot of people are owning iPhone and a Samsung phone at the same time. (Because they just can’t decide which one is better or they just want to be comparable to everyone?).
I would love to have a phone case which allows me to put two or more
phones (one on top of another) and I can just flip over to use whichever phone I like. Awesome.

Z-Wave Aeon Labs Minimote

aeon labs logoaeon labs minimote

Product Name: Aeon Labs Minimote

Feature and Functions:

  • a remote control

  • capable of adding, removing, and controlling other z-wave devices (as primary controller)

  • automatic rediscovery of Z-wave network and becoming a secondary controller.

Operational Procedures:

  1. Inclusion-Mode (as primary controller only)

    – press button “include” – blue LED blinks slowly

    – press button on device – blue and red LED will blink quickly – blue LED will stay solid for 2 seconds to indicate success / red LED will stay solid for 2 seconds to indicate failure

    – Blue LED continue to blink slowly and can repeat for all other devices

    – if it is a secondary controller, the Red LED will stay solid with 2 seconds then exit the mode.

  2. Removal mode (as primary controller only)

    – press button “remove” – red LED will blink slowly

    – press button on the device – blue LED will stay solid for 2 seconds to indicate success or red LED stays solid for 2 seconds to indicate failure

    – red LED continue to blink and can continue to remove other devices

  3. Creating scenes ( and removing Z wave devices from scenes)

    – press and hold the scene button – blue LED will blink fast

    – while still holding the button, press on the button of the devices – blue LED will stay solid

    then adjust the device to the level you want

    – release the scene button to complete adding the device

    – if repeat for the same device, it will be removed from the scene

  4. All – On ( turn on ALL Z wave devices in the network)

    – press and hold the top left and top right scene buttons together

  5. All – Off ( turn off all Z-wave devices in the network)

    – press and hold the bottom left and bottom right scene button together

  6. Dim Up/down – brighten / dim the zwave devices associated to a scene

    – press and hold the button – blue led will blink slowly

    – release when the desired level is reached

  7. Association

    – press the button “ associate” – blue LED blinks slowly

    – press the button on the destination device ( slave) – blue LED blinks quickly

    – press button on the source device ( routing slave – sensor, controller) – blue LED stays solid for 2 seconds to indicate success; red to indicate failure

    – repeat for all other source devices

    – press any other button to exit

  8. Disassociation

    – press and hold the button “associate” – red LED blinks slowly

    – press the button on the source – blue LED stays solid for a while

  9. B ecoming a secondary controller

    – press button “learn” – blue LED blink slowly

    – press button on primary controller (include) – blue and red blink quickly

    – blue led stays solid for 2 seconds to indicate success; red to indicate failure

  10. Reset

    – press and hold both “associate” and “learn” for 10 seconds

    – red LED blinks from slow to fast

    – blue LED stays solid for 2 seconds to indicate success

  11. Rediscovering

    – press and hold button “include” for 10 seconds

    – blue and red LED will blink quickly

    – blue LED will stay solid for 2 seconds

Comments:

Minimote operations are rather confusing at the start because there are quite a few different modes. The indications have to be observed carefully too. Nevertheless, it works well as a secondary controller complementing Z-Stick for the purpose of associating and disassociating the z-wave devices as well as creating scenes. Of course, it works well as a stand alone primary controller too.

VNC Server on Raspberry Pi

VNC Server

It would be tedious if you are connecting your Raspberry Pi to your only TV. You are doing some programming on it and you realize it’s the show time of your favourite drama series or cartoon series! (Yes I feel frustrated everytime I missed any minutes of the episode last time!)

Instead of unplugging your monitor from your PC, you can actually unplug R-Pi from its current set up (with a monitor, keyboard, mouse and so on) leaving only the power and Ethernet cable may be. Power on your laptop or PC and start PuTTY in order to connect securely to R-Pi.

Type in the following in the terminal (without $):

To install Tight VNC Server: $ sudo apt-get install tightvncserver
To run the program: $ tightvncserver

tightvncserver

To start VNC server

(not really necessary) To start a VNC session: $ vncserver :1 -geometry 1920x1080 -depth 24

VNC Client / Viewer
On my laptop (window XP), I use UltraVNC downloaded from here.
Start UltraVNC Viewer and you will see this.

UltraVNC

UltraVNC

raspberry pi IP address

How to get IP address of Raspberry Pi.

UltraVNC authentication

UltraVNC authentication

Type in the server IP address and display number (1).  Key in your password set for your VNC server. Your R-Pi GUI desktop is now live on your laptop!

Raspberry Pi VNC remote desktop

Raspberry Pi VNC remote desktop

You can start the second or third server as well by replacing “:1” with “:2”, “:3” and so on.