06 – How to Communicate with the Picaxe?

One of the questions that comes up every time is: How do I Communicate with the Picaxe microcontroller? I want to send information and commands to it or I want to download information gathered by the Picaxe. The answer is by using the serial RS232 communication SerOut and SerIn commands for the Picaxe.

Sending information out to a PC is very handy when you are debugging or just want to see the value of a variable. You can also use a LCD screen for this purpose but you may not have one readily available or you may not have enough pins available to use a LCD display. If that is the case, using the Picaxe serial RS232 communication capability to send data to your PC is the answer.


What do I need to setup RS232 communication between PICAXE and a PC?

  • You can use two methods of RS232 communication in Picaxe. One is by using a MAX202 driver IC to get a true (signals is not inverted) method. This option is probable the best method but it requires an additional RS232 driver IC and other components. The second method uses the same 22k and 10k resister interface used in the programming interface and it makes use of inverted signals. This is the method I prefer because of it’s simplicity and it works just as well.
  • You will also need a spare Input pin for the RXD signal.
  • You will need a communication program on the PC the standard HyperTerminal program on Windows XP works very well. I understand that HyperTerminal is not included in Windows 7, in that case search for a free communication program. One such program is Termite by www.compuphase.com.
Circuit Diagram for RS232 Serial Communication with PICAXE (08M2)

The diagram shows the 10 and 22k interfaces for serial communication as used in the standard Picaxe programming interface. It is important to note that the “Serial In” pin is reserved for Picaxe programming and it can’t be used for serial communication with a PC. We will need a second input pin (pin 3) for the Serial In signal.

If you just want to send data to the PC without receiving anything back from the PC you can use the same Serial Out pin but you will still need a second port and you can omit the serial In signal from the PC on the second serial communication port. This will save you an additional I/O pin and it is ideal for debugging or just sending variables to be displayed on a PC.

The three pins on the serial interface represent the following:

  • Header Pin 1 – RxD – Serial Out
  • Header Pin 2 – TxD – Serial In
  • Header Pin 3 – Gnd – Ground 

How to connect PICAXE to a PC?
We have the circuit diagram, all that is left is to connect the header pins to a serial computer cable. This can be done by using the PICAXE audio socket serial cable or you can make up your own connector to connect to a standard 9 pin serial cable. The following sketch (PICAXE Manual 1) shows how to connect the PICAXE to a cable for serial communication to a PC. There are four different methods to connect the PICAXE to a computer:


  1. Using a PICAXE serial download cable (AXE026) to connect the Comms Serial Port to the serial port on your computer, the 9 Way D male socket. If you use this method you will have to use a stereo audio socket on your Comms Serial Port as indicated in the top sketch above instead of the pin connector indicated in the diagram. The 9 Way D female socket of the of the PICAXE serial download cable connect to the 9 Way D male connector on your computer. 
  2. The second method is to use the PICAXE USB download cable (AXE027) to connect the Comms Serial Port to a USB port on your computer. Again you will need a Stereo socket like the PICAXE Stereo socket (CON039) on your Comms Serial Port instead of the pin connector.
  3. The third method is to use a standard serial cable with a 9 Way D female socket on the one end and 9 Way D Male socket on the other end. In this method you need to make-up a 9 Way D female socket on your Comms Serial Port as in the sketch above. 
  4. You can also make-up your own serial cable with a 9 Way D female connector on the one end to plug into the serial port on the computer and on the other end you can use just the wires to plug into a breadboard or any connector that will suit you. 
PICAXE Connection Serial ComPort on PC
Signal Pin Header Stereo Socket Port Signal D9 Pin
Serial Out 1 Shaft a RxD 2
Serial In 2 Ring b TxD 3
Ground 3 Tip c Gnd 5

 PICAXE Connection Summery

PICAXE Code to communicate with a PC
When one uses the resistor interface for serial communication as we have done above it is important to remember to use the SerOut command with the inverted (N) option. The following code can be used to send information out to a PC. In this example the serial in signal on port C.3 can be left out because we are only sending information out to the PC.

The information received on the PC from the PICAXE is shown below in the HyperTerminal application.

The next example shows how to receive information as a 5 character string from a PC and then echo the string back to the PC to be displayed in a RS232 communication program like Termite. 

The results is shown in the screen capture of the Kermit RS232 communication program. To test the program type in the 5 characters you want to send to the PICAXE in the bottom line in the Kermit application and press the ‘Enter’ key. The typed in characters will be displayed in blue and below it the characters received from the PICAXE is displayed in green. Make sure the Local echo option is selected to display the local characters in blue.

Serial Port Settings for Termite communication program
The following Port Settings needs to be selected for PICAXE serial communication:

  • Port – The comport used for serial communication.
  • Baud rate – 2400 (depend on your selected speed in the PICAXE program)
  • Data bits – 8
  • Stop bits – 1
  • Parity – None
  • Flow control – none
  • Forward – none