$10 GPS

pciegpsOn ebay you can find cheap u-blox mini-pcie gps units for around $10 including shipping. They are for internal use in laptops and similar (most likely hooking up to the usb bus over Mini PCIe), but it turns out that the pads on the backside expose connectivity options such as uart and usb data.

I soldered on a pin header for ease of use, and also attached a cheap ceramic antenna using double sided tape.

The UART pins will spew over standard NMEA 183 data, so it should be easy to use with both computers and microcontrollers.

On the raspberry pi you can install the gpsd and gpsd-clients packages. Connect the tx gps pin to GPIO 15 RXD on the pi (you only really need one way uart, unless you want to change settings on the gps). Also connect ground and vcc, the gps requires 3.3v and probably need more umphf than the 50mA max 3.3 pin on the pi can deliver. I connected power via a 5v pin and a 3.3v regulator. I do not know if the gps is 5v tolerant, but probably not.

Launch the daemon ( gpsd -b /dev/ttyAMA0 ) and a client ( cgps ).. Remember to disable the tty running on /dev/ttyAMA0 before you use the UART pins for something like this.

Go GPIO library for Raspberry Pi

GopherBeen playing a bit with Go (-lang) lately, it seems like a fun little language. Very minimalistic and clean, yet quite powerful – you can do so many things with the simple constructs they provide (especially the goroutines, channels and type-system). Sadly, it looks like it’s pretty slow in benchmarks compared to the other natural alternatives – but it’s still early.

animatedAnyway, in an attempt to mix Gophers and Pi, I’ve made a small native GPIO library for Go on the Raspberry Pi (or the bcm2835 chipset in general). Nothing advanced, but it provides the usual suspects: PinMode (Output, Input), Write, Read, PullUp, PullDown, PullOff, etc. It works by memory-mapping the GPIO addresses in /dev/mem, so it will require root.

To use, and blink a little LED (“hello world” of the electronics/microcontroller realm) just do something like:


import (
	"fmt"
	"github.com/stianeikeland/go-rpio"
	"os"
	"time"
)

func main() {
	if err := rpio.Open(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	defer rpio.Close()

	pin = rpio.Pin(10)
	pin.Output()

	for x := 0; x < 20; x++ {
		pin.Toggle()
		time.Sleep(time.Second)
	}
}

Available over at GitHub.

Would be awesome to add PWM, I2C, SPI, etc.. who knows, maybe one day..