Sunteți pe pagina 1din 11

Bluetooth HC-05 and HC-06 pinout

Since HC-05 and HC-06 Bluetooth use the same chip and pin number are only different in
Master / Slave configuration, Here is the pinout diagram of Bluetooth HC-05 and Bluetooth
HC-06.

Table Description pinout Bluetooth module

1
Pin
Pin Name PAD Type Description
Number
CMOS output, tri-stable with
1 UART_TX UART Data output
weak internal pull-up
CMOS input with weak
2 UART_RX UART Data input
internal pull-down
CMOS input with weak
3 UART_CTS UART clear to send, active low
internal pull-down
CMOS output, tri-stable with
4 UART_RTS UART request to send, active low
weak internal pull-up
5 PCM_CLK Bi-directional Synchronous PCM data clock
6 PCM_OUT CMOS input Synchronous PCM data output
7 PCM_IN CMOS input Synchronous PCM data input
8 PCM_SYNC Bi-directional Synchronous PCM data strobe
9 AIO0 Bi-directional Programmable input/output line
10 AIO1 Bi-directional Programmable input/output line
CMOS input with weak Reset of low.input debouncde so must
11 RESET
internal pull-up be low for >5MS to cause a reset
Integrated 3.3V(+) supply with On-
VCC 3,3
12 3,3V chip linear regulator output within
Volt
3.15-3.3V
13 GND VSS Ground Pot
14 NC - -
15 USB D- Bi-directional -
CMOS input with weak Chip select for serial peripheral
16 SPI_CSB
internal pull-up interface, active low
CMOS input with weak
17 SPI_MOSI Serial peripheral interface data input
internal pull-down
CMOS input with weak
18 SPI_MISO Serial peripheral interface data output
internal pull-down
CMOS input with weak
19 SPI_CLK Serial peripheral interface clock
internal pull-down
20 USB D+ Bi-directional -
21 GND VSS Ground Pot
22 GND VSS Ground Pot
Programmable input/output line,
23 PIO0 Bi-directional RX EN
control output for LNA (if fitted)
Programmable input/output line,
24 PIO1 Bi-directional TX EN
control output for LNA (if fitted)
25 PIO2 Bi-directional Programmable input/output line
26 PIO3 Bi-directional Programmable input/output line
27 PIO4 Bi-directional Programmable input/output line
28 PIO5 Bi-directional Programmable input/output line

2
29 PIO6 Bi-directional Programmable input/output line
30 PIO7 Bi-directional Programmable input/output line
31 PIO8 Bi-directional Programmable input/output line
32 PIO9 Bi-directional Programmable input/output line
33 PIO10 Bi-directional Programmable input/output line
34 PIO11 Bi-directional Programmable input/output line

Arduino Bluetooth shield.

433MHz Lora Ra-02 Arduino with Switch


and LED
Irone Chank December 25, 2017

3
In the previous article, we discussed Basic how to sending and receiving data on wireless
communication using 433MHz Lora Ra-02 and Arduino Uno. So in this discussion, will be
developed by adding switches and LEDs. The working principle in this debate, ie when the
switch in circuit 1 (transmitter) is pressed, arduino will send a message to circuit 2 (receiver)
via Lora radio communication. In circuit 2 when there is incoming data from circuit 1 which is
then captured by Lora module in circuit 2 then go into Arduino and continued LED will light
up then off. For more details like in the following block diagram picture:

Electronic component materials are used as follows.


 Arduino Uno: 2 pieces.
 433MHz Lora radio RA-02: 2 pieces.
 Switch: 1 piece.
 LED: 1 piece.
 Resistor: 2 pieces.
 Project Board: 2 pieces.

The circuit diagram 433MHz Lora Ra-02 Arduino.


For the first circuit or data sender, there are some electronic components, such as 433MHz Lora
radio RA-02, Arduino, switches, and resistors. Schematic wiring diagram as follows.

4
For second circuit or data receiver, there are some electronic components, such as 433MHz
Lora radio RA-02, Arduino, LED and resistor. Schematic wiring diagram as follows.

Arduino Code for transmitter and receiver.


When the switch in circuit 1 is pressed then the switch will send a high logic signal to arduino,
then arduino will send a text message through lora module and sent to circuit 2. In circuit 2
lora radio ra-02 take data from circuit 1 and then processed by arduino then turn on led then
lapse 1 second killed.

In this experiment, there are two scenarios for text messages sent from series 1 to series 2. It is
the first one-letter text format, the second one with the text format with one sentence.

5
The first scenario, when the switch is pressed then arduino in circuit 1 sending packet “1” in 1
letter text format, here is arduino code.

#include <SPI.h>
#include <LoRa.h>

int btn = 3;

