아두이노 모듈 질문합니다 !!

아두이노 모듈 질문합니다 !!

작성일 2018.05.23댓글 2건
    게시물 수정 , 삭제는 로그인 필요

아두이노 모듈 rn52  블루투스 모듈을 사용해서 프로젝트를 해보려고 하는데요.

rn52예시 코드가 없어서 hc06블루투스 모듈 코드를 이용해서 rn52를 사용하려고하는데 가능한가요?

물론 핀번호와 변수는 제가 지정하려고합니다. 그 코드 형태와 유형을 사용가능한지 궁금합니다~


#아두이노 모듈 #아두이노 모듈 종류 #아두이노 모듈 여러개 #아두이노 모듈 라즈베리파이 #아두이노 모듈 연결 #아두이노 모듈 연결방법 #아두이노 모듈 구매 #아두이노 모듈 추천 #아두이노 모듈 가격 #gps 아두이노 모듈

profile_image 익명 작성일 -

RN52 Arduino Library

The Doayee RN52 Arduino Library is a detailed library for use with the RN52 Bluetooth Audio module from Microchip. The library is designed for use with the features of the v1.16 firmware for the RN52 and allows for convenient communication with the RN52 module, using a microcontroller rather than a command line interface. This allows for much greater usability and the ability to run groups of commands, one after the other, on demand with minimal user input.

The vast majority of features available when communicating with the RN52 in "Command Mode" have been included in this library. All the relevant downloads are available above, a zip file containing the library itself, with example sketches included, and a PDF Library Command Guide. An online command guide is also available.




BAL - RN52 Development Board

We wrote this RN52 Arduino Library to be used in conjunction with our BAL – Bluetooth Audio Link, a feature rich RN52 development kit with on-board amplifier, and broken out pins. See its product page to purchase one. However, it can also be used with any RN52 module, using information found here.

If you have any queries or require support regarding the RN52 Arduino Library, please contact us using the BAL support pages.

https://doayee.co.uk/bal/library/

RN-52 Bluetooth Hookup Guide

Overview

The RN-52 Audio Bluetooth Breakout is a sleek Bluetooth audio module from Roving Networks broken out on an easy to use PCB. It allows you to send stereo audio over a wireless Bluetooth connection. The module has an embedded DSP that handles the audio stream entering and exiting the module, converting the digital wireless signals into audio and vice versa. The module is easy to configure with both ASCII commands and GPIO. It can function as a stand alone module, or it can be incorporated with a microprocessor to create the ultimate wireless audio experience.

Covered in this Tutorial

In this tutorial, we will go over some of the module’s features. We’ll show you how to configure the module to suit your projects needs, how to hook it up, and go over a simple example project using the RN-52.

Suggested Reading

The RN-52 Module

Before we get in to the breakout board, let’s discuss the module and its features.

As with any product, it is wise to read the datasheet before embedding this device into a project.

Bluetooth Version

The RN-52 is a Bluetooth v3.0 module. It is compatible with all Bluetooth v3.0 devices and also backwards compatible with all Bluetooth v2.1 + EDR, 1.2, and 1.1 devices.

Bluetooth Profiles

Here is a list of all the profiles that the RN-52 supports.

  • SPP - Serial Port Profile allows you to configure the device over a UART serial connection. This can also be used to send commands to the module from a microcontroller.
  • HFP/HSP - Support of both Hands-Free Profile and Headset Profile mean the module can act as a headset device. This allows the it to send audio back and forth, just like a Bluetooth headset. You can send audio input through a microphone and receive audio output through a speaker or headphones.
  • A2DP - Advanced Audio Distribution Profile sends audio in one direction, but the quality of that audio is better than the quality of HFP and HSP.
  • AVRCP - A/V Remote Control Profile allows you to control certain features of your audio through the module. Tasks such as Play/Pause, Volume Up, and Volume Down can be controlled by inputs on the module.
  • iAP - This is the iPod Accessory Protocol, and it allows you to connect the module to any Apple devices such as iPhones, iPods, and Mac laptops and computers.

*Note: Multiple profiles can be implemented at once. The default settings are set to have all profiles discoverable.

Range

The RN-52 is a Class 2 Bluetooth device, meaning that the range of the on board antenna is about 10m. Thus, you should be able to stream audio to the module from about 32 ft in open air. If you are streaming through walls or windows, that range will diminish.

Wireless Audio

The RN-52 is different than other Bluetooth modules in that it can stream audio. It does this via an on-board Digital Signal Processing (DSP) chip. When streaming audio to the RN-52, the DSP converts the radio waves sent from the transmitter device (phone, computer, etc.) into electrical signals that can then be sent to the amplifier and then to your audio output (speakers/headphones). When streaming audio from the module, it converts the electrical signals from the audio input device (mic/line-in) to radio waves for the receiver device (stereo, computer, phone).

Many people ask why it isn’t possible to send audio over just any old Bluetooth connection. The lack of an on-board DSP is the main reason most “regular” modules cannot support audio streaming.

Communication

Aside from a wireless Bluetooth connection, the RN-52 has four paths on which it can communicate to outside devices: UART, USB, SPI, and PCM. We’ll discuss these in more depth in the next section.

The RN-52 Breakout

There is a lot going on with the RN-52 breakout board. Let’s break it up into sections to find out what pins are needed for what purposes.

Here is the module broken up into sections by color (and numerically for the color-vision impared).

1. Power

Powering the RN-52 is very simple. There are three pins necessary to power the board, 3.3V, GND, and power enable (PWR_EN). The supply voltage should be in the 3.0 ~ 3.6V range.

2. GPIO Pins

The RN-52 has eleven general purpose input/output pins (GPIO). Many of these pins are reserved for special functions when the module is booted up and when the module is running. These pins also act as input pins for specific functions during audio playback. These can be configured to control media programs such as iTunes or Windows Media Player (eg. Play, Pause, Next Song, etc.).

This table shows each GPIO and its function.

The most important pin to take note of is GPIO9. If you are familiar with other versions of Roving Network’s Bluetooth modules, you may also be familiar with the $$$ command used to enter command mode on the module. On this module, however, there is only one way to enter command mode, by pulling GPIO9 LOW.

There is also one analog input/output line, AIO0.

3. USB

The USB lines are strictly used for device firmware update (DFU) mode. Used in conjunction with GPIO3, the USBD+ and USBD- lines allow you to upload new firmware directly to the RN-52.

4. UART

The UART lines are used to communicate with and configure the RN-52. Used in conjunction with GPIO9, the UART will allow you to send and receive serial commands to and from the module.

The UART can also be used to connect the module to an external microcontroller that issues commands and handles status updates.

5. Audio In/Out

These pins are reserved for audio input and output. The RN-52 comes ready to stream audio right out of the box. You can attach speakers directly to the speaker pins and get immediate gratification from wireless music. The RN-52 has a built in integrated amplifier capable of driving two 16Ω speakers or most standard headphones. The speaker outputs can also be attached to an external amplifier for greater amplification.

The RN-52 also supports audio input on the Mic pins.

6. Status LEDs

There are two status LEDs located on the breakout board. However, if you wish to place the board in an enclosure, these lines are broken out for external LEDs. The LEDs are configured as open drain output, meaning that they must be driven HIGH to activate the the LED.

LED0 LED1 Description
Flashing Flashing The RN52 module is discoverable.
Flashing Off The module is connectable.
Off Flashing The module is connected.

Note: Flashing refers to the LEDs flashing alternatively. If you see the LEDs flashing in unison, then you are in DFU mode. Please check pin 3 if you have entered DFU mode by accident.

7. SPI

External audio codecs can be sent over the SPI lines.

8. PCM

Another option for communicating with the module is the Pulse-Code Modulation (PCM) pins. PCM is a way to digitally represent sampled analog signals. This is done over an I2S connection. External audio codecs can be sent over these lines as well.

Hardware Setup

Before you can configure the module, some hardware needs to be connected. This section will cover the necessary hardware needed to work with the RN-52.

Materials Needed

Aside from an RN-52 Breakout, you will need the following:


Wiring the RN-52

In order to use the RN-52, you must first decide how you will connect external hardware to the breakout board. One option is to solder female headers to both sides of the breakout. Second, you can solder wire directly to the breakout. Another option, and the one that will be used in all the demos in this tutorial, is to solder straight male headers to the breakout so that it can be used in a breadboard.

Configure the Module

Now that you can actually power up the RN-52 and send it into command mode, let’s talk about changing the settings, and thus the behavior, of the Bluetooth module.

  1. Make sure the CMD Mode switch is in the OFF position (GPIO9 NOT shorted to GND).
  2. Turn on your RN-52.
  3. The two status LEDs should both stay solid for about 1 second and then begin flashing alternately.
  4. Your device is now ready to make a connection. Rather than connect over Bluetooth, the connection will be made over the serial UART.
  5. Open a terminal window on the port your RN-52 has been assigned (115200 Baud, 8,N,1).
  6. With the terminal open and connected to the RN-52, flip the CMD Mode switch to the ON position (GPIO9 shorted to GND). You should now see CMD appear in your terminal.

You are now in Command Mode!

To exit command mode, simply flip the switch back to the OFF position. You will see END appear in the window.

Streaming Tunes

Enough talk. Let’s stream some tunes! The RN-52 comes ready to begin streaming tunes from most any Bluetooth audio-capable device. However, to add external control functions such as play, skip, and volume, you’ll need to make a few small adjustments.

Hardware

Using the same setup from the Hardware Setup section, let’s add a few more pieces. By connecting a few buttons and some speakers, the RN-52 becomes a full-on music station and remote. The image below shows all the connections and the functions of each button.

The functions for each GPIO can be found in the datasheet.

Configuration

By default, the RN-52 does not have the AVRCP enabled. This is part of the extended features. When you type D to see the basic settings, you’ll notice a line that says ExtFeatures=XX, where XX is some hex value. As of this writing, the default firmware comes with the AVRCP buttons disabled. Future versions of the firmware may differ. Looking in the Command Specifications document, we find this table:

EK is the Evaluation Kit Roving Networks sells and comes with the AVRCP enabled by default.

Notice that bit 0 is the bit we need to enable to activate the AVRCP button functionality. Send the command S%,07(/r) to enable this bit while leaving the other two bits enabled. Then follow it up with a reboot – R,1(/r). You should now have AVRCP enabled. Type D to double check the settings.

That’s really the only setting that needs changed for this example.

Connect and Play

You are now ready to connect to your Bluetooth device and start streaming some music. Directions on how to pair and connect to the RN-52 can also be found in section 1.4 of the user guide.

Troubleshooting/Common Issues

Checking the Version Number

To check the version number of your RN52, you can use the “v” command. Make sure that you connect the 3.3V FTDI to the RN-52 as stated in the hookup guide for CMD mode: Rx <-> UART_Tx, Tx <-> UART_Rx, 3.3V <-> PWR_EN <-> 3.3V, GND<-> GND, and GPIO9 <-> GND. Using a serial terminal connected to the FTDI’s enumerated COM port (with setting 115200, 8-none-1-none). After typing the command, the RN-52 will respond with:

Upgrading DFU Firmware over USB

Note: Upgrade at your own discretion before proceeding!!! You might brick your module if you are not cautious!!!

If you are interested in upgrading the firmware on the RN-52s, you will need the USBD+, USBD-, GND and GPIO3 pins. The standard default v1.10 firmware on the RN-52s requires DFU over USB. After flashing the v1.16 (file rn52-i_rm116.dfu ), the RN-52 will have the ability to use DFU over UART.

Try looking at the RN52 Firmware v1.16 Release Notes for new additional features.

1.) Head to Microchip’s RN-52 Product Page .

2.) Download the RN52 Bluetooth DFU Utility Installer located under “Documentation > Software.” This will contain the application called MicroChip Bluetooth DFU Utility Installer.exe and a guide called RN52-EK DFU Procedure Guide.pdf . The guide was written for Microchip’s RN52-EK development board but there was no issues updating RN-52’s on our breakout board.

3.) Download the image of your choice below the software. You have the option of using “RN52-I/RM110 DFU Image” (saved as the rn52-i_rm110.dfu file) or “RN52-I/RM116 DFU Image” (saved as the rn52-i_rm116.dfu file).

4.) Unzip Microchip Bluetooth DFU Utility Installer.zip .

5.) Click on the Microchip Bluetooth DFU Utility Installer.exe to install.

6.) Follow the installation instructions in the installer. This will also install the driver for your Rn-52 audio bluetooth though USB.

7a.) Hardware Connection Connect a DFU Over USB Pins: USBD+, USBD-, 3.3V, PWR_EN, GND, and GPIO3 pins. You could use the a USB Mini-B Breakoutmini-B cable , and jumper wires. Since I already connected the 3.3V FTDI to the RN-52, I just used 3.3V and GND from the FTDI to the RN-52 for power. Make sure to connect GND of the USB Mini-B breakout with the GND of the FTDI so the reference is the same:

7b.) Power Cycle Power cycle the RN-52 so that the GPIO3 is HIGH at boot time. The green LED labelled (LED0) and red LED labelled (LED1) will blink simultaneously.

7c.) Launch the the “Microchip Bluetooth Device Firmware Upgrade Utility” software (i.e. MCHPDFUUtility.exe ).

7d.) You will be greeted with a note from Microchip. Click on the “Next >” button to begin.

7e.) Connection Type Selection Select “DFU over Universal Serial Bus (USB)” and click on the “Next >” button.

7f.) The software should automatically search for the device that is connected over USB. Your computer might pop up with a new device (For Windows, there was a popup in the notifications):

7g.) Upgrade Action Selection Select “Download a new version of the firmware, saving a copy of the current version first. Any previous saved version will be replaced. (Recommended.)” and click “Next >”.

7h.) Upgrade File Select the location of your file (i.e. rn52-i_rm116.dfu ). and click “Next >”.

7i.) Ready to Upgrade Verify your selections and click “Next >”. Your window might say something like this:

Note: Since the PWR_EN is connected to 3.3V already, you do not need to “hold the power button down” as stated in the guide for Microchip’s RN52-EK development board. The upgrade automatically started as soon as I pressed on the “Next >” button.

7j.) Upgrade in Process Make sure to not interrupt the power and connections during the firmware upgrade. There will be progress bars that indicate your progress. Depending on your upgrade selection, it will save the previous firmware, flash the new firmware, and verify the update on the RN-52.

7k.) Successful Upgrade Once finished, the utility will provide the total time it took to save your file and flash the new firmware. It took less than 5 minutes to upgrade the firmware:

There was also a verification process after flashing the new firmware. This should take about a minute to complete. Click “Finish” to complete the upgrade at the final screen.

7l.) Cycle Power Disconnect GPIO3 from 3.3V so that it is LOW. Power cycle the RN-52 by disconnecting and reconnecting power to 3.3V.

8.) If you are already connected to a serial terminal with a 3.3V FTDI and the RN-52 set to CMD mode, you can verify the version number by sending the “v” command. The RN-52 should respond with this output:

This should indicate that the firmware has been upgraded to the new firmware. Try testing out the new firmware by playing music from a smartphone. =)

Streaming Music and Phone Calls

When streaming music with the audio bluetooth and a call comes in, the smartphone will automatically stop the music and begin to ring until the call is answered/rejected. After answering or rejecting the call, the music will begin to stream again.

Useful mic design application notes for the RN-52

http://www.jenrathbun.com/Electronics/rn52-bluetooth-adapter-microphone/

http://www.microchip.com/forums/m770128.aspx

https://learn.sparkfun.com/tutorials/rn-52-bluetooth-hookup-guide/discuss#comment-5241d04ed3ae260a048b4567

Resources and Going Further

Wireless music, how sweet it is! We’ve only just scraped the surface of what the RN-52 is capable of. Try your hand at a project that incorporates the RN-52. You could create your own wireless headset. You could have a home theater system that can stream music from your mobile device. You could even connect an RN-52 to your car stereo and stream tunes from your phone as you travel. The possibilities are endless!

Resources

Here are all the documents listed in this tutorial:

Also, don’t forget to check out the RN-52 GitHub page for all the hardware files and info.

This site is a handy Bluetooth Class of Device (CoD) generator.

For more tutorial action, check out these related tutorials:


https://learn.sparkfun.com/tutorials/rn-52-bluetooth-hookup-guide?_ga=2.100686921.911818808.1527121116-139317065.1527121116


어떤 모듈을 가지고 있는지 모르겠지만
모듈 제조사 사이트의 자료부터 체크하세요





2018.05.24.

  • 답변확정

    질문자가 답변확정한 답변입니다.

도움이 되었다면 UP 눌러주세요!
UP이 많은 답변일수록 사용자들에게 더 많이 노출됩니다.

profile_image 익명 작성일 -

{{=it.contents}}

아두이노 블루투스 모듈 질문

동아리에서 아두이노 수업을 진행하려고 하는데 블루투스 모듈 혹은 적외선 리모컨을 사용하려고 하는데 혹시 방 같이 작은 곳에서 20명정도가 사용하려고 하면 막 신호가...

아두이노 물 분사 모듈 질문

... 해당 물 분사 모듈아두이노와 직접적으로 연결하여 사용할 수 있습니다. 우선, 모듈의 전원을 공급해주어야 합니다. 모듈은 12V DC 전원을 필요로 하므로, 아두이노...

아두이노에서 릴레이 모듈을 통한 AC...

... 혹시 제가 그린 회로대로 사용해도 괜찮을지 알고자 질문 드립니다 ! 퓨즈의 위치는... 릴레이를 자세히 보면 위에 전류용량이 적혀 있습니다 .보통 아두이노모듈의...