Rapid prototyping for music, art and design work

Accessing sensors and actuators in Nokia N900

Nokia N900 has a bunch of interesting sensors and actuators. This post explain how to read the internal sensors (e.g. accelerometer) and write the actuators (e.g. vibration motor) by accessing sysfs in X Terminal application. Details can be found in Maemo wiki pages


Establish the environment (To access data from sensors and actuators,  you need to be a root user in X Terminal.)

  1. Install “rootsh“.
  2. Open X Terminal application. As it’s a defualt application, you can find it in the application grid.
  3. Type “sudo grainroot” and press return.
  4. The screen should show “Root shell enabled”.

Accessing accelerometer

  1. Type “cat /sys/class/i2c-adapter/i2c-3/3-001d/coord
  2. The screen shows “-36 -198 972” for instance. (value is milliG. 1000mG = 1G)

Use Arc tangent to calculate pitch.

angle_in_radians = atan2(x, -y)

angle_in_radians = atan2(y, -z)

Example python code:

def get_rotation():
f = open(“/sys/class/i2c-adapter/i2c-3/3-001d/coord”, ‘r’ )
coords = [int(w) for w in f.readline().split()]
return coords

Accessing light meter (ambient light sensor)

  1. Type “cat /sys/class/i2c-adapter/i2c-2/2-0029/lux
  2. The screen shows “20” for instance. (the sensor is located between Nokia Logo and phone speaker on the left hand side.)

Accessing vibration

  1. Type “sudo gainroot”
  2. Type “echo <number> > /sys/class/leds/twl4030\:vibrator/brightness”
  3. Type number between 0 and 255.
  4. Vibrate for a moment according to the number.

Accessing Bluetooth Serial profile

  1. Type “sudo gainroot” if you are not the root user.
  2. Type “rfcomm -r connect 0 <MAC address of the Bluetooth device> 1” (e.g. MAC address -> 03:1A:09:08:32:02). The first 0 is a device number. The digit after the address is channel number.
  3. Type “cat – >/dev/rfcomm0” (0 is the device number)
  4. If Bluetooth connectivity is established, you can send data by typing and received data is shown on the screen.
  5. If the connectivity is failed, type “killall rfcomm 2>/dev/null” and start over again from 1.

Accessing GPS

  1. Install GPS Track Logger Widget (This widget creates a live log of Geo coordinate if GPS is enabled. The Debian software package has .deb extension.)
  2. Go to Homescreen. (The widget should already appear there.)
  3. Press “Rec” button of the widget. See the corresponding screenshot.
  4. Open X Terminal
  5. Type “sudo gainroot”
  6. Type “cd MyDocs” (Default file path should be under MyDocs. This can be changed in the setting view of the widget.)
  7. Type “cat xxxx.gps” (filename should be latest one if there are multiple).
  8. The xml file contains log data of Geo coordinates.

GPS Track Logger Widget

See details in Maemo wiki about Location API.

Controlling Full color LEDs

  1. Type “echo <number> /sys/class/leds/lp5523:r/brightness” (Number between 0 and 255)
    1. Red: /sys/class/leds/lp5523:r/brightness
    2. Green: /sys/class/leds/lp5523:g/brightness
    3. Blue: /sys/class/leds/lp5523:b/brightness
  2. There are 6 backlight underneath keyboard. Each can be controlled as follow.
    1. echo <number>/sys/class/leds/lp5523:kb1/brightness
    2. echo <number> /sys/class/leds/lp5523:kb2/brightnes
    3. echo <number>/sys/class/leds/lp5523:kb3/brightnes
    4. echo <number>/sys/class/leds/lp5523:kb4/brightnes
    5. echo <number>/sys/class/leds/lp5523:kb5/brightnes
    6. echo <number>/sys/class/leds/lp5523:kb6/brightness

Example python code
oslo:~# cat
#! /bin/bash


while true; do
for led in $RED $GREEN $BLUE; do
echo 255 > $led ; sleep 1 ; echo 0 > $led

Facebook Twitter Email

Category: Snippets


One Response

  1. david says:

    in led paterns give me an error…
    it says
    exit status 65280
    diferent number of lines

    can anybody helps me?
    my mobile is always withs the lights on and the keypad never is on…

Social links powered by Ecreative Internet Marketing