Elastic Sheep

Because elasticdog was already taken

Elastic Sheep header image 1

Current project

September 27th, 2011 · Uncategorized

I am currently building a “baby phone” toy for my son based on a discarded landline phone enclosure. The toy will feature record and playback on SD card to allow family members to record messages on the device. Voice messages would be played back when pressing a key of the original phone keyboard.

The plan has been to reuse as much of the old phone as possible : speaker, microphone, keyboard.

The prototyping began on a Teensy2 board starting from my previous WAV player project. It has now moved on an ATmega328 because USB Mass Storage is not required and I want to keep my Teensy for other projects.

Hardware is done. Software is almost done. I am now soldering the design on a veroboard to fit it inside its final case.

More details and pictures to come…

→ No CommentsTags:·

Bluetooth module breakout boards are back in stock

September 26th, 2011 · Uncategorized

My initial production was only a short run to prototype the board for my personal use.

Having sold out the stock and seeing the interest for the board, I have ordered a new batch that is now available for sale.

The price at Olimex was interesting for prototyping but not for producing greater quantity. This new batch has been produced by PCBCart instead with same specification.

Order your board in the shop page.

→ 1 CommentTags:··

Serial Bluetooth module – Master/Slave connection

May 20th, 2011 · Uncategorized

I have soldered a second serial Bluetooth module. I am now going to test them in a master/slave configuration.

The test boards

The first test board is the one already used for my slave test with a Teensy 2 as USB to serial adapter and power supply. This board will be the master one.

The second test board is powered by a USB connector and a 3.3V regulator. A serial connection is establish with my laptop through a Prolific PL2303 adapter. This board will be the slave one.

Slave module configuration

The slave module is powered up in command mode. Cu does not seem to work correctly anymore with the PL2303 so I use screen instead:

$>screen /dev/cu.serial 38400
AT+ADDR?
+ADDR:11:3:252002
OK
AT+UART?
+UART:9600,0,0
OK
AT+ROLE?
+ROLE:0
OK

Role=0 is for the slave mode. I keep the default 9600 baud UART speed.

The module Bluetooth address will be useful to establish the connection from the master module.

Master module configuration

The master module is powered up in command mode. The role is changed to 1 for master. The UART baudrate is set to the same as the slave module.

$>sudo cu –s 38400 –l /dev/cu.usbmodemXXXX
AT+UART?
+UART:115200,0,0
OK
AT+UART=9600,0,0
OK
AT+UART?
+UART:9600,0,0
OK
AT+ROLE?
+ROLE:0
OK
AT+ROLE=1
+ROLE:1
OK
AT+ROLE?
+ROLE:1
OK

To establish an automatic connection to a slave module, the master module must know the slave address. This is configured with the AT+BIND command with CMODE=0 (Use a predefined address).

AT+CMODE?
+CMOD:0
OK
AT+BIND=11,3,252002
OK
AT+BIND?
+BIND:11:3:252002
OK

With CMODE=1, the master can connect to any device in its transmission range, so it is a much less secure configuration.

Master/Slave automatic connection

Now that the two modules are setup, I power up them in automatic mode (PIO11 = 0).

On each module, the red leds connected to PIO8 blinks quickly. After less than 2 seconds, the green led connected to PIO9 is shining on both modules indicating that they are now paired and connected, ready to transmit data.

I connect a terminal to the serial port of each module with their respective adapter to test the communication:

The first window displays the connection to the master BT module. The second window displays the connection to the slave BT module.

The connection is successful at 9600 bauds. I also successfully tested the communication at 115200 bauds.

→ 16 CommentsTags:···

Serial Bluetooth module slave test

May 8th, 2011 · Uncategorized

I am going to test the connection of a serial Bluetooth module to my Mac laptop. Serial data will be provided to the module through a Teensy 2 used as a USB-to-Serial adapter.

Soldering the module on a breakout board

The difficulty is to correctly align all the module pins to the breakout pads. The module is so light that it can moves just because of the solder surface tension.

Two rows of header are added to fit in a prototyping breadboard.

Teensy 2 USB-to-Serial profile

I use the USBtoSerial project from LUFA 101122.

I already covered how to compile this project for the original Teensy in this previous post (Testing the LUFA USB Serial with GPS data). I apply the following modifications to the makefile:

MCU = atmega32u4
F_CPU = 16000000   

Here is the binary: Teensy2-USBtoSerial.hex

To connect to the virtual serial port on a Mac:

$> sudo cu –s 9600 –l /dev/cu.usbmodemXXXX

A quick loopback test (direct wire from TX to RX) confirms that the profile is correctly working.

Useful to exit cu: ~.

Connections between the Teensy 2 and the BT module

The TX pin of the BT module is connected to the RX pin of the Teensy 2, and the RX pin on the TX pin.

My Teensy 2 board has been patched with a 3.3V regulator (see Converting the Teensy2 to 3.3V). I will use it to power the BT module.

The TX pin of the BT module is connected to the RX pin of the Teensy, and the RX pin on the TX pin.

Two leds are connected on PIO8 and PIO9 to display the status of the BT link.

The PIO11 pin is used to select the boot mode:

  • High => Command/Response mode where you can issue AT command to setup the module.
  • Low => Slave or master automatic operation.

Module configuration

I connect the PIO11 pin to the 3.3V rail. In this mode, the baud rate is 38400.

I open a cu session in the terminal and communicate with the BT module over its serial interface:

$>sudo cu –s 38400 –l /dev/cu.usbmodemXXXX
Connected.
AT
OK
OK
OK
OK

The module sends the OK response repeatedly. Sending Ctrl-C can stop it. Then you can enter another commands.

AT+VERSION?
+VERSION:2.0-20100601
OK
AT+NAME?
+NAME:HC-05
OK
AT+ADDR?
+ADDR:11:3:252009
OK
AT+UART?
+UART:9600,0,0
OK

We can see that the module is currently configured for 9600 bauds operations with 1 stop bit, no parity.

I speedup the baudrate to 115200 bauds.

AT+UART=115200,0,0
OK
AT+UART?
+UART:115200,0,0
OK

I also change the role to slave-loop. In this mode, the module sends back all data it receives over the BT link. It is useful to check that the module can correctly receive and send data over the BT link before connecting it to your system.

AT+ROLE=2
OK
AT+ROLE?
+ROLE:2
OK

Now I power up the module with the PIO11 connected to GND to boot in autoconnect mode.

Pairing with a Mac

The connection of Bluetooth devices is handled by the System Preferences/Bluetooth panel.

The connection fails because the default passkey of the module is 1234. It can be changed with the AT+PSWD command.

The module is now successfully paired with the Mac but currently not connected.

It is recognized as a virtual serial port and corresponding devices are automatically created in the /dev directory:

$> ls /dev/*HC*
/dev/cu.HC-05-DevB	/dev/tty.HC-05-DevB

Slave-loop connection

I can now connect to the BT device and use it as a classic serial interface. In slave-loop mode, the characters are echoed back to the terminal.

$> sudo cu –s 115200 –l /dev/cu.HC-05-DevB
Connected.
ABCDEFGHIJKLM

The status of the bluetooth connection is reflected in the System Preferences panel.

Slave mode

I switch to the command/response mode and change back the role to slave:

AT+ROLE=0
OK
AT+ROLE?
+ROLE:0
OK

In this mode, the BT module acts as a full duplex serial interface. The data received over the BT link are forwarded to the its TX pin, while the RX pin incoming data are sent over the BT link.
So to test the connection I open two cu sessions. One is connected to the BT module, the other one to the Teensy 2 serial emulation. As the 2 devices serial pins are connected together, I am able to send characters on one session and receive them on the other sessions.

The first window displays the connection to the Teensy 2. The second window displays the connection to the BT module.

→ 20 CommentsTags:····

Bluetooth module breakout boards received

May 2nd, 2011 · Uncategorized

Go to the Shop page if you want to get one.

→ No CommentsTags:··