1 #include <SPI.h>
2 #include <LoRa.h>
3
4 int btn = 3;
5
6 void setup() {
7 Serial.begin(9600);
8 while (!Serial);
9
10 Serial.println("LoRa Sender");
11
12 if (!LoRa.begin(433E6)) {
13 Serial.println("Starting LoRa failed!");
14 while (1);
15 }
16
17 LoRa.setSpreadingFactor(10);
18 LoRa.setSignalBandwidth(62.5E3);
19 LoRa.crc();
20
21 pinMode(btn, INPUT);
22 Serial.println("Push the button switch for send packet");
23 }
24
25 void loop() {
26 int data = digitalRead(btn);
27 if (data == HIGH){
28 Serial.println("Send packet");
29 // send packet
30 LoRa.beginPacket();
31 LoRa.print("1");
32 LoRa.endPacket();
33 }
34 delay(500);
35 }

Here is the display result transmitter code on the serial monitor arduino IDE when circuit 1
sending packet data to circuit 2.

6
In circuit 2 it serves to received packet data message “1” from circuit 1. The following is the
arduino code in the receiver circuit (circuit 2).

#include <SPI.h>
#include <LoRa.h>

int led = 3;

1 #include <SPI.h>
2 #include <LoRa.h>
3
4 int led = 3;
5
6 void setup() {
7 Serial.begin(9600);
8 while (!Serial);
9
10 Serial.println("Lora Receiver");
11
12 if (!LoRa.begin(433E6)) {
13 Serial.println("Lora Error");
14 while (1);
15 }
16 LoRa.setSpreadingFactor(10);
17 LoRa.setSignalBandwidth(62.5E3);

7
18 LoRa.crc();
19
20 pinMode(led, OUTPUT);
21 }
22
23 void loop() {
24 // try to parse packet
25 int packetSize = LoRa.parsePacket();
26 if (packetSize) {
27
28 // received a packet
29 Serial.print("received a packet : ");
30
31 // read packet
32 while (LoRa.available()) {
33 char data = LoRa.read();
34 Serial.print(data);
35 if (data == '1'){
36 digitalWrite(led, HIGH);
37 delay(500);
38 digitalWrite(led, LOW);
39 delay(500);
40 }
41 //Serial.print((char)LoRa.read());
42 }
43 Serial.println(" ");
44 }
45 }

Display results receiver code on the serial monitor arduino IDE, which in series 2 is as follows.

8
In the second scenario of data sent by series 1 in the form of long text or 1 sentence, in this
experiment, the text message is “switch”. The arduino code for the sending packet (circuit 1)
is as follows:

#include <SPI.h>
#include <LoRa.h>

int btn = 3;

1 #include <SPI.h>
2 #include <LoRa.h>
3
4 int btn = 3;
5
6 void setup() {
7 Serial.begin(9600);
8 while (!Serial);
9
10 Serial.println("LoRa Sender");
11
12 if (!LoRa.begin(433E6)) {
13 Serial.println("Starting LoRa failed!");
14 while (1);
15 }
16
17 LoRa.setSpreadingFactor(10);
18 LoRa.setSignalBandwidth(62.5E3);
19 LoRa.crc();
20
21 pinMode(btn, INPUT);
22 Serial.println("Push the button switch for send packet");
23 }
24
25 void loop() {
26 int data = digitalRead(btn);
27 if (data == HIGH){
28 Serial.println("Send packet");
29 // send packet
30 LoRa.beginPacket();
31 LoRa.print("switch,");
32 LoRa.endPacket();
33 }
34 delay(500);
35 }

9
The arduino code for the receiver circuit (circuit 2), when receiving the message data “switch”
is as follows.

#include <SPI.h>
#include <LoRa.h>

int led = 3;

1 #include <SPI.h>
2 #include <LoRa.h>
3
4 int led = 3;
5 String readString;
6 char data = 0;
7
8 void setup() {
9 Serial.begin(9600);
10 while (!Serial);
11
12 Serial.println("Lora Receiver");
13
14 if (!LoRa.begin(433E6)) {
15 Serial.println("Lora Error");
16 while (1);
17 }
18 LoRa.setSpreadingFactor(10);
19 LoRa.setSignalBandwidth(62.5E3);
20 LoRa.crc();
21
22 pinMode(led, OUTPUT);
23 }
24
25 void loop() {
26 int packetSize = LoRa.parsePacket();
27 if (packetSize) {
28 // received a packet
29 Serial.print("received a packet : ");
30 // read packet
31 while (LoRa.available()) {
32 data = LoRa.read();
33 if (data == ',') {
34 if (readString.length() > 1) {
35 Serial.print(readString); //prints string to serial port out
36 Serial.println(' '); //prints delimiting ","
37 digitalWrite(led, HIGH); // LED ON
38 delay(500);
39 digitalWrite(led, LOW); // LED OFF
40 delay(500);
41 //do stuff with the captured readString
42 readString=""; //clears variable for new input

10
43 }
44 }
45 else {
46 readString += data; //makes the string readString
47 }
48 }
49 }
50 }

The display results receiver code in the serial monitor arduino IDE in the receiving packet are
as follows.

11

S-ar putea să vă placă și