# uC to host Bluetooth module via UART

I am a newbie. I am trying to finish a school project, I need to transmit an analog signal to the computer via Bluetooth.

I am using Bluegiga WT12 as the Bluetooth module, and I want to use it with SPP profile. I need to host this module with a uC, which will send iWRAP5 instructions via UART to control the module and send data via UART.

The signal has bandwidth around 4000 Hz, thus I need to convert it to digital with a rate of 8000 samples per seconds at least.

My question, since I am not familiar with uC's around,

1. what should I look in a uC to fulfill my project? (other than ADC and UART interfaces)

2. With that how can I use the uC as a host in the UART connection? (the wiring and the software?)

You haven't specified one of the more important ADC parameters, which is the number of bits of resolution. This selects the magnitude of your quantization error. ADC's typically come in 8, 10, 12 and 16 bits. 16-bit ADC's are fairly rare. So I looked for chips with 12-bit ADCs.

A sampling rate of 8000 samples/sec should not be an issue. For example, the Microchip PIC24EP256GP202, which costs just $5.41 in single quantities from Digi-Key, has a multi-channel 12-bit ADC that can sample at 500,000 samples/second, obviously way more than you need. It also has 256KB of flash and 32KB of RAM, and two UARTs, so you can use one to connect to the WT-12 (you just need to use cross connected the TX and RX pins between the WT-12 and the PIC), and use the other if desired to connect to a terminal program on the PC for debugging output. Because of your proposed sampling rate of 8000 samples/sec, if you use two bytes for each 12-bit sample, this would require a serial bandwidth of 8000 * 2 * 10 bits (for 8N1 serial protocol), or 160,000 bps. This is obviously higher than the default baud rate of 115,200 for the WT-12. However the WT-12 can run up to 3M baud, and the PIC24 can go higher than that. So this is not a problem after all. So I suggest picking a baud rate of 460,800. If you chose to use an 8-bit ADC (which I do not recommend), you could get by with the default 115,200 since you would only be sending one byte of data, or half the bandwidth of the above (80,000). This PIC24 is available in a DIP package, which makes it easier to prototype with. For programming, you will need to get a PIC-compatible programmer, such as the PIC kit3. (This is the least expensive one made by Microchip; there may be some third-party ones you can also buy.) There is a free compiler available for the PIC24 that is free from Microchip; the only difference between the free one and their paid one ($495) is the free one doesn't do any code optimization. But since the processor runs at 70 MIPS, that won't be an issue in your case. You will also need to download the MPLABX IDE, which is free.

1: Other than ADC and UART interfaces, as you said, I am thinking of the memory size of the uC (so the program you write can fit on it) and its maximum clock speed. A rate of 8000 samples per second seems a high requirement to me, so you should choose a fast uC. You also need to take into account the ADC resolution (how much precision you need for your measurements).

Here you see some calculations you need to do in order to know how fast you need your microcontroller to run. They don't have the same values as yours, but you can get a picture: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=119916&start=0

However there are many other things you should look in to choose a uC. The list can be very long, but here are some hints:

• Price
• Power consumption
• Development tools

2: UART wiring is pretty simple. There are just three lines (GND, TX and RX) and their wiring is straightforward: -WT12 TX pin to MCU RX pin -WT12 RX pin to MCU Tx pin -WT12 GND pin to MCU GND pin

For the software it depends on which uC you are using but the code should be similar. You can take a look to any Arduino tutorial for UART communication (it is a good starting point). They are based on ATMEGA microcontrollers.