Configuration of RN52 through Simblee (RFD77101)

Simblee (RFD77101) is one of the best BLE (Bluetooth Low Energy) chip that turns your project into the IoT. Since I have learned how to use the Simblee, I have come up with the idea that I connect Simblee into RN52 (Audio Bluetooth) to make my project more fun. The first step that I needed to do was whether I could do the configuration of RN52 through a Simblee chip, so I will introduce how to configure it by using UART and display the configuration on the Simblee App based on the commands you input.

Normal Configuration

In order to do the normal configuration that you can find in Sparkfun tutorial of RN52, you need to use a FTDI chip with USB to communicate with a serial UART through a USB port.

You are supposed to get the configuration like this (From Sparkfun).

Configuration on Simblee App

However, what if you would like to display the configuration of RN52 on Simblee App through RFD77101, the process will be different. Here is the simple sketch of this project. FTDI chip is connected to RFD77101 using UART (RX is 25 pin & TX is 23 pin as a default), and by connecting RFD77101 and RN52 using GPIO17 & GPIO19 as RX & TX), you could do the serial communication between these chips.

Source Code

 

Results

This is the UI on Simblee App.

When SMD mode started (GPIO9 pin shorted to GND).

When a command “D” was input in field1. However, I was supposed to get more than 68 bytes (As you can see, when you do the normal configuration on Terminal, the number of characters is more than 68 characters.) I need to study more about how to use a buffer, and fix this problem.

When a command that does not exist was input.

There are a lot of available commands that you can see. This project succeeded! Thanks.

 

Arduino Nano + RN52 + TPA2016D2 Experiment

It has been over a year since I have been working on the audio things. The previous experiment, I used an amplifier called TPA2016 which can amplify an audio data from a 3.5mm headphone wire connecting a phone. However, I really wanted it to be a wireless which can send the audio data, and I finally found the one called “RN52” which is an audio bluetooth module.

RN52 Test

In the Fritzing image above, I did an initial test with this RN52 module and an 8Ω speaker ( 16Ω speaker should have been used according to the data sheet, but it is actually not big deal.) with an Arduino Nano for UART communication and as a voltage supplier from my computer which is 5V. The initial test worked perfectly and I heard sounds, but there were some problems.

  1. The sounds were NOT really amplified.
  2. It could not control a gain from your Phone.

In order to solve these problems, I decided to use an TPA2016 which is the stereo class D amplifier with a gain control. By using the amplifier, I could amplify the audio sounds to around 30 dB, and I could control the gain from my phone which means I could adjust the sound volume in my phone. The TPA2016 module could solve these problems once.

Here is the new Fritzing image.

Fortunately, RN52 had 4 pins audio outputs and TPA2016 had 4 pins audio inputs, thus by connecting between these modules, the audio data coming from RN52 as outputs is going into the TPA2016 as inputs. In this video, I am showing how to connect the Bluetooth module and your phone, and how it works.

Bone Conduction Speaker Experiment using I2C

The more things I studied about TPA2016, the further curiosity I had got such as what is going to happen what if I connect bone conduction speaker instead of a speaker. In addition, while reading the data sheet of TPA2016D2, I had been stuck on some words which were Automatic Gain Control (AGC) and Dynamic Range Compression (DRC) because I have never heard of these words before. However, these words DRC and AGC seem to be really important to know to do the further experiment like the aim of this tutorial which is the experiment of bone conduction speaker using I2C.


○About AGC and DRC

Automatic Gain Control is able to make an output signal constant despite its input signal. For example, when multiple people use a microphone at the same time, the sound input levels are different because some of them might be farther than other people, but some of them might be using the microphone closer. In this case, AGC automatically adjusts the input level and makes the output level constant. The point is, the weaker input signal is, the stronger output signal is, and the stronger input signal is, the weaker output signal is. In addition, the gain on the TPA2016D2 can be selected -28dB to +30dB. Of course, -28dB outputs a silent sound and +30dB can output a louder sound.

Dynamic Range Compression is able to prevent a clipping noise when the sound volume is extremely high by compressing the dynamic range of audio signal and speaker. In addition, DRC can automatically adjust the audio signal level for the sound range that you want.


Once you understood these words, let’s get started with bone conduction speaker using I2C experiment.

○Requirements

・Bone Conduction Transducer

img_3669

・TPA2016

s__41000966

・3.5mm Headphone Jack

s__40984581

・3.5mm Audio Cable

s__40984584

・Arduino Uno

s__40984579

・A breadboard

s__40984582

・Some Jumper Wires

img_3670


○Circuit Diagram

bone-conduction-speaker-circuit-diagram

Assembly the components by following this circuit diagram. Remember that the goal of this experiment is to use I2C. I2C pins on the Arduino are A4 pin (SDA) and A5 pin (SCL), so connect each pin to the pins on TPA2016.


○Programming

Before you look up the code below, you should download two libraries which are wire library and TPA2016 library. (Go to Arduino IDE -> Sketch -> Include library -> Manage Libraries -> Search these libraries and download them). After restarting Arduino IDE, go to File -> Example -> then you see “Adafruit TPA2016 Library and click on it. You will get the exactly same code below.

In the serial monitor, you should get this result.

TPA2016 Audio Test
Gain = -28
Gain = -27
Gain = -26
Gain = -25
Gain = -24
Gain = -23
Gain = -22
Gain = -21
Gain = -20
Gain = -19
Gain = -18
Gain = -17
Gain = -16
Gain = -15
Gain = -14
Gain = -13
Gain = -12
Gain = -11
Gain = -10
Gain = -9
Gain = -8
Gain = -7
Gain = -6
Gain = -5
Gain = -4
Gain = -3
Gain = -2
Gain = -1
Gain = 0
Gain = 1
Gain = 2
Gain = 3
Gain = 4
Gain = 5
Gain = 6
Gain = 7
Gain = 8
Gain = 9
Gain = 10
Gain = 11
Gain = 12
Gain = 13
Gain = 14
Gain = 15
Gain = 16
Gain = 17
Gain = 18
Gain = 19
Gain = 20
Gain = 21
Gain = 22
Gain = 23
Gain = 24
Gain = 25
Gain = 26
Gain = 27
Gain = 28
Gain = 29
Gain = 30
Left off
Left On, Right off
Left On, Right On
Setting AGC Compression
Setting Limit Level
Setting AGC Attack
Setting AGC Hold
Setting AGC Release


○Result

The sound from bone conduction speaker worked well! While the gain increases from -28dB to +30dB, the sound correspondingly becomes louder and when the speaker does not touch anywhere, you cannot hear any sound. Which means I2C also worked well between TPA2016 and Arduino. Pretty cool!

Lastly, check and watch the result video below.

Adafruit TPA2016 with Arduino

When I have been looking around a website called Adafruit, I could find an interesting board which made me excited and buy it immediately. Until TPA2016 ships to my home, I was googling how to use it. However, I could not find the simple tutorial which is used with Arduino, so I am trying to show you my experiment about TPA2016 with Arduino.

○Requirements

・TPA2016 (Stereo 2.8W Class D Audio Amplifier)

s__40984580

・Arduino Uno

s__40984579

・3.5mm Stereo Headphone Jack

s__40984581

・3.5mm Audio Cable

s__40984584

・A Speaker ( 8rm, 0.5W )

s__40984585

・A Breadboard

s__40984582

・Some Jumper Wires

s__40984583


○Assembly

s__40992771There are 10 pins on the TPA2016, so combine with the male headers which come with the kit from Adafruit to the 10 pins. Besides that, there are two terminal blocks in the kit, so do the same as the males headers. After all, solder them to completely connect with the TPA2016.

(The terminal blocks might not be required because it depends on what types of speaker you have. In my experiment, I use the speaker above, so there is no way itself can connect to the terminal block, so I am NOT going to use that.)


 

s__41000963

 

The setup looks like this. Put the TPA2016 and 3.5mm Headphone Jack on a breadboard.

 

 

 

 


○Circuit Diagram

s__41000965

I wrote the circuit diagram that is easier to see how it looks like. In this circuit diagram, the Arduino could be working as a power supply (5V).


s__41000964

If you can connect everything correctly, you get a similar one like the image above. Well, the phone that is being connected with the 3.5mm headphone jack was supposed to be on the image… But I took the picture by using the phone, so it is not on there.

I could make a sound through my phone, but the sound was very small and the sound quality was horrible. Do you have any advice to make this experiment better? If so, let’s discuss about this topic in the comment area.

 

How to use WTV020SD with Arduino

I have been working on my personal project which is about how to make a sound on WTV020SD with Arduino for a couple of days. I could not find any solutions of it on Google. However, I finally found it out with the simplest way EVER! SO I am going to talk about how to use WTV020SD with Arduino on this article.


What you need

  1. Arduino Uno

S__34267138

2. A USB cable (Type A to B)

S__34267145

3. A Breadboard

S__34267139

4. Sparkfun Audio-Sound Breakout WTV020SD

S__34963458

5. Kingston MicroSD Card (2GB)

S__34963460

6. Mini Metal Speaker (8orm, 0.5W)

S__34963459

7. 7 Jumper Wires

S__34963461


◯What you set up

  1. First of all, you have to convert your .wav or .mp3 audio file to .ad4. If you are a Mac user, you should use a Windows computer to convert it. Here is the link about how to convert (http://www.buildcircuit.com/how-to-convert-mp3-and-wav-files-to-ad4-format-wtv020sd-tutorial/) I am not going to talk about the details about it in this tutorial.
  2. You should change the name of the audio file to ad4 format such as 0000.ad4 because the file will be read from 0000.ad4.
  3. Connect from the 5V PIN on your Arduino to the VCC on your WTV020SD by using a jumper wire.
  4. Connect from the GND PIN on your Arduino to the GND PIN on WTV020SD by using a jumper wire.
  5. Connect from 6 PIN on your Arduino to PLAY PIN on WTV020SD by using a jumper wire.
  6. Connect from 5 PIN on your Arduino to BUSY PIN on WTV020SD by using a jumper wire.
  7. Connect from 4 PIN on your Arduino to DIN PIN on WTV020SD by using a jumper wire.
  8. Connect from 3 PIN on your Arduino to DCLK PIN on WTV020SD by using a jumper wire.
  9. Connect from 2 PIN on your Arduino to RESET PIN on WTV020SD by using a jumper wire.
  10. Connect the between SPK+ and SPK- PIN and Mini Metal Speaker.

audio schematic


◯The Code

In this tutorial, I am just showing about how to make a sound you want by using PLAY. I am not showing about changing a sound or making a sound back or anything like that.


◯The Result