PICAXE URF/ERF Hello World on Ubuntu

August 22, 2013

I wanted to use the PICAXE URF and ERF modules to send information gathered by a PICAXE to a computer. This means that I can send temperature readings, or signals from a rain gauge, through to the computer using wireless signals.

The ERF module is supplied with pins to connect it to a breadboard - I needed to solder these pins to the board before I could start.

Circuit

The circuit used is that contained in the datasheet (link in References below) for PICAXE download, except that the link to TX is not needed and the RX can be connected to any PICAXE output pin. So:

  • DTR - connected to a 1k resistor and then through an LED to ground
  • RX - connected to pin 3 (C.4) of my PICAXE 8M2+
  • TX - not connected, left floating
  • PWR - connected to +5v
  • CTS - connected to 0v
  • 0V - connected to 0v

PicAxePinout

Program

The following PICAXE program was used. This flashes two LEDs and sends Hello and World at intervals.

main:
    setfreq m8
    high C.4
    for b0 = 1 to 5
        high C.1
        high C.2
        serout C.4,N9600_8,("Hello")
        pause 400
        low C.1
        low C.2
        serout C.4,N9600_8,("World")
        pause 400
    next
    pause 2000
    goto main

Note that:

  • The 8M2+ clock speed is modified to 8Mhz using setfreq m8. This is required for the ERF module to work at its default 9600 baud.
  • As the chip is overclocked to double its default 4MHz, all the pause command values had to be doubled.

Linux

On the Linux box, the wireless signal can be monitored in real time. On my machine, when the URF module was plugged in, I gained a /dev/ttyACM0 device. The first command below configures this device to run at 9600 baud, and the second outputs the data received to the console:

drumcoder@machine:~$ stty -F /dev/ttyACM0 9600
drumcoder@machine:~$ cat /dev/ttyACM0
WorldHelloWorldHelloWorldHello

References