Skip to main content

Posts

Showing posts from August, 2013

DS1621 with Raspberry Pi/ArchLinuxARM

Here is  how to get DS1621 I 2 C Temperature sensor working with Raspberry Pi running ArchLinuxARM Make sure you have a working setup of RPi and Arch Linux, if not refer here: HelloWorld in Lua on Raspberry Pi running Mihini on ArchLinux with Koneki as IDE After you have the setup ready, attach the DS1621 sensor to your RPi as shown in the schematic below. I have Model B Revision 1.0 Raspberry Pi ( cat /proc/cpuinfo shows Revision : 0002 ) DS1621 connected to Raspberry Pi (.fzz file here ) The following commands issues to RPi over a terminal (SSH or Serial using PuTTY): Install i2c-tools : pacman -Sy i2c-tools Install lm-sensors : pacman -Sy lm_sensors Open kernel module load config file for editing: nano /etc/modules-load.d/raspberrypi.conf Add the following line at the end of the file and save it. i2c-dev This will load the i2c-dev kernel module at boot up. This module will allow you to access the I 2 C bus via /dev/i2c-0 Reboot Raspberry Pi When the Raspberr

Reading switches via GPIOs on Raspberry Pi in Lua (ArchLinux+Mihini)

My previous posts on using Eclipse M2M with Raspberry Pi: HelloWorld in Lua on Raspberry Pi running Mihini on ArchLinux with Koneki as IDE ( link ) LED Blinky in Lua on Raspberry Pi running Mihini on ArchLinux ( link ) Autostart Lua script on RasPi+Archlinux+Mihini at power up ( link ) After having accomplished the above, I moved on to reading switches and controlling LEDs My schematic looks like below: This is how I connected 4 switches and 4 LEDs to the GPIO pins of my Raspberry Pi. Black wire is Gnd. I wanted to toggle an LED for each press of the corresponding switch. I paired up each switch to an LED: Switch at GPIO 4 would control the LED at GPIO 22 Switch at GPIO 17 would control the LED at GPIO 23 Switch at GPIO 18 would control the LED at GPIO 24 Switch at GPIO 21 would control the LED at GPIO 25 I registered a hook function which would be called whenever the state changed of any of the four GPIOs to which the switches were connected. From with

Autostart Lua script on RasPi+Archlinux+Mihini at power up

After having setup  Mihini on my Raspberry Pi/ArchLinux and having blinked a few LEDs via GPIOs, I wanted to try out configuring Mihini to start a Lua script at power up. Benjamin CabĂ© ( blog  | twitter ) and the mihini contributors ( twitter ) pointed me in the right direction: Creating Launcher & Installing App | Appmon Daemon First up, here is a code to blink four LEDs. How is it better than the previous code that blinked four LEDs together? Well, this one used the sched  module to blink the four different LEDs at different rates using 4 tasks in parallel. 4 instances of tasks are created from the same function blink() using the sched.run. For each instance, we pass different parameters to blink a different LED at a different rate. We use sched.wait() within a task to relinquish control to another task waiting in queue - this is how collaborative multitasking is implemented here using the sched module. blinky.lua: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1

LED Blinky in Lua on Raspberry Pi running Mihini on ArchLinux

After setting up Eclipse M2M toolchain for Raspberry Pi, I wanted to try out a simple lua script to blink LEDs using GPIOs. Here is the schematic and lua script for the same. I used the 3.3V available on RPi for powering the LEDs. 1 kiloohm resistors were used to limit the current passing through the LED. The cathodes of the LED were connected to drain the current into the GPIO pins. I used 4 LEDs connected to 4 different GPIOS (GPIO 22, GPIO 23, GPIO 24, GPIO 25). Schematic Photo of the setup, I used a LED/Switches widget 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 package.path = '/opt/mihini/lua/?.lua;/opt/mihini/lua/?/init.lua;' .. package.path package.cpath = '/opt/mihini/lua/?.so;' .. package.cpath local gpio = require "gpio" local clock = os.clock local function sleep (n) -- seconds local t0 = clock() while clock() - t0 <