Bluetooth Stuff

Everybody loves the bluetooth nowadays. I learned what Bluejacking is at E-tech this year. As a wise woman pointed out to me: “Bluejacking, that’s what teenage boys do in the privacy of their bedrooms, right?” Similar enough.

Mike Sharon pointed out this little BT accelerometer board. I’d change the PIC for an 18F, but it’s really nice. The radio on it can be found here.

Here’s parallax’ EmbeddedBlue module.

I have a Promi SD 102 and the Promi ESD from Initium. They’re nice. They’ve got a distributor in Connecticut, Lemos:

Lemos International Co. Inc.
1305 Post Road
Suite 305
Fairfield, Ct. 06430
TEL: 203-254-1531
FAX: 203-254-7442

A note on the Promi SD: Jamie Allen got this from the folks at Initium:

“If you want to use Promi-SD with Tx, Rx, and ground pins only, you have to disable hardware flow control feature on Promi-SD.
The AT command for this is:

AT+UARTCONFIG, baudrate, parity, stopbit, flow control

For example, if you use 9600 bps, no parity, one stopbit, no hardware flow control, then command is


Or, you may do same job at Promi-WIN(v3b) software.”

I also have the EmbeddedBlue board from Parallax. Also nice, but the form factor’s harder to work with on a breadboard.

Here’s another one,

Mark Argo turned me on to blueRadios as well. They offer a version for those who want to write their own Bluetooth stack, which is worth the extra cost if you’re looking for custom functions.

Anyone got more of them? I want easy ones, something I only have to send AT commands to via a serial port, at worst. The less soldering, the better, as long as it’s cheap. I want world peace too.

Sound in to a Microntroller

Microcontrollers can take sound in as an analog input, for crude measurements. While 8-bit ones  (the Basic Stamp, BX-24, PIC, Arduino, etc) are not fast enough to read the frequency difference between various sounds, they can read sound levels. A line-level audio signal (which is what a typical CD or MP3 player produces) varies between -1V and 1V, a range of 2V total. If you raise that up so that it varies between, say, 3.5V and 1.5V, you can read it using the analog input on your microcontroller

First, if you have a microphone, you won’t be able to connect it directly. A microphone’s voltage, known as mic level voltage, is only a few millivolts at best. If you put it through a preamp such as a mixer board, or through an amplifier, you get a line level signal, which you can read.

A simple way to do this is to buy a preamplifier kit, something like the Velleman K1803 Universal Mono Preamplifier from Jameco (part no. 117612). For $8.95, it’ll save you some troubleshooting time, and cost about as much as the circuit below. Or you can build your own.

The following circuit uses a Condenser microphone element from Radio Shack (part no. 270-090C) and an amplifier chip also from Radio Shack (LM386 Audio Amplifier). The amplifier raises the microphone’s signal so it’s within line level tolerances, -1V to 1V. To raise that to a 1.5V to 3.5V range, we use a voltage divider (the two 100K resistors). Normally, the voltage between the resistors would be 2.5V (since their resistance is equal). When we add in the line level signal, we get 1.5V to 3.5V.

Note that the 10K variable pot is using all three pins of the potentiometer. The center pin goes to pin 2 of the amplifier, the end pins to the mic and pin 3, respectively. The variable resistor is your volume knob. I used an audio taper pot, since I wanted the curve of the pot to follow the sound’s volume.

Note that the capacitors are polarized electrolytic capacitors, so it matters which way they face.

In the BX-BASIC code, I found my base value (when all was silent) was about 512. So I subtracted that, took the absolute value of the result (so that negative numbers would always read as positive), and got a sound level varying between about 1 and 500. You may need to adjust these values depending on your setup.

dim soundIn as integer

Sub main()
    call delay(0.5)  ' start  program with a half-second delay 

        soundIn = abs(getADC(13)- 512)

        debug.print "soundIn = " ; cStr(soundIn)

End Sub

Here’s the same code in Wiring/Arduino:

void setup() {

void loop() {
	// read the audio in on analog 0:
	int soundLevel = analogRead(0) -512;
       Serial.print( "soundIn = ");
	Serial.println(soundLevel, DEC);

Java for the PIC

Muvium is a java VM for the PIC. The only problem is, you can’t just buy the software, you have to buy PICs from them with the VM already loaded on. You can also buy a certificate that allows you to bootload the java VM on your own PICs.