Posts tagged ‘serial’

Communication with Pinguino via Bluetooth

I bought a BlueSMIRF Bluetooth module a few weeks ago, and this weekend I’ve finally had some time to put it in action 🙂

Connecting the BlueSMIRF module is really easy. The BlueSMIRF module has 6 pins: CTS-I, VCC, GND, TX-0, RX-1 and RTS-0. You have to connect CTS-I to RTS-0, connect VCC to the supply voltage and GND to ground. The TX-0 pin is connected to the RX pin of the microprocessor, while the RX-1 pin is connected to the TX pin of the microprocessor. On the PIC18F4455 these are pins 26 and 25 (pinguino pins 9 and 8). s

CTS-I  O----------------
VCC    O--5V           |
GND    O--0V (gnd)     |
TX-0   O-- to RX PIC   |
RX-1   O-- to TX PIC   |
RTS-0  O----------------

As explained in a previous post, I am using a Pinguino board, so the code should work on Arduino as well without needing too many modifications. This is the code I used for writing some text:

#define PIC18F4550
char incomingByte = 'K';	// for incoming serial data

void setup() {

void loop() {
	// send data only when you receive a C character
	if (Serial.available() > 0) {
		// read the incoming byte:
		incomingByte =;
		if (incomingByte == 'C') {
			Serial.print("I received: ");
			Serial.print(incomingByte, DEC);
In the setup routine I connect to the serial port at 115200 bauds. The bluetooth module is just used as a regular serial cable, so no fancy tricks are necessary.
On my Ubuntu laptop, I had to do the following to get things running:
  • first connect your Bluetooth dongle to the BlueSMIRF (mine appeared as FireFLY-719A)
  • sudo hcitool scan #so we know the MAC address of the FireFLY
  • rfcomm connect 0 00:06:66:03:72:9A #substitute with your BlueSMIRF’s MAC address
  • sudo gtkterm -p /dev/rfcomm0 -s 115200 #start gtkterm to read/write to the serial port

Of course we don’t want to interact through gtkterm with our microcontroller. I wanted to employ Processing, but this gave some additional difficulties in my setup. In Processing, Serial.list() is used to list all available serial ports. The Bluetooth serial port /dev/rfcomm0 does not appear in the list though. A dirty hack to solve the issue is symlinking /dev/ttyS0 to /dev/rfcomm0:

sudo rm /dev/ttyS0
sudo ln -s /dev/rfcomm0 /dev/ttyS0

If anyone knows a better way to solve the issue, please mention so in the comments! This is the Processing code:

import processing.serial.*;

Serial myPort;                // Create object from Serial class

void setup()
  size(200, 200);
  myPort = new Serial(this, Serial.list()[0], 115200);  //the first port in the list is /dev/ttyS0 which we symlinked to /dev/rfcomm0

void draw()
  while (myPort.available() > 0) {                      //if something was received via serial port
    String inBuffer = myPort.readString();

void keyPressed() {

void stop() {

February 22, 2010 at 6:12 pm 3 comments

Serial com-port communication with autoIt

This weekend I found out how to read from / write to a com port with autoIt code. I created a file with some functions that read/write single characters or lines. To communicate with a com port, I use the CreateFile function from Kernel32.dll.

Continue Reading December 7, 2008 at 5:12 pm 13 comments


Articles to be written…

Twitter – kr3l


RSS Google Reader Shared Stuff

  • An error has occurred; the feed is probably down. Try again later.

RSS Listening to..

  • An error has occurred; the feed is probably down. Try again later.