Tuesday, January 22, 2013

Raspberry Pi Received

I just got a Raspberry Pi, model B, and am trying some stuff. The idea is to use it instead of the Beaglebone in a less expensive home monitor.

I received from MCM Electronics Inc a "Raspberry Pi cased product", which is a Pi in a clear plastic case, a 4 GB SD card with Debian 6 for Linux already installed, and a 5V 1A power adapter with a micro USB connector. Total including shipping was $76.80.

I had an HP LCD monitor with an HDMI cable, a USB mouse and a USB keyboard.

I simply connected these to the Pi, powered it on, and it booted to a text-based shell. Running startx brought up the windowing system.

I had a wireless adapter with an ethernet cable, and after connecting this to to Pi ethernet jack I had to do an ifup command to eth0 to bring up the network (only the first time, however.)

So, the board had access to the network, but addressing it (for ssh use) required knowing its IP address. the ifconfig command provided that, and I could ssh to it.

Zero config allows addressing it using local names like raspberrypi.local, and it seems that avahi-daemon was not installed. So I did apt-get install avahi-daemon to get it, and that seemed to install and run the daemon:

$ sudo apt-get install avahi-daemon

The network name is raspberrypi.local. From another computer, such as my laptop running Ubuntu, you can log on to the board thusly:

$ ssh pi@raspberrypi.local

The pi password is raspberry.

The next thing was to get the host-based javascript engine node.js running, since I'd like to program in javascript. (My monitor software is currently written in tcl, which comes preinstalled on the Pi, but I plan to transition to javascript.) There is a package for node:

$ sudo apt-get install nodejs

After installing node, I wrote the standard web server using the http module, and ran it:

$ nodejs webserver.js

Server running at http://raspberrypi.local:1337/

webserver.js:

var http = require('http');
var counter = 0;
http.createServer(function (req, res) {
  counter = counter + 1;
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('From Raspberry pi for the ' + counter + ' time: Hello World\n');
}).listen(1337);
console.log('Server running at http://raspberrypi.local:1337/');

The next job will be to install the usb-modeswitch software so I can run the USB GSM modem as a serial device (HSO.) I don't have a modem here, since I am in New Hampshire and the modem is doing its job back in Maryland, so I'll delay installing that software until I get a modem and sim card to play with.


No comments:

Post a Comment