Repositorios para el proyecto de hidroponia
Bluetooth.cpp@0:19f9867f1730, 2022-06-10 (annotated)
- Committer:
- iwhalk
- Date:
- Fri Jun 10 04:17:20 2022 +0000
- Revision:
- 0:19f9867f1730
- Child:
- 1:7b3ea5d5e074
agregando bluetooth
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
iwhalk | 0:19f9867f1730 | 1 | /* ############################################################################# |
iwhalk | 0:19f9867f1730 | 2 | ** Archivo : main.c |
iwhalk | 0:19f9867f1730 | 3 | ** Proyecto : STM32F103C8_Bluetooth_Terminal |
iwhalk | 0:19f9867f1730 | 4 | ** Procesador : STM32F103C8T6 |
iwhalk | 0:19f9867f1730 | 5 | ** Plataforma : Blue Pill |
iwhalk | 0:19f9867f1730 | 6 | ** Herramienta : Mbed |
iwhalk | 0:19f9867f1730 | 7 | ** Compilador : Mbed Online C Compiler |
iwhalk | 0:19f9867f1730 | 8 | ** Version : Mbed-OS 5.15.0 |
iwhalk | 0:19f9867f1730 | 9 | ** Fecha/Hora : 18-12-2019, 11:48, # CodeGen: 0 |
iwhalk | 0:19f9867f1730 | 10 | ** Descripción : |
iwhalk | 0:19f9867f1730 | 11 | ** Este proyecto utiliza la Terminal Serial para interactuar con la |
iwhalk | 0:19f9867f1730 | 12 | ** Conexión Serial del Bluetooth como Terminal Serial |
iwhalk | 0:19f9867f1730 | 13 | ** This module contains user's application code. |
iwhalk | 0:19f9867f1730 | 14 | ** Componentes : GPIO, Timer, etc . |
iwhalk | 0:19f9867f1730 | 15 | ** Configuraciones : Includes, Stacks y Drivers externos |
iwhalk | 0:19f9867f1730 | 16 | ** Autores : |
iwhalk | 0:19f9867f1730 | 17 | ** ATEAM Development Group: |
iwhalk | 0:19f9867f1730 | 18 | ** - Antulio Morgado Valle |
iwhalk | 0:19f9867f1730 | 19 | ** |
iwhalk | 0:19f9867f1730 | 20 | ** Versión : Beta |
iwhalk | 0:19f9867f1730 | 21 | ** Revisión : A |
iwhalk | 0:19f9867f1730 | 22 | ** Release : 0 |
iwhalk | 0:19f9867f1730 | 23 | ** Bugs & Fixes : |
iwhalk | 0:19f9867f1730 | 24 | ** Date : 20/10/2019 |
iwhalk | 0:19f9867f1730 | 25 | ** First Release |
iwhalk | 0:19f9867f1730 | 26 | ** |
iwhalk | 0:19f9867f1730 | 27 | ** |
iwhalk | 0:19f9867f1730 | 28 | ** |
iwhalk | 0:19f9867f1730 | 29 | ** ###########################################################################*/ |
iwhalk | 0:19f9867f1730 | 30 | /* |
iwhalk | 0:19f9867f1730 | 31 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
iwhalk | 0:19f9867f1730 | 32 | : I N C L U D E S |
iwhalk | 0:19f9867f1730 | 33 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
iwhalk | 0:19f9867f1730 | 34 | */ |
iwhalk | 0:19f9867f1730 | 35 | #include "stm32f103c8t6.h" |
iwhalk | 0:19f9867f1730 | 36 | #include "mbed.h" |
iwhalk | 0:19f9867f1730 | 37 | #include "Serial.h" |
iwhalk | 0:19f9867f1730 | 38 | //#include "AnalogIn.h" |
iwhalk | 0:19f9867f1730 | 39 | //#include "Led_RGB.h" |
iwhalk | 0:19f9867f1730 | 40 | //#include <stdio.h> |
iwhalk | 0:19f9867f1730 | 41 | |
iwhalk | 0:19f9867f1730 | 42 | /* |
iwhalk | 0:19f9867f1730 | 43 | :............................................................................... |
iwhalk | 0:19f9867f1730 | 44 | : D E F I N I C I O N E S |
iwhalk | 0:19f9867f1730 | 45 | :............................................................................... |
iwhalk | 0:19f9867f1730 | 46 | */ |
iwhalk | 0:19f9867f1730 | 47 | #define LED_ON 0 // Estado para el Led Encendido |
iwhalk | 0:19f9867f1730 | 48 | #define LED_OFF 1 // Estado para el Led Apagado |
iwhalk | 0:19f9867f1730 | 49 | #define BUZZ_ON 1 // Estado para Buzzer Encendido |
iwhalk | 0:19f9867f1730 | 50 | #define BUZZ_OFF 0 // Estado para Buzzer Apagado |
iwhalk | 0:19f9867f1730 | 51 | #define FALSE 0 // Estado FALSO |
iwhalk | 0:19f9867f1730 | 52 | #define TRUE 1 // Estado VERDADERO |
iwhalk | 0:19f9867f1730 | 53 | #define LOW 0 // Estado para Nivel "Bajo" |
iwhalk | 0:19f9867f1730 | 54 | #define HIGH 1 // Estado para Nivel "Alto" |
iwhalk | 0:19f9867f1730 | 55 | #define ON 0 // Estado para boton presionado |
iwhalk | 0:19f9867f1730 | 56 | #define OFF 1 // Estado para boton sin presionar |
iwhalk | 0:19f9867f1730 | 57 | #define HOLD 2 // Estado para boton mantenido |
iwhalk | 0:19f9867f1730 | 58 | #define RELEASE 3 // Estado para boton liberado |
iwhalk | 0:19f9867f1730 | 59 | #define TICKER_RATE 1000 // Periodo de Interrupción (us) |
iwhalk | 0:19f9867f1730 | 60 | #define BAUD_RATE 115200 // Velocidad de Transmisión (Bauds)) |
iwhalk | 0:19f9867f1730 | 61 | // Velocidades Permitidas: |
iwhalk | 0:19f9867f1730 | 62 | // 300, 600, 1200, 2400, 4800, 9600, |
iwhalk | 0:19f9867f1730 | 63 | // 14400, 19600, 28800, 38400, 57600 |
iwhalk | 0:19f9867f1730 | 64 | // 115200, 230400 |
iwhalk | 0:19f9867f1730 | 65 | #define BT_App_Type 0 // App en el Celular: 0=Estandar 1=Emulador |
iwhalk | 0:19f9867f1730 | 66 | #if BT_App_Type == 0 |
iwhalk | 0:19f9867f1730 | 67 | #define BT_BAUD_RATE 38400 // Velocidad Estandar Bluetoothclado (default) |
iwhalk | 0:19f9867f1730 | 68 | #endif |
iwhalk | 0:19f9867f1730 | 69 | #if BT_App_Type == 1 |
iwhalk | 0:19f9867f1730 | 70 | #define BT_BAUD_RATE 9600 // Velocidad de Emulación Terminal Serial |
iwhalk | 0:19f9867f1730 | 71 | #endif |
iwhalk | 0:19f9867f1730 | 72 | |
iwhalk | 0:19f9867f1730 | 73 | /* |
iwhalk | 0:19f9867f1730 | 74 | *=============================================================================== |
iwhalk | 0:19f9867f1730 | 75 | * |
iwhalk | 0:19f9867f1730 | 76 | * C O N F I G U R A C I O N D E P U E R T O S |
iwhalk | 0:19f9867f1730 | 77 | * |
iwhalk | 0:19f9867f1730 | 78 | *=============================================================================== |
iwhalk | 0:19f9867f1730 | 79 | */ |
iwhalk | 0:19f9867f1730 | 80 | Ticker TimerInt; // Inicializa la Interrupción por Timer |
iwhalk | 0:19f9867f1730 | 81 | DigitalOut led_monitor(LED1); // Inicializa el LED Monitor (Interno) |
iwhalk | 0:19f9867f1730 | 82 | DigitalOut led_testigo(PB_12); // Inicializa el LED Testigo (Externo) |
iwhalk | 0:19f9867f1730 | 83 | DigitalOut Led_Verde(PB_13); // Inicializa el PWM2 (PA6_TIM1_CH1N) Led VERDE |
iwhalk | 0:19f9867f1730 | 84 | DigitalOut Led_Rojo(PB_14); // Inicializa el PWM3 (PA7_TIM1_CH2N) Led ROJO |
iwhalk | 0:19f9867f1730 | 85 | DigitalOut Led_Azul(PB_15); // Inicializa el PWM1 (PB0_TIM1_CH3N) Led AZUL |
iwhalk | 0:19f9867f1730 | 86 | DigitalOut key_pin(PB_5,HIGH); // Inicializa el KEY pin o STATE pin (AT Commnands) |
iwhalk | 0:19f9867f1730 | 87 | PwmOut pwm1(PA_7); // Inicializa el PWM para el LED Externo |
iwhalk | 0:19f9867f1730 | 88 | PwmOut buzzer(PB_0); // Inicializa el PWM para el Buzzer Externo |
iwhalk | 0:19f9867f1730 | 89 | AnalogIn Sensor1(PA_0); // Inicializa Canal Analógico para Potenciometro 1 |
iwhalk | 0:19f9867f1730 | 90 | Serial terminal(PA_2, PA_3); // Inicializa la Comunicación Serial UART_2 a la PC (Tx, Rx) |
iwhalk | 0:19f9867f1730 | 91 | Serial bluetooth(PB_10, PB_11);// Inicializa la Comunicación Serial UART_3 sobre Bluetooth (Tx, Rx) |
iwhalk | 0:19f9867f1730 | 92 | //Serial bluetooth(PA_9, PA_10); // Inicializa la Comunicación Serial UART1 sobre Bluetooth (Tx, Rx) |
iwhalk | 0:19f9867f1730 | 93 | //Serial bluetooth(PB_6, PB_7); // Inicializa la Comunicación Serial UART1 sobre Bluetooth (Tx, Rx) |
iwhalk | 0:19f9867f1730 | 94 | /* |
iwhalk | 0:19f9867f1730 | 95 | #=============================================================================== |
iwhalk | 0:19f9867f1730 | 96 | | |
iwhalk | 0:19f9867f1730 | 97 | | A R E A D E D A T O S |
iwhalk | 0:19f9867f1730 | 98 | | |
iwhalk | 0:19f9867f1730 | 99 | #=============================================================================== |
iwhalk | 0:19f9867f1730 | 100 | */ |
iwhalk | 0:19f9867f1730 | 101 | /* |
iwhalk | 0:19f9867f1730 | 102 | +------------------------------------------------------------------------------- |
iwhalk | 0:19f9867f1730 | 103 | | Variables Globales de Usuario |
iwhalk | 0:19f9867f1730 | 104 | +------------------------------------------------------------------------------- |
iwhalk | 0:19f9867f1730 | 105 | */ |
iwhalk | 0:19f9867f1730 | 106 | uint16_t Rate=TICKER_RATE/2; // Velocidad de barrido (500us = 0.5ms) |
iwhalk | 0:19f9867f1730 | 107 | uint16_t counter=250; // Cuenta inicial de 250us |
iwhalk | 0:19f9867f1730 | 108 | uint8_t estado=0; |
iwhalk | 0:19f9867f1730 | 109 | uint8_t caracter; |
iwhalk | 0:19f9867f1730 | 110 | const char *buffer; |
iwhalk | 0:19f9867f1730 | 111 | /* END variables */ |
iwhalk | 0:19f9867f1730 | 112 | |
iwhalk | 0:19f9867f1730 | 113 | /* |
iwhalk | 0:19f9867f1730 | 114 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
iwhalk | 0:19f9867f1730 | 115 | | Definición de Funciones Prototipo y Rutinas de los Vectores de Interrupción |
iwhalk | 0:19f9867f1730 | 116 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
iwhalk | 0:19f9867f1730 | 117 | */ |
iwhalk | 0:19f9867f1730 | 118 | // Las Definiciones de Funciones Prototipo |
iwhalk | 0:19f9867f1730 | 119 | // y Apuntadores a Vectores de Interrupciones van aquí ! |
iwhalk | 0:19f9867f1730 | 120 | void TimerInt_OnInterrupt(void); // Vector de Interrupción del Ticker |
iwhalk | 0:19f9867f1730 | 121 | void Setup(void); // Función de Inicialización del Sistema |
iwhalk | 0:19f9867f1730 | 122 | void Config_BT(void); // Función de Configuración del Bluetooth |
iwhalk | 0:19f9867f1730 | 123 | void Caratula(void); // Función que despliega la Caratula en la Terminal |
iwhalk | 0:19f9867f1730 | 124 | void Eco(void); // Función que Transmite y Recibe entre Terminales |
iwhalk | 0:19f9867f1730 | 125 | void Clear_Screen(void); // Función que limpia la Pantalla de la Terminal |
iwhalk | 0:19f9867f1730 | 126 | void Buzzer_Beep(void); // Función que prueba del Buzzer |
iwhalk | 0:19f9867f1730 | 127 | /* END prototypes */ |
iwhalk | 0:19f9867f1730 | 128 | |
iwhalk | 0:19f9867f1730 | 129 | /* END definitions */ |
iwhalk | 0:19f9867f1730 | 130 | /* |
iwhalk | 0:19f9867f1730 | 131 | #=============================================================================== |
iwhalk | 0:19f9867f1730 | 132 | | |
iwhalk | 0:19f9867f1730 | 133 | | P R O G R A M A P R I N C I P A L |
iwhalk | 0:19f9867f1730 | 134 | | |
iwhalk | 0:19f9867f1730 | 135 | #=============================================================================== |
iwhalk | 0:19f9867f1730 | 136 | */ |
iwhalk | 0:19f9867f1730 | 137 | int main() |
iwhalk | 0:19f9867f1730 | 138 | { |
iwhalk | 0:19f9867f1730 | 139 | //+++++++++++++++++++ Secuencia Principal +++++++++++++++++++++++++++++++++++++ |
iwhalk | 0:19f9867f1730 | 140 | // Inicialización de variables, puertos, interrupciones y carátula |
iwhalk | 0:19f9867f1730 | 141 | key_pin = HIGH; // Bluetooth en modo de Comandos AT |
iwhalk | 0:19f9867f1730 | 142 | Setup(); // Inicializa el Sistema |
iwhalk | 0:19f9867f1730 | 143 | Config_BT(); // Configura el Módulo Bluetooth |
iwhalk | 0:19f9867f1730 | 144 | Caratula(); // Imprime la Caratula de Inicio |
iwhalk | 0:19f9867f1730 | 145 | //+++++++++++++++++++ Lazo Principal +++++++++++++++++++++++++++++++++++++++++++ |
iwhalk | 0:19f9867f1730 | 146 | // El Lazo del Programa principal está aquí !!! |
iwhalk | 0:19f9867f1730 | 147 | while (true) |
iwhalk | 0:19f9867f1730 | 148 | { |
iwhalk | 0:19f9867f1730 | 149 | Eco(); // Hace ECO la terminal Serial con la terminal Bluetooth y viceversa. |
iwhalk | 0:19f9867f1730 | 150 | } |
iwhalk | 0:19f9867f1730 | 151 | } |
iwhalk | 0:19f9867f1730 | 152 | /* END main */ |
iwhalk | 0:19f9867f1730 | 153 | |
iwhalk | 0:19f9867f1730 | 154 | /* |
iwhalk | 0:19f9867f1730 | 155 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
iwhalk | 0:19f9867f1730 | 156 | :: |
iwhalk | 0:19f9867f1730 | 157 | :: V E C T O R E S D E I N T E R R U P C I Ó N |
iwhalk | 0:19f9867f1730 | 158 | :: (Rutinas de Atención) |
iwhalk | 0:19f9867f1730 | 159 | :: |
iwhalk | 0:19f9867f1730 | 160 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
iwhalk | 0:19f9867f1730 | 161 | */ |
iwhalk | 0:19f9867f1730 | 162 | // Las Rutinas de Atención a Interrupciones van aquí ! |
iwhalk | 0:19f9867f1730 | 163 | /* |
iwhalk | 0:19f9867f1730 | 164 | ** =================================================================== |
iwhalk | 0:19f9867f1730 | 165 | ** Vector : TimerInt_OnInterrupt() |
iwhalk | 0:19f9867f1730 | 166 | */ |
iwhalk | 0:19f9867f1730 | 167 | /*! |
iwhalk | 0:19f9867f1730 | 168 | ** @brief |
iwhalk | 0:19f9867f1730 | 169 | ** Called after Ticker is done, [Interrupt service/event] |
iwhalk | 0:19f9867f1730 | 170 | ** and it is enabled: |
iwhalk | 0:19f9867f1730 | 171 | ** TimerInt.attach_us(&TimerInt_OnInterrupt, TICKER_RATE); |
iwhalk | 0:19f9867f1730 | 172 | ** the event is enabled and will be executed every [TICKER_RATE] |
iwhalk | 0:19f9867f1730 | 173 | ** @param |
iwhalk | 0:19f9867f1730 | 174 | ** UserDataPtr - Pointer to the user or |
iwhalk | 0:19f9867f1730 | 175 | ** RTOS specific data. The pointer is passed |
iwhalk | 0:19f9867f1730 | 176 | ** as the parameter of Init method. |
iwhalk | 0:19f9867f1730 | 177 | */ |
iwhalk | 0:19f9867f1730 | 178 | /* ===================================================================*/ |
iwhalk | 0:19f9867f1730 | 179 | void TimerInt_OnInterrupt() // Rutina de Atención al Ticker |
iwhalk | 0:19f9867f1730 | 180 | { |
iwhalk | 0:19f9867f1730 | 181 | counter--; // Aquí va la Rutina de Servicio ! |
iwhalk | 0:19f9867f1730 | 182 | if (!counter) |
iwhalk | 0:19f9867f1730 | 183 | { |
iwhalk | 0:19f9867f1730 | 184 | // terminal.printf("Counter Finish! \r\n"); |
iwhalk | 0:19f9867f1730 | 185 | led_monitor = !led_monitor; // Parapadeo del LED por Interrupción (LED Toggled) |
iwhalk | 0:19f9867f1730 | 186 | counter = Rate; // Restablece el contador, Le asigna el periodo de 0.5ms (Rate=500) |
iwhalk | 0:19f9867f1730 | 187 | } |
iwhalk | 0:19f9867f1730 | 188 | } |
iwhalk | 0:19f9867f1730 | 189 | /* END Events */ |
iwhalk | 0:19f9867f1730 | 190 | /* |
iwhalk | 0:19f9867f1730 | 191 | ______________________________________________________________________________ |
iwhalk | 0:19f9867f1730 | 192 | /______________________________________________________________________________\ |
iwhalk | 0:19f9867f1730 | 193 | | | |
iwhalk | 0:19f9867f1730 | 194 | | F U N C I O N E S P R O T O T I P O | |
iwhalk | 0:19f9867f1730 | 195 | |______________________________________________________________________________| |
iwhalk | 0:19f9867f1730 | 196 | \_____________________________________________________________________________/ |
iwhalk | 0:19f9867f1730 | 197 | */ |
iwhalk | 0:19f9867f1730 | 198 | // Las Funciones Prototipo van aquí ! |
iwhalk | 0:19f9867f1730 | 199 | /* |
iwhalk | 0:19f9867f1730 | 200 | |-------------------------------------------------- |
iwhalk | 0:19f9867f1730 | 201 | | Función Setup() |
iwhalk | 0:19f9867f1730 | 202 | |-------------------------------------------------- |
iwhalk | 0:19f9867f1730 | 203 | */ |
iwhalk | 0:19f9867f1730 | 204 | void Setup() |
iwhalk | 0:19f9867f1730 | 205 | { |
iwhalk | 0:19f9867f1730 | 206 | confSysClock(); // Inicialización del Sistema, Configure system clock (72MHz HSE clock, 48MHz USB clock) |
iwhalk | 0:19f9867f1730 | 207 | terminal.baud(BAUD_RATE); // Se configura la velocidad de transmisión e inicia la comunicación serial. |
iwhalk | 0:19f9867f1730 | 208 | Clear_Screen(); // Limpia la pantalla de la Terminal |
iwhalk | 0:19f9867f1730 | 209 | Buzzer_Beep(); // Prueba el Buzzer |
iwhalk | 0:19f9867f1730 | 210 | terminal.printf("The System is Wake Up!.\n\r"); |
iwhalk | 0:19f9867f1730 | 211 | wait (2); // Espera 2 segundos |
iwhalk | 0:19f9867f1730 | 212 | TimerInt.attach_us(&TimerInt_OnInterrupt, TICKER_RATE); // Le asigna el periodo de interrupción de 1ms (TICKER_RATE=1000) |
iwhalk | 0:19f9867f1730 | 213 | Clear_Screen(); // Limpia la pantalla de la Terminal |
iwhalk | 0:19f9867f1730 | 214 | } |
iwhalk | 0:19f9867f1730 | 215 | /* |
iwhalk | 0:19f9867f1730 | 216 | |-------------------------------------------------- |
iwhalk | 0:19f9867f1730 | 217 | | Función Config_BT() |
iwhalk | 0:19f9867f1730 | 218 | |-------------------------------------------------- |
iwhalk | 0:19f9867f1730 | 219 | */ |
iwhalk | 0:19f9867f1730 | 220 | void Config_BT() // Software Bluetooth Initialization |
iwhalk | 0:19f9867f1730 | 221 | { |
iwhalk | 0:19f9867f1730 | 222 | /* |
iwhalk | 0:19f9867f1730 | 223 | key_pin = HIGH; // Entramos al modo de Comandos AT |
iwhalk | 0:19f9867f1730 | 224 | bluetooth.baud(38400); // Velocidad del Módulo Bluetooth para comandos AT. |
iwhalk | 0:19f9867f1730 | 225 | wait_ms(25); // Espermos a que se estabilize el reloj |
iwhalk | 0:19f9867f1730 | 226 | bluetooth.printf("AT\r\n"); // Configura el nombre de la terminal Bluetooth. |
iwhalk | 0:19f9867f1730 | 227 | bluetooth.printf("AT+ROLE=0\r\n"); // Configura el módulo Bluetooth como "Esclavo". |
iwhalk | 0:19f9867f1730 | 228 | bluetooth.printf("AT+NAME=BluePill\r\n"); // Configura el nombre de la terminal Bluetooth. |
iwhalk | 0:19f9867f1730 | 229 | // bluetooth.printf("AT+PSWD=4321\r\n"); // Configura el password de la terminal Bluetooth. |
iwhalk | 0:19f9867f1730 | 230 | bluetooth.printf("AT+VERSION?\r\n");// Muestra la Versión del Módulo Bluetooth. |
iwhalk | 0:19f9867f1730 | 231 | bluetooth.printf("AT+ADDR?\r\n"); // Muestra la Dirección de la terminal Bluetooth. |
iwhalk | 0:19f9867f1730 | 232 | bluetooth.printf("AT+UART?\r\n"); // Muestra la Velocidad de Transmisión de la terminal Bluetooth. |
iwhalk | 0:19f9867f1730 | 233 | key_pin=HIGH; // Inhibe al HC-05 para recibir commandos AT |
iwhalk | 0:19f9867f1730 | 234 | bluetooth.baud(9600); // Velocidad del Módulo Bluetooth para datos AT. |
iwhalk | 0:19f9867f1730 | 235 | // terminal.baud(BT_BAUD_RATE); // Configura la velocidad del Módulo Bluetooth. |
iwhalk | 0:19f9867f1730 | 236 | bluetooth.printf("The Bluetooth is configuring Sucesfully!.\n\r"); |
iwhalk | 0:19f9867f1730 | 237 | wait_ms(25); |
iwhalk | 0:19f9867f1730 | 238 | */ |
iwhalk | 0:19f9867f1730 | 239 | key_pin = HIGH; // Entramos al modo de Comandos AT |
iwhalk | 0:19f9867f1730 | 240 | // bluetooth.baud(9600); // Velocidad del Módulo Bluetooth para datos AT. |
iwhalk | 0:19f9867f1730 | 241 | if (bluetooth.writable()) // Espermos para poder escribir en el Bluetooth. |
iwhalk | 0:19f9867f1730 | 242 | bluetooth.baud(38400); // Velocidad del Módulo Bluetooth para comandos AT. |
iwhalk | 0:19f9867f1730 | 243 | wait_ms(25); // Espermos a que se estabilize el reloj |
iwhalk | 0:19f9867f1730 | 244 | if (bluetooth.writable()) // Espermos para poder escribir en el Bluetooth. |
iwhalk | 0:19f9867f1730 | 245 | bluetooth.printf("AT\r\n"); // Configura el nombre de la terminal Bluetooth. |
iwhalk | 0:19f9867f1730 | 246 | wait_ms(5); // Espermos a que responda la terminal Bluetooth. |
iwhalk | 0:19f9867f1730 | 247 | if (bluetooth.writable()) // Espermos para poder escribir en el Bluetooth. |
iwhalk | 0:19f9867f1730 | 248 | bluetooth.printf("AT+ROLE=1\r\n"); // Configura el módulo Bluetooth: 0="Esclavo", 1="Maestro". |
iwhalk | 0:19f9867f1730 | 249 | wait_ms(5); // Espermos a que responda la terminal Bluetooth. |
iwhalk | 0:19f9867f1730 | 250 | // if (bluetooth.writable()) // Espermos para poder escribir en el Bluetooth. |
iwhalk | 0:19f9867f1730 | 251 | // bluetooth.printf("AT+CMODE=1\r\n"); // Selecciona/Verifica el modo de conección: 0 - A dirección fija 1 - A cualquier dirección, 2 - Lazo de Esclavo |
iwhalk | 0:19f9867f1730 | 252 | // wait_ms(5); // Espermos a que responda la terminal Bluetooth. |
iwhalk | 0:19f9867f1730 | 253 | if (bluetooth.writable()) // Espermos para poder escribir en el Bluetooth. |
iwhalk | 0:19f9867f1730 | 254 | bluetooth.printf("AT+NAME=BluePill\r\n"); // Configura el nombre de la terminal Bluetooth. |
iwhalk | 0:19f9867f1730 | 255 | wait_ms(5); // Espermos a que responda la terminal Bluetooth. |
iwhalk | 0:19f9867f1730 | 256 | // if (bluetooth.writable()) // Espermos para poder escribir en el Bluetooth. |
iwhalk | 0:19f9867f1730 | 257 | // bluetooth.printf("AT+PSWD=4321\r\n"); // Configura el password de la terminal Bluetooth. |
iwhalk | 0:19f9867f1730 | 258 | // wait_ms(5); // Espermos a que responda la terminal Bluetooth. |
iwhalk | 0:19f9867f1730 | 259 | if (bluetooth.writable()) // Espermos para poder escribir en el Bluetooth. |
iwhalk | 0:19f9867f1730 | 260 | bluetooth.printf("AT+VERSION?\r\n");// Muestra la Versión del Módulo Bluetooth. |
iwhalk | 0:19f9867f1730 | 261 | if (bluetooth.writable()) // Espermos para poder escribir en el Bluetooth. |
iwhalk | 0:19f9867f1730 | 262 | bluetooth.printf("AT+ADDR?\r\n"); // Muestra la Dirección de la terminal Bluetooth. |
iwhalk | 0:19f9867f1730 | 263 | if (bluetooth.writable()) // Espermos para poder escribir en el Bluetooth. |
iwhalk | 0:19f9867f1730 | 264 | bluetooth.printf("AT+UART?\r\n"); // Muestra la Velocidad de Transmisión de la terminal Bluetooth. |
iwhalk | 0:19f9867f1730 | 265 | key_pin=LOW; // Inhibe al HC-05 para recibir commandos AT |
iwhalk | 0:19f9867f1730 | 266 | // bluetooth.baud(BT_BAUD_RATE); // Configura la velocidad del Módulo Bluetooth. |
iwhalk | 0:19f9867f1730 | 267 | bluetooth.baud(9600); // Velocidad del Módulo Bluetooth para datos AT. |
iwhalk | 0:19f9867f1730 | 268 | wait_ms(25); |
iwhalk | 0:19f9867f1730 | 269 | terminal.printf("The \e[1;34;40mBluetooth\e[m was configurated Sucesfully!.\n\r"); |
iwhalk | 0:19f9867f1730 | 270 | wait_ms(25); |
iwhalk | 0:19f9867f1730 | 271 | if (bluetooth.writable()) // Espermos para poder escribir en el Bluetooth. |
iwhalk | 0:19f9867f1730 | 272 | bluetooth.printf("The \e[1;34;40mBluetooth\e[m is ready to Paring!.\n\r"); |
iwhalk | 0:19f9867f1730 | 273 | } |
iwhalk | 0:19f9867f1730 | 274 | /* |
iwhalk | 0:19f9867f1730 | 275 | |-------------------------------------------------- |
iwhalk | 0:19f9867f1730 | 276 | | Función Caratula() |
iwhalk | 0:19f9867f1730 | 277 | |-------------------------------------------------- |
iwhalk | 0:19f9867f1730 | 278 | */ |
iwhalk | 0:19f9867f1730 | 279 | void Caratula() |
iwhalk | 0:19f9867f1730 | 280 | { |
iwhalk | 0:19f9867f1730 | 281 | terminal.printf ("\t\e[1;37;41mInstituto Politecnico Nacional\e[0m\n\r"); |
iwhalk | 0:19f9867f1730 | 282 | terminal.printf ("\e[1;37;42mESCUELA SUPERIOR DE INGENIERIA MECANICA Y ELECTRICA\e[0m\n\r\v"); |
iwhalk | 0:19f9867f1730 | 283 | terminal.printf ("\t\e[1;31;40mPrueba \e[1;35;40mde \e[1;33;40mla \e[1;32;40mTerminal \e[1;34;40mBluetooth \e[0m\n\r\v\v\e[0m"); |
iwhalk | 0:19f9867f1730 | 284 | // terminal.printf ("\t\e[1;32;40mTerminal Serial Lista!\n\r"); |
iwhalk | 0:19f9867f1730 | 285 | // bluetooth.printf ("\t\e[1;34;40mTerminal Bluetooth Lista!\n\r"); |
iwhalk | 0:19f9867f1730 | 286 | } |
iwhalk | 0:19f9867f1730 | 287 | /* |
iwhalk | 0:19f9867f1730 | 288 | |-------------------------------------------------- |
iwhalk | 0:19f9867f1730 | 289 | | Función Eco() |
iwhalk | 0:19f9867f1730 | 290 | |-------------------------------------------------- |
iwhalk | 0:19f9867f1730 | 291 | */ |
iwhalk | 0:19f9867f1730 | 292 | void Eco() // Eco a la Terminal |
iwhalk | 0:19f9867f1730 | 293 | { |
iwhalk | 0:19f9867f1730 | 294 | if (bluetooth.readable()) |
iwhalk | 0:19f9867f1730 | 295 | { |
iwhalk | 0:19f9867f1730 | 296 | caracter=bluetooth.getc(); // Si llega un dato por el puerto BT |
iwhalk | 0:19f9867f1730 | 297 | // wait_ms(5); // Espera a que se desocupe la terminal |
iwhalk | 0:19f9867f1730 | 298 | // if (terminal.writable()) // Si se peude escribir a la Terminal |
iwhalk | 0:19f9867f1730 | 299 | terminal.printf("\e[1;34;40m%c",caracter); // se envía al monitor serial |
iwhalk | 0:19f9867f1730 | 300 | if (bluetooth.writable()) |
iwhalk | 0:19f9867f1730 | 301 | bluetooth.putc(caracter); // y hace ECO con la terminal BT |
iwhalk | 0:19f9867f1730 | 302 | } |
iwhalk | 0:19f9867f1730 | 303 | |
iwhalk | 0:19f9867f1730 | 304 | if (terminal.readable()) |
iwhalk | 0:19f9867f1730 | 305 | { |
iwhalk | 0:19f9867f1730 | 306 | caracter=terminal.getc(); // Si llega un dato por el monitor serial |
iwhalk | 0:19f9867f1730 | 307 | // if (bluetooth.writable()) |
iwhalk | 0:19f9867f1730 | 308 | bluetooth.putc(caracter); // se envía al puerto BT |
iwhalk | 0:19f9867f1730 | 309 | terminal.printf("\e[1;32;40m%c",caracter); // y hace ECO con el monitor serial |
iwhalk | 0:19f9867f1730 | 310 | } |
iwhalk | 0:19f9867f1730 | 311 | } |
iwhalk | 0:19f9867f1730 | 312 | /* |
iwhalk | 0:19f9867f1730 | 313 | |-------------------------------------------------- |
iwhalk | 0:19f9867f1730 | 314 | | Función Clear_Screen() |
iwhalk | 0:19f9867f1730 | 315 | |-------------------------------------------------- |
iwhalk | 0:19f9867f1730 | 316 | */ |
iwhalk | 0:19f9867f1730 | 317 | void Clear_Screen() |
iwhalk | 0:19f9867f1730 | 318 | { |
iwhalk | 0:19f9867f1730 | 319 | // ANSI Terminal Commands |
iwhalk | 0:19f9867f1730 | 320 | terminal.printf("\x1B[2J"); // secuencia de Escape \e1B[2J |
iwhalk | 0:19f9867f1730 | 321 | terminal.printf("\x1B[H"); // secuencia de Escape \e1B[H |
iwhalk | 0:19f9867f1730 | 322 | } |
iwhalk | 0:19f9867f1730 | 323 | /* |
iwhalk | 0:19f9867f1730 | 324 | |-------------------------------------------------- |
iwhalk | 0:19f9867f1730 | 325 | | Función Buzzer_Beep() |
iwhalk | 0:19f9867f1730 | 326 | |-------------------------------------------------- |
iwhalk | 0:19f9867f1730 | 327 | */ |
iwhalk | 0:19f9867f1730 | 328 | void Buzzer_Beep() // Software routine for Buzzer Beep |
iwhalk | 0:19f9867f1730 | 329 | { |
iwhalk | 0:19f9867f1730 | 330 | terminal.printf("Testing Buzzer... \n\r"); |
iwhalk | 0:19f9867f1730 | 331 | buzzer = BUZZ_ON; |
iwhalk | 0:19f9867f1730 | 332 | wait_ms(750); |
iwhalk | 0:19f9867f1730 | 333 | buzzer = BUZZ_OFF; |
iwhalk | 0:19f9867f1730 | 334 | wait_ms(125); |
iwhalk | 0:19f9867f1730 | 335 | buzzer = BUZZ_ON; |
iwhalk | 0:19f9867f1730 | 336 | wait_ms(250); |
iwhalk | 0:19f9867f1730 | 337 | buzzer = BUZZ_OFF; |
iwhalk | 0:19f9867f1730 | 338 | wait_ms(125); |
iwhalk | 0:19f9867f1730 | 339 | buzzer = BUZZ_ON; |
iwhalk | 0:19f9867f1730 | 340 | wait_ms(500); |
iwhalk | 0:19f9867f1730 | 341 | buzzer = BUZZ_OFF; |
iwhalk | 0:19f9867f1730 | 342 | terminal.printf("Buzzer OK ! \n\r"); |
iwhalk | 0:19f9867f1730 | 343 | } |
iwhalk | 0:19f9867f1730 | 344 | /* END functions */ |
iwhalk | 0:19f9867f1730 | 345 | |
iwhalk | 0:19f9867f1730 | 346 | /* END program */ |
iwhalk | 0:19f9867f1730 | 347 | |
iwhalk | 0:19f9867f1730 | 348 | /* |
iwhalk | 0:19f9867f1730 | 349 | *+****************************************************************************** |
iwhalk | 0:19f9867f1730 | 350 | *+ D O C U M E N T A C I Ó N |
iwhalk | 0:19f9867f1730 | 351 | *+****************************************************************************** |
iwhalk | 0:19f9867f1730 | 352 | *+ La documentación va aquí!: |
iwhalk | 0:19f9867f1730 | 353 | *+ |
iwhalk | 0:19f9867f1730 | 354 | *+------------------------------------------------------------------------------ |
iwhalk | 0:19f9867f1730 | 355 | *+ MODULO BLUETOOTH HC-05 |
iwhalk | 0:19f9867f1730 | 356 | *+------------------------------------------------------------------------------ |
iwhalk | 0:19f9867f1730 | 357 | *+ |
iwhalk | 0:19f9867f1730 | 358 | *+ PIN CONFIGURATION |
iwhalk | 0:19f9867f1730 | 359 | *+ |
iwhalk | 0:19f9867f1730 | 360 | *+ |
iwhalk | 0:19f9867f1730 | 361 | *+ Pin Number Pin Name Description |
iwhalk | 0:19f9867f1730 | 362 | *+ 1 Enable/Key This pin is used to toggle between |
iwhalk | 0:19f9867f1730 | 363 | *+ Data Mode (set LOW) and AT command mode (set HiGH). |
iwhalk | 0:19f9867f1730 | 364 | *+ By default it is in Data mode |
iwhalk | 0:19f9867f1730 | 365 | *+ 2 Vcc Powers the module. Connect to +5V Supply voltage |
iwhalk | 0:19f9867f1730 | 366 | *+ 3 Ground Ground pin of module, connect to system ground. |
iwhalk | 0:19f9867f1730 | 367 | *+ 4 TX–Transmitter Transmits Serial Data. Everything received via |
iwhalk | 0:19f9867f1730 | 368 | ** Bluetooth will be given out by this pin as serial data. |
iwhalk | 0:19f9867f1730 | 369 | *+ 5 RX–Receiver Receive Serial Data. Every serial data given to |
iwhalk | 0:19f9867f1730 | 370 | *+ this pin will be broadcasted via Bluetooth |
iwhalk | 0:19f9867f1730 | 371 | *+ 6 State The state pin is connected to on board LED, it |
iwhalk | 0:19f9867f1730 | 372 | *+ can be used as a feedback to check if Bluetooth |
iwhalk | 0:19f9867f1730 | 373 | *+ is working properly. |
iwhalk | 0:19f9867f1730 | 374 | *+ 7 LED Indicates the status of Module: |
iwhalk | 0:19f9867f1730 | 375 | *+ * Blink once in 2 sec: Module has entered Command Mode |
iwhalk | 0:19f9867f1730 | 376 | *+ * Repeated Blinking: Waiting for connection in Data Mode |
iwhalk | 0:19f9867f1730 | 377 | *+ * Blink twice in 1 sec: Connection successful in Data Mode |
iwhalk | 0:19f9867f1730 | 378 | *+ 8 Button Used to control the Key/Enable pin to toggle between |
iwhalk | 0:19f9867f1730 | 379 | *+ Data and command Mode |
iwhalk | 0:19f9867f1730 | 380 | *+ |
iwhalk | 0:19f9867f1730 | 381 | *+ HC-05 Default Settings |
iwhalk | 0:19f9867f1730 | 382 | *+ |
iwhalk | 0:19f9867f1730 | 383 | *+ Default Bluetooth Name: “HC-05” |
iwhalk | 0:19f9867f1730 | 384 | *+ Default Password: 1234 or 0000 |
iwhalk | 0:19f9867f1730 | 385 | *+ Default Communication: Slave |
iwhalk | 0:19f9867f1730 | 386 | *+ Default Mode: Data Mode |
iwhalk | 0:19f9867f1730 | 387 | *+ Data Mode Baud Rate: 9600, 8, N, 1 |
iwhalk | 0:19f9867f1730 | 388 | *+ Command Mode Baud Rate: 38400, 8, N, 1 |
iwhalk | 0:19f9867f1730 | 389 | *+ Default firmware: LINVOR |
iwhalk | 0:19f9867f1730 | 390 | *+ |
iwhalk | 0:19f9867f1730 | 391 | *+ HC-05 Technical Specifications |
iwhalk | 0:19f9867f1730 | 392 | *+ |
iwhalk | 0:19f9867f1730 | 393 | *+ Serial Bluetooth module for Arduino and other microcontrollers |
iwhalk | 0:19f9867f1730 | 394 | *+ Operating Voltage: 4V to 6V (Typically +5V) |
iwhalk | 0:19f9867f1730 | 395 | *+ Operating Current: 30mA |
iwhalk | 0:19f9867f1730 | 396 | *+ Range: <100m |
iwhalk | 0:19f9867f1730 | 397 | *+ Supported baud rate: 9600,19200,38400,57600,115200,230400,460800. |
iwhalk | 0:19f9867f1730 | 398 | *+ Works with Serial communication (USART) and TTL compatible |
iwhalk | 0:19f9867f1730 | 399 | *+ Follows IEEE 802.15.1 standardized protocol |
iwhalk | 0:19f9867f1730 | 400 | *+ Uses Frequency-Hopping Spread spectrum (FHSS) |
iwhalk | 0:19f9867f1730 | 401 | *+ Can operate in Master, Slave or Master/Slave mode |
iwhalk | 0:19f9867f1730 | 402 | *+ Can be easily interfaced with Laptop or Mobile phones with Bluetooth |
iwhalk | 0:19f9867f1730 | 403 | *+ |
iwhalk | 0:19f9867f1730 | 404 | *+ |
iwhalk | 0:19f9867f1730 | 405 | *+ Cómo utilizar el módulo Bluetooth HC-05 |
iwhalk | 0:19f9867f1730 | 406 | *+ |
iwhalk | 0:19f9867f1730 | 407 | *+ El HC-05 tiene dos modos de funcionamiento, uno es el modo de datos en el |
iwhalk | 0:19f9867f1730 | 408 | *+ que puede enviar y recibir datos de otros dispositivos Bluetooth y el otro |
iwhalk | 0:19f9867f1730 | 409 | *+ es el modo de comando AT donde se puede cambiar la configuración predeterminada |
iwhalk | 0:19f9867f1730 | 410 | *+ del dispositivo. Podemos operar el dispositivo en cualquiera de estos dos |
iwhalk | 0:19f9867f1730 | 411 | *+ modos usando el pin clave como se explica en la descripción del pin. |
iwhalk | 0:19f9867f1730 | 412 | *+ |
iwhalk | 0:19f9867f1730 | 413 | *+ Es muy fácil emparejar el módulo HC-05 con microcontroladores porque opera |
iwhalk | 0:19f9867f1730 | 414 | *+ utilizando el Protocolo de Puerto Serie (SPP). Simplemente encienda el módulo |
iwhalk | 0:19f9867f1730 | 415 | *+ con + 5V y conecte el pin Rx del módulo al Tx del MCU y el pin Tx del módulo |
iwhalk | 0:19f9867f1730 | 416 | *+ al Rx del MCU como se muestra en la siguiente figura |
iwhalk | 0:19f9867f1730 | 417 | *+ |
iwhalk | 0:19f9867f1730 | 418 | *+ Para este ejemplo disponemos de un módulo Bluetooth HC-05 que podemos |
iwhalk | 0:19f9867f1730 | 419 | *+ conectar al puerto Serial de la Blue Pill. |
iwhalk | 0:19f9867f1730 | 420 | *+ Resumidamente hemos de conectar los pines de recepción (RX) y transmisión (TX); |
iwhalk | 0:19f9867f1730 | 421 | *+ que por defecto son los pines 0 y 1 respectivamente de nuestra placa con los |
iwhalk | 0:19f9867f1730 | 422 | *+ pines de transmisión (TX) y recepción (RX) del módulo de forma inversa; |
iwhalk | 0:19f9867f1730 | 423 | *+ tal y como se indica en la figura. |
iwhalk | 0:19f9867f1730 | 424 | *+ |
iwhalk | 0:19f9867f1730 | 425 | *+ Módulo HC-05 Blue Pill PIN |
iwhalk | 0:19f9867f1730 | 426 | *+ KEY (EN) <---------- KEY_pin (ENable) PB_1 |
iwhalk | 0:19f9867f1730 | 427 | *+ VCC ----------- 5V (algunos módulos pueden operar a 3.3V) |
iwhalk | 0:19f9867f1730 | 428 | *+ GND ----------- GND |
iwhalk | 0:19f9867f1730 | 429 | *+ Tx ----------> Rx PB_11 |
iwhalk | 0:19f9867f1730 | 430 | *+ Rx <---------- Tx PB_10 |
iwhalk | 0:19f9867f1730 | 431 | *+ |
iwhalk | 0:19f9867f1730 | 432 | *+ Lo más importante a tener en cuenta es que debemos de activar el modo de |
iwhalk | 0:19f9867f1730 | 433 | *+ configuración del Bluetooth a través de el PIN EN o KEY, que debe de estar |
iwhalk | 0:19f9867f1730 | 434 | *+ activo con un voltaje y que en este caso conectacmos al pin de 3,3V. |
iwhalk | 0:19f9867f1730 | 435 | *+ |
iwhalk | 0:19f9867f1730 | 436 | *+ ATENCIÓN: Hay algunos módulos HC-05 que disponen de un botón diminuto y que |
iwhalk | 0:19f9867f1730 | 437 | *+ hay que apretar antes de conectarlo a la alimentación. En el momento en el |
iwhalk | 0:19f9867f1730 | 438 | *+ que entre en modo configuración; el LED parpadeará más lento de lo normal y |
iwhalk | 0:19f9867f1730 | 439 | *+ podemos verificar que ha cambiado de modo. |
iwhalk | 0:19f9867f1730 | 440 | *+ |
iwhalk | 0:19f9867f1730 | 441 | *+ Conexiones del circuito del módulo Bluetooth HC-05 |
iwhalk | 0:19f9867f1730 | 442 | *+ |
iwhalk | 0:19f9867f1730 | 443 | *+ Durante el encendido, el pin de key puede conectarse a tierra para |
iwhalk | 0:19f9867f1730 | 444 | *+ entrar en el modo de comando; si se deja libre, entrará de forma predeterminada |
iwhalk | 0:19f9867f1730 | 445 | *+ en el modo de datos. Tan pronto como se encienda el módulo, debería poder |
iwhalk | 0:19f9867f1730 | 446 | *+ encontrar el dispositivo Bluetooth como “HC-05”, luego conéctese con la |
iwhalk | 0:19f9867f1730 | 447 | *+ contraseña predeterminada 1234 y comience a comunicarse con él. |
iwhalk | 0:19f9867f1730 | 448 | *+ El nombre de la contraseña y otros parámetros predeterminados se pueden |
iwhalk | 0:19f9867f1730 | 449 | *+ cambiar ingresando al modo de configuración. |
iwhalk | 0:19f9867f1730 | 450 | *+ |
iwhalk | 0:19f9867f1730 | 451 | *+ Para poder comunicarse en modo configuración a través de la placa Blue Pill |
iwhalk | 0:19f9867f1730 | 452 | *+ es necesario configurar la velocidad de transmisión hacia la tarjeta HC-05 a |
iwhalk | 0:19f9867f1730 | 453 | *+ 38400 Bauds |
iwhalk | 0:19f9867f1730 | 454 | *+ |
iwhalk | 0:19f9867f1730 | 455 | *+ 1. Dispositivos Bluetooth: |
iwhalk | 0:19f9867f1730 | 456 | *+ El módulo Bluetooth HC-05 viene configurado de fábrica como "Esclavo" (slave), |
iwhalk | 0:19f9867f1730 | 457 | *+ pero se puede cambiar para que trabaje como "maestro" (master), además al |
iwhalk | 0:19f9867f1730 | 458 | *+ igual que el HC-06, se puede cambiar el nombre, código de vinculación, |
iwhalk | 0:19f9867f1730 | 459 | *+ velocidad y otros parámetros más. |
iwhalk | 0:19f9867f1730 | 460 | *+ |
iwhalk | 0:19f9867f1730 | 461 | *+ Definamos primero que es un dispositivo bluetooth maestro y dispositivo esclavo: |
iwhalk | 0:19f9867f1730 | 462 | *+ |
iwhalk | 0:19f9867f1730 | 463 | *+ Modulo bluetooth hc-05 como esclavo: |
iwhalk | 0:19f9867f1730 | 464 | *+ Cuando está configurado de esta forma, se comporta similar a un HC-06, espera |
iwhalk | 0:19f9867f1730 | 465 | *+ que un dispositivo bluetooth maestro se conecte a este, generalmente se |
iwhalk | 0:19f9867f1730 | 466 | *+ utiliza cuando se necesita comunicarse con una PC o Celular, pues estos se |
iwhalk | 0:19f9867f1730 | 467 | *+ comportan como dispositivos maestros. |
iwhalk | 0:19f9867f1730 | 468 | *+ |
iwhalk | 0:19f9867f1730 | 469 | *+ Modulo bluetooth hc-05 como Maestro: |
iwhalk | 0:19f9867f1730 | 470 | *+ En este modo, EL HC-05 es el que inicia la conexión. Un dispositivo maestro |
iwhalk | 0:19f9867f1730 | 471 | *+ solo se puede conectarse con un dispositivo esclavo. Generalmente se utiliza |
iwhalk | 0:19f9867f1730 | 472 | *+ este modo para comunicarse entre módulos bluetooth. Pero es necesario antes |
iwhalk | 0:19f9867f1730 | 473 | *+ especificar con que dispositivo se tiene que comunicar, esto se explicará más |
iwhalk | 0:19f9867f1730 | 474 | *+ adelante |
iwhalk | 0:19f9867f1730 | 475 | *+ |
iwhalk | 0:19f9867f1730 | 476 | *+ El módulo HC-05 viene por defecto configurado de la siguiente forma: |
iwhalk | 0:19f9867f1730 | 477 | *+ - Modo o role: Esclavo |
iwhalk | 0:19f9867f1730 | 478 | *+ - Nombre por defeco: HC-05 |
iwhalk | 0:19f9867f1730 | 479 | *+ - Código de emparejamiento por defecto: 1234 |
iwhalk | 0:19f9867f1730 | 480 | *+ - La velocidad por defecto (baud rate): 9600 |
iwhalk | 0:19f9867f1730 | 481 | *+ |
iwhalk | 0:19f9867f1730 | 482 | *+ 2. Modos de trabajo del HC-05:: |
iwhalk | 0:19f9867f1730 | 483 | *+ EL Modulo HC-05 tiene 4 estados los cuales es importante conocer: |
iwhalk | 0:19f9867f1730 | 484 | *+ |
iwhalk | 0:19f9867f1730 | 485 | *+ Estado Desconectado: |
iwhalk | 0:19f9867f1730 | 486 | *+ - Entra a este estado tan pronto alimentas el modulo, y cuando no se ha |
iwhalk | 0:19f9867f1730 | 487 | *+ establecido una conexión bluetooth con ningún otro dispositivo |
iwhalk | 0:19f9867f1730 | 488 | *+ - EL LED del módulo en este estado parpadea rápidamente |
iwhalk | 0:19f9867f1730 | 489 | *+ - En este estado a diferencia del HC-06, el HC-05 no puede interpretar los |
iwhalk | 0:19f9867f1730 | 490 | *+ comandos AT |
iwhalk | 0:19f9867f1730 | 491 | *+ |
iwhalk | 0:19f9867f1730 | 492 | *+ Estado Conectado o de comunicación |
iwhalk | 0:19f9867f1730 | 493 | *+ - Entra a este estado cuando se establece una conexión con otro dispositivo |
iwhalk | 0:19f9867f1730 | 494 | *+ bluetooth. |
iwhalk | 0:19f9867f1730 | 495 | *+ - El LED hace un doble parpadeo. |
iwhalk | 0:19f9867f1730 | 496 | *+ - Todos los datos que se ingresen al HC-05 por el Pin RX se trasmiten por |
iwhalk | 0:19f9867f1730 | 497 | *+ bluetooth al dispositivo conectado, y los datos recibidos se devuelven por |
iwhalk | 0:19f9867f1730 | 498 | *+ el pin TX. La comunicación es transparente |
iwhalk | 0:19f9867f1730 | 499 | *+ |
iwhalk | 0:19f9867f1730 | 500 | *+ Modo AT 1 |
iwhalk | 0:19f9867f1730 | 501 | *+ - Para entrar a este estado después de conectar y alimentar el modulo es |
iwhalk | 0:19f9867f1730 | 502 | *+ necesario presionar el botón del HC-05. |
iwhalk | 0:19f9867f1730 | 503 | *+ - En este estado, podemos enviar comandos AT, pero a la misma velocidad con |
iwhalk | 0:19f9867f1730 | 504 | *+ el que está configurado. |
iwhalk | 0:19f9867f1730 | 505 | *+ - EL LED del módulo en este estado parpadea rápidamente igual que en el |
iwhalk | 0:19f9867f1730 | 506 | *+ estado desconectado. |
iwhalk | 0:19f9867f1730 | 507 | *+ |
iwhalk | 0:19f9867f1730 | 508 | *+ Modo AT 2 |
iwhalk | 0:19f9867f1730 | 509 | *+ - Para entrar a este estado es necesario tener presionado el botón al momento |
iwhalk | 0:19f9867f1730 | 510 | *+ de alimentar el modulo, es decir el modulo debe encender con el botón |
iwhalk | 0:19f9867f1730 | 511 | *+ presionado, después de haber encendido se puede soltar y permanecerá en |
iwhalk | 0:19f9867f1730 | 512 | *+ este estado. |
iwhalk | 0:19f9867f1730 | 513 | *+ - En este estado, para enviar comandos AT es necesario hacerlo a la velocidad |
iwhalk | 0:19f9867f1730 | 514 | *+ de 38400 baudios, esto es muy útil cuando nos olvidamos la velocidad con |
iwhalk | 0:19f9867f1730 | 515 | *+ la que hemos dejado configurado nuestro modulo. |
iwhalk | 0:19f9867f1730 | 516 | *+ - El LED del módulo en este estado parpadea lentamente. |
iwhalk | 0:19f9867f1730 | 517 | *+ |
iwhalk | 0:19f9867f1730 | 518 | *+ Los siguientes pasos son para entrar al Modo AT 1 o Modo AT 2: |
iwhalk | 0:19f9867f1730 | 519 | *+ |
iwhalk | 0:19f9867f1730 | 520 | *+ -Para entrar al modo AT 1, después de alimentar el modulo y haber encendido |
iwhalk | 0:19f9867f1730 | 521 | *+ tan solo basta presionar el botón que tiene el |
iwhalk | 0:19f9867f1730 | 522 | *+ módulo HC-05, el LED del módulo seguirá parpadeando |
iwhalk | 0:19f9867f1730 | 523 | *+ rápidamente, por lo que para saber si hemos entrado |
iwhalk | 0:19f9867f1730 | 524 | *+ al Modo AT 1 es necesario enviar comandos AT y ver |
iwhalk | 0:19f9867f1730 | 525 | *+ si responde, estos comandos se verán más adelante. |
iwhalk | 0:19f9867f1730 | 526 | *+ -Para entrar al modo AT 2, antes de alimentar o encender el modulo es necesario |
iwhalk | 0:19f9867f1730 | 527 | *+ presionar su botón, mantener presionado y alimentar |
iwhalk | 0:19f9867f1730 | 528 | *+ el modulo, después que enciende recién podemos |
iwhalk | 0:19f9867f1730 | 529 | *+ soltar el botón. Si el LED Parpadea lentamente es |
iwhalk | 0:19f9867f1730 | 530 | *+ porque ya está en Modo AT 2. |
iwhalk | 0:19f9867f1730 | 531 | *+ |
iwhalk | 0:19f9867f1730 | 532 | *+ En este tutorial enviaremos los comandos AT usando el Modo AT 2, pero también |
iwhalk | 0:19f9867f1730 | 533 | *+ es válido si están en el Modo AT 1, con la diferencia que tendrán que cambiar |
iwhalk | 0:19f9867f1730 | 534 | *+ a la velocidad con la que tienen configurado su Bluetooth (si es la primera |
iwhalk | 0:19f9867f1730 | 535 | *+ vez que configuran, la velocidad por defecto es de 9600). |
iwhalk | 0:19f9867f1730 | 536 | *+ |
iwhalk | 0:19f9867f1730 | 537 | *+ Ahora abrimos nuestro Monitor serial Tera Term, pero puedes usar |
iwhalk | 0:19f9867f1730 | 538 | *+ cualquier monitor serial. |
iwhalk | 0:19f9867f1730 | 539 | *+ |
iwhalk | 0:19f9867f1730 | 540 | *+ En la opción Setup --> Terminal debemos escoger “Ambos LF & CR” y la velocidad |
iwhalk | 0:19f9867f1730 | 541 | *+ “38400 baud” (la velocidad para comunicarse en el MODO AT 2) |
iwhalk | 0:19f9867f1730 | 542 | *+ |
iwhalk | 0:19f9867f1730 | 543 | *+ Echo esto Podemos empezar a enviar los comandos AT a nuestro Bluetooth |
iwhalk | 0:19f9867f1730 | 544 | *+ |
iwhalk | 0:19f9867f1730 | 545 | *+ Test de comunicación |
iwhalk | 0:19f9867f1730 | 546 | *+ Lo primero es comprobar si nuestro bluetooth responde a los comandos AT |
iwhalk | 0:19f9867f1730 | 547 | *+ |
iwhalk | 0:19f9867f1730 | 548 | *+ Enviar: AT |
iwhalk | 0:19f9867f1730 | 549 | *+ Recibe: OK |
iwhalk | 0:19f9867f1730 | 550 | *+ |
iwhalk | 0:19f9867f1730 | 551 | *+ Si recibimos como respuesta un OK entonces podemos continuar, sino verificar |
iwhalk | 0:19f9867f1730 | 552 | *+ las conexiones o los pasos anteriores. |
iwhalk | 0:19f9867f1730 | 553 | *+ |
iwhalk | 0:19f9867f1730 | 554 | *+ |
iwhalk | 0:19f9867f1730 | 555 | *+----------------------------------------------------------------------------- |
iwhalk | 0:19f9867f1730 | 556 | *+ |
iwhalk | 0:19f9867f1730 | 557 | *+ MODULO BLUETOOTH HC-05 |
iwhalk | 0:19f9867f1730 | 558 | *+ |
iwhalk | 0:19f9867f1730 | 559 | *+ El módulo HC-05 es un módulo Bluetooth SPP (protocolo de puerto serie) |
iwhalk | 0:19f9867f1730 | 560 | *+ fácil de usar, diseñado para una configuración de conexión serial inalámbrica |
iwhalk | 0:19f9867f1730 | 561 | *+ transparente. El módulo Bluetooth de puerto serie está totalmente calificado |
iwhalk | 0:19f9867f1730 | 562 | *+ como Bluetooth V2.0 + EDR (Velocidad de datos mejorada) Modulación de 3Mbps |
iwhalk | 0:19f9867f1730 | 563 | *+ con transceptor de radio y banda base completos de 2.4GHz. |
iwhalk | 0:19f9867f1730 | 564 | *+ Utiliza el sistema Bluetooth CSR Bluecore 04-External de un solo chip con |
iwhalk | 0:19f9867f1730 | 565 | *+ tecnología CMOS y con AFH (función de salto de frecuencia adaptable). |
iwhalk | 0:19f9867f1730 | 566 | *+ Tiene una huella tan pequeña como 12.7 mm x 27 mm. |
iwhalk | 0:19f9867f1730 | 567 | *+ |
iwhalk | 0:19f9867f1730 | 568 | *+ Características del software |
iwhalk | 0:19f9867f1730 | 569 | *+ |
iwhalk | 0:19f9867f1730 | 570 | *+ o Velocidad de transmisión predeterminada: |
iwhalk | 0:19f9867f1730 | 571 | *+ 38400 bauds, Bits de datos: 8, Bit de parada: 1, Paridad: Sin paridad, |
iwhalk | 0:19f9867f1730 | 572 | *+ Control de datos: tiene. |
iwhalk | 0:19f9867f1730 | 573 | *+ Velocidad de transmisión permitidas: |
iwhalk | 0:19f9867f1730 | 574 | *+ 9600,19200,38400,57600,115200,230400,460800. |
iwhalk | 0:19f9867f1730 | 575 | *+ o Dado un pulso ascendente en PIO0, el dispositivo se desconectará. |
iwhalk | 0:19f9867f1730 | 576 | *+ o Puerto de instrucción de estado PIO1: Bajo=desconectado, Alto=conectado; |
iwhalk | 0:19f9867f1730 | 577 | *+ o PIO10 y PIO11 se pueden conectar al led rojo y azul por separado. |
iwhalk | 0:19f9867f1730 | 578 | *+ Cuando el maestro y el esclavo están emparejados, el LED rojo y azul |
iwhalk | 0:19f9867f1730 | 579 | *+ parpadea en intervalo de 1 vez/2s, mientras que el LED azul parpadea solo |
iwhalk | 0:19f9867f1730 | 580 | *+ 2 veces/s. |
iwhalk | 0:19f9867f1730 | 581 | *+ o Se conecta automáticamente al último dispositivo con alimentación de forma |
iwhalk | 0:19f9867f1730 | 582 | *+ predeterminada. |
iwhalk | 0:19f9867f1730 | 583 | *+ o Permitir que el dispositivo se conecte de forma predeterminada. |
iwhalk | 0:19f9867f1730 | 584 | *+ o CÓDIGO PIN de emparejamiento automático: "0000" por defecto |
iwhalk | 0:19f9867f1730 | 585 | *+ o Reconexión automática en 30 minutos cuando se desconecta como resultado |
iwhalk | 0:19f9867f1730 | 586 | *+ de un rango de conexión más allá. |
iwhalk | 0:19f9867f1730 | 587 | *+ |
iwhalk | 0:19f9867f1730 | 588 | *+ Características de hardware |
iwhalk | 0:19f9867f1730 | 589 | *+ |
iwhalk | 0:19f9867f1730 | 590 | *+ Sensibilidad típica de -80dBm |
iwhalk | 0:19f9867f1730 | 591 | *+ Hasta + 4dBm de potencia de transmisión de RF |
iwhalk | 0:19f9867f1730 | 592 | *+ Operación de baja potencia E/S de 1.8V a 3.6V |
iwhalk | 0:19f9867f1730 | 593 | *+ Control PIO |
iwhalk | 0:19f9867f1730 | 594 | *+ Interfaz UART con velocidad de transmisión programable |
iwhalk | 0:19f9867f1730 | 595 | *+ Con antena integrada |
iwhalk | 0:19f9867f1730 | 596 | *+ Con conector de borde |
iwhalk | 0:19f9867f1730 | 597 | *+ |
iwhalk | 0:19f9867f1730 | 598 | *+ Conexión al Módulo Bluetooth HC-05: |
iwhalk | 0:19f9867f1730 | 599 | *+ |
iwhalk | 0:19f9867f1730 | 600 | *+ / |
iwhalk | 0:19f9867f1730 | 601 | *+ BluePill HC-05 / |
iwhalk | 0:19f9867f1730 | 602 | *+ 1 Enable/Key ---o o---> GND |
iwhalk | 0:19f9867f1730 | 603 | *+ 3.3V ------ 2 Vcc |
iwhalk | 0:19f9867f1730 | 604 | *+ GND ------ 3 GND |
iwhalk | 0:19f9867f1730 | 605 | *+ Rx (PB_11) <----- 4 Tx |
iwhalk | 0:19f9867f1730 | 606 | *+ Tx (PB_10) -----> 5 Rx |
iwhalk | 0:19f9867f1730 | 607 | *+ 6 State -----------> IRQ |
iwhalk | 0:19f9867f1730 | 608 | *+ |
iwhalk | 0:19f9867f1730 | 609 | *+ Comandos AT Soportados |
iwhalk | 0:19f9867f1730 | 610 | *+ |
iwhalk | 0:19f9867f1730 | 611 | *+ Cómo configurar el modo a servidor (maestro): |
iwhalk | 0:19f9867f1730 | 612 | ** 1. Conecte PIO11 a nivel alto. (pin 34) |
iwhalk | 0:19f9867f1730 | 613 | *+ 2. Encendido, módulo en estado de comando |
iwhalk | 0:19f9867f1730 | 614 | *+ 3. Usando la velocidad en baudios 38400, se envía el comando |
iwhalk | 0:19f9867f1730 | 615 | *+ "AT+ROLE=1\r\n" |
iwhalk | 0:19f9867f1730 | 616 | *+ al módulo, con una respuesta de |
iwhalk | 0:19f9867f1730 | 617 | *+ "OK\r\n" |
iwhalk | 0:19f9867f1730 | 618 | *+ significa establecer éxitos. |
iwhalk | 0:19f9867f1730 | 619 | *+ 4. Conecte el PIO11 a nivel bajo, vuelva a encender el módulo, el módulo |
iwhalk | 0:19f9867f1730 | 620 | *+ funciona como servidor (maestro). |
iwhalk | 0:19f9867f1730 | 621 | *+ |
iwhalk | 0:19f9867f1730 | 622 | *+ Comandos AT:(todos terminan con \r\n) |
iwhalk | 0:19f9867f1730 | 623 | *+ 1. Test command: |
iwhalk | 0:19f9867f1730 | 624 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 625 | *+ AT OK - |
iwhalk | 0:19f9867f1730 | 626 | *+ 2. Reset: |
iwhalk | 0:19f9867f1730 | 627 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 628 | *+ AT+RESET OK - |
iwhalk | 0:19f9867f1730 | 629 | *+ 3. Get firmware version |
iwhalk | 0:19f9867f1730 | 630 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 631 | *+ AT+VERSION? +VERSION:<Param> Param : firmware version |
iwhalk | 0:19f9867f1730 | 632 | *+ OK |
iwhalk | 0:19f9867f1730 | 633 | *+ |
iwhalk | 0:19f9867f1730 | 634 | *+ Ejemplo: |
iwhalk | 0:19f9867f1730 | 635 | *+ AT+VERSION?\r\n |
iwhalk | 0:19f9867f1730 | 636 | *+ +VERSION:2.0-20100601 |
iwhalk | 0:19f9867f1730 | 637 | *+ OK |
iwhalk | 0:19f9867f1730 | 638 | *+ |
iwhalk | 0:19f9867f1730 | 639 | *+ 4. Restore default |
iwhalk | 0:19f9867f1730 | 640 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 641 | *+ AT+ORGL OK - |
iwhalk | 0:19f9867f1730 | 642 | *+ |
iwhalk | 0:19f9867f1730 | 643 | *+ Estado por Omisión: |
iwhalk | 0:19f9867f1730 | 644 | *+ Slave mode, pin code :1234, device name: H-C-2010-06-01 ,Baud 38400bits/s. |
iwhalk | 0:19f9867f1730 | 645 | *+ |
iwhalk | 0:19f9867f1730 | 646 | *+ 5. Get moduleaddress |
iwhalk | 0:19f9867f1730 | 647 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 648 | *+ AT+ADDR? +ADDR:<Param> Param: address of Bluetooth Module |
iwhalk | 0:19f9867f1730 | 649 | *+ OK |
iwhalk | 0:19f9867f1730 | 650 | *+ |
iwhalk | 0:19f9867f1730 | 651 | *+ Bluetooth address: NAP: UAP : LAP |
iwhalk | 0:19f9867f1730 | 652 | *+ |
iwhalk | 0:19f9867f1730 | 653 | *+ Ejemplo: |
iwhalk | 0:19f9867f1730 | 654 | *+ AT+ADDR?\r\n |
iwhalk | 0:19f9867f1730 | 655 | *+ +ADDR:1234:56:abcdef |
iwhalk | 0:19f9867f1730 | 656 | *+ OK |
iwhalk | 0:19f9867f1730 | 657 | *+ |
iwhalk | 0:19f9867f1730 | 658 | *+ 6. Set/Check module name |
iwhalk | 0:19f9867f1730 | 659 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 660 | *+ AT+NAME=<Param> OK Param: Bluetooth module name |
iwhalk | 0:19f9867f1730 | 661 | *+ AT+NAME? +NAME:<Param> (Default: HC-05) |
iwhalk | 0:19f9867f1730 | 662 | *+ OK (/FAIL) |
iwhalk | 0:19f9867f1730 | 663 | *+ |
iwhalk | 0:19f9867f1730 | 664 | *+ Ejemplo: |
iwhalk | 0:19f9867f1730 | 665 | *+ AT+NAME=HC-05\r\n set the module name to “HC-05” |
iwhalk | 0:19f9867f1730 | 666 | *+ OK |
iwhalk | 0:19f9867f1730 | 667 | *+ AT+NAME=BluePill\r\n set the module name to “BluePill” |
iwhalk | 0:19f9867f1730 | 668 | *+ OK |
iwhalk | 0:19f9867f1730 | 669 | *+ AT+NAME?\r\n |
iwhalk | 0:19f9867f1730 | 670 | *+ +NAME: BluePill |
iwhalk | 0:19f9867f1730 | 671 | *+ OK |
iwhalk | 0:19f9867f1730 | 672 | *+ |
iwhalk | 0:19f9867f1730 | 673 | *+ 7. Get the Bluetooth device name: |
iwhalk | 0:19f9867f1730 | 674 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 675 | *+ AT+RNAME?<Param1> 1. +NAME:<Param2> Param1,Param2: the address of |
iwhalk | 0:19f9867f1730 | 676 | *+ OK Bluetooth device |
iwhalk | 0:19f9867f1730 | 677 | *+ 2. FAIL |
iwhalk | 0:19f9867f1730 | 678 | *+ |
iwhalk | 0:19f9867f1730 | 679 | *+ Ejemplo:(Device address 00:02:72:od:22:24,name:BluePill) |
iwhalk | 0:19f9867f1730 | 680 | *+ AT+RNAME? 0002,72,od2224\r\n |
iwhalk | 0:19f9867f1730 | 681 | *+ +RNAME:BluePill |
iwhalk | 0:19f9867f1730 | 682 | *+ OK |
iwhalk | 0:19f9867f1730 | 683 | *+ |
iwhalk | 0:19f9867f1730 | 684 | *+ 8.Set/Check module mode: |
iwhalk | 0:19f9867f1730 | 685 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 686 | *+ AT+ROLE=<Param> OK Param: |
iwhalk | 0:19f9867f1730 | 687 | *+ AT+ ROLE? +ROLE:<Param> 0-Slave |
iwhalk | 0:19f9867f1730 | 688 | *+ 1-Master |
iwhalk | 0:19f9867f1730 | 689 | *+ |
iwhalk | 0:19f9867f1730 | 690 | *+ 9. Set/Check device class |
iwhalk | 0:19f9867f1730 | 691 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 692 | ** AT+CLASS=<Param> OK Param: Device Class |
iwhalk | 0:19f9867f1730 | 693 | *+ AT+ CLASS? 1. +CLASS:<Param> |
iwhalk | 0:19f9867f1730 | 694 | *+ OK |
iwhalk | 0:19f9867f1730 | 695 | *+ 2. FAIL |
iwhalk | 0:19f9867f1730 | 696 | *+ |
iwhalk | 0:19f9867f1730 | 697 | *+ 10. Set/Check GIAC (General Inquire Access Code) |
iwhalk | 0:19f9867f1730 | 698 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 699 | *+ AT+IAC=<Param> 1.OK Param: GIAC |
iwhalk | 0:19f9867f1730 | 700 | *+ 2.FAIL (Default: 9e8b33) |
iwhalk | 0:19f9867f1730 | 701 | *+ AT+IAC +IAC:<Param> |
iwhalk | 0:19f9867f1730 | 702 | *+ OK |
iwhalk | 0:19f9867f1730 | 703 | *+ |
iwhalk | 0:19f9867f1730 | 704 | *+ Ejemplo: |
iwhalk | 0:19f9867f1730 | 705 | *+ AT+IAC=9e8b3f\r\n |
iwhalk | 0:19f9867f1730 | 706 | *+ OK |
iwhalk | 0:19f9867f1730 | 707 | *+ AT+IAC?\r\n |
iwhalk | 0:19f9867f1730 | 708 | *+ +IAC: 9e8b3f |
iwhalk | 0:19f9867f1730 | 709 | *+ OK |
iwhalk | 0:19f9867f1730 | 710 | *+ |
iwhalk | 0:19f9867f1730 | 711 | *+ 11. Set/Check --Query access patterns |
iwhalk | 0:19f9867f1730 | 712 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 713 | *+ AT+INQM=<Param>, 1.OK Param: |
iwhalk | 0:19f9867f1730 | 714 | *+ <Param2>, 2.FAIL 0——inquiry_mode_standard |
iwhalk | 0:19f9867f1730 | 715 | *+ <Param3> 1——inquiry_mode_rssi |
iwhalk | 0:19f9867f1730 | 716 | *+ Param2: |
iwhalk | 0:19f9867f1730 | 717 | *+ Maximum number of Bluetooth |
iwhalk | 0:19f9867f1730 | 718 | *+ devices to respond to |
iwhalk | 0:19f9867f1730 | 719 | *+ Param3: |
iwhalk | 0:19f9867f1730 | 720 | *+ Timeout (1-48 : 1.28s to 61.44s) |
iwhalk | 0:19f9867f1730 | 721 | *+ |
iwhalk | 0:19f9867f1730 | 722 | *+ Ejemplo: |
iwhalk | 0:19f9867f1730 | 723 | *+ AT+INQM=1,9,48\r\n |
iwhalk | 0:19f9867f1730 | 724 | *+ OK AT+INQM\r\n |
iwhalk | 0:19f9867f1730 | 725 | ++ +INQM: 1, 9, 48 |
iwhalk | 0:19f9867f1730 | 726 | *+ OK |
iwhalk | 0:19f9867f1730 | 727 | *+ |
iwhalk | 0:19f9867f1730 | 728 | *+ 12. Set/Check PIN code: |
iwhalk | 0:19f9867f1730 | 729 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 730 | *+ AT+PSWD=<Param> OK Param: PIN code(Default 1234) |
iwhalk | 0:19f9867f1730 | 731 | *+ AT+ PSWD? + PSWD:<Param> |
iwhalk | 0:19f9867f1730 | 732 | *+ OK |
iwhalk | 0:19f9867f1730 | 733 | *+ |
iwhalk | 0:19f9867f1730 | 734 | *+ 13. Set/Checkserial parameter: |
iwhalk | 0:19f9867f1730 | 735 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 736 | *+ AT+UART=<Param>, OK Param1: Baud |
iwhalk | 0:19f9867f1730 | 737 | *+ <Param2>, Param2: Stop bit |
iwhalk | 0:19f9867f1730 | 738 | *+ <Param3> Param3: Parity |
iwhalk | 0:19f9867f1730 | 739 | *+ AT+ UART? +UART=<Param>, |
iwhalk | 0:19f9867f1730 | 740 | *+ <Param2>, |
iwhalk | 0:19f9867f1730 | 741 | *+ <Param3> |
iwhalk | 0:19f9867f1730 | 742 | *+ OK |
iwhalk | 0:19f9867f1730 | 743 | *+ Ejemplo: |
iwhalk | 0:19f9867f1730 | 744 | *+ AT+UART=115200,1,2,\r\n |
iwhalk | 0:19f9867f1730 | 745 | *+ OK |
iwhalk | 0:19f9867f1730 | 746 | *+ AT+UART? |
iwhalk | 0:19f9867f1730 | 747 | *+ +UART:115200,1,2 |
iwhalk | 0:19f9867f1730 | 748 | *+ OK |
iwhalk | 0:19f9867f1730 | 749 | *+ |
iwhalk | 0:19f9867f1730 | 750 | *+ 14. Set/Check connect mode: |
iwhalk | 0:19f9867f1730 | 751 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 752 | *+ AT+CMODE=<Param> OK Param: |
iwhalk | 0:19f9867f1730 | 753 | *+ AT+ CMODE? + CMODE:<Param> 0 - connect fixed address |
iwhalk | 0:19f9867f1730 | 754 | *+ OK 1 - connect any address |
iwhalk | 0:19f9867f1730 | 755 | *+ 2 - slave-Loop |
iwhalk | 0:19f9867f1730 | 756 | *+ |
iwhalk | 0:19f9867f1730 | 757 | *+ 15. Set/Check fixed address: |
iwhalk | 0:19f9867f1730 | 758 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 759 | ** AT+BIND=<Param> OK Param: |
iwhalk | 0:19f9867f1730 | 760 | *+ + BIND:<Param> Fixed address |
iwhalk | 0:19f9867f1730 | 761 | *+ OK (Default 00:00:00:00:00:00) |
iwhalk | 0:19f9867f1730 | 762 | *+ |
iwhalk | 0:19f9867f1730 | 763 | *+ Ejemplo: |
iwhalk | 0:19f9867f1730 | 764 | *+ AT+BIND=1234,56,abcdef\r\n |
iwhalk | 0:19f9867f1730 | 765 | *+ OK |
iwhalk | 0:19f9867f1730 | 766 | *+ AT+BIND?\r\n |
iwhalk | 0:19f9867f1730 | 767 | *+ +BIND:1234:56:abcdef |
iwhalk | 0:19f9867f1730 | 768 | *+ OK |
iwhalk | 0:19f9867f1730 | 769 | *+ |
iwhalk | 0:19f9867f1730 | 770 | *+ 16. Set/Check LED I/O |
iwhalk | 0:19f9867f1730 | 771 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 772 | *+ AT+POLAR=<Param1, OK Param1: |
iwhalk | 0:19f9867f1730 | 773 | *+ <Param2> 0-PIO8 low drive LED |
iwhalk | 0:19f9867f1730 | 774 | *+ AT+ POLAR? +POLAR=<Param1>, 1-PIO8 high drive LED |
iwhalk | 0:19f9867f1730 | 775 | *+ <Param2> Param2: |
iwhalk | 0:19f9867f1730 | 776 | ** 0-PIO9 low drive LED |
iwhalk | 0:19f9867f1730 | 777 | ** 1-PIO9 high drive LED |
iwhalk | 0:19f9867f1730 | 778 | *+ 17. Set PIO output |
iwhalk | 0:19f9867f1730 | 779 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 780 | *+ AT+PIO=<Param1>, OK Param1: |
iwhalk | 0:19f9867f1730 | 781 | *+ <Param2> PIO number |
iwhalk | 0:19f9867f1730 | 782 | *+ Param2: |
iwhalk | 0:19f9867f1730 | 783 | *+ PIO level |
iwhalk | 0:19f9867f1730 | 784 | *+ 0-low |
iwhalk | 0:19f9867f1730 | 785 | *+ 1-high |
iwhalk | 0:19f9867f1730 | 786 | *+ Ejemplo: |
iwhalk | 0:19f9867f1730 | 787 | *+ 1. PIO10 output high level |
iwhalk | 0:19f9867f1730 | 788 | *+ AT+PI0=10,1\r\n |
iwhalk | 0:19f9867f1730 | 789 | *+ OK |
iwhalk | 0:19f9867f1730 | 790 | *+ |
iwhalk | 0:19f9867f1730 | 791 | *+ 18. Set/Check –scan parameter |
iwhalk | 0:19f9867f1730 | 792 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 793 | *+ AT+IPSCAN=<Param1>, OK Param1: Query time interval |
iwhalk | 0:19f9867f1730 | 794 | *+ <Param2>, Param2:Query duration |
iwhalk | 0:19f9867f1730 | 795 | *+ <Param3>, Param3:Paging interval |
iwhalk | 0:19f9867f1730 | 796 | *+ <Param4> Param4:Call duration |
iwhalk | 0:19f9867f1730 | 797 | *+ AT+IPSCAN? +IPSCAN:<Param1>, |
iwhalk | 0:19f9867f1730 | 798 | *+ <Param2>, |
iwhalk | 0:19f9867f1730 | 799 | *+ <Param3>, |
iwhalk | 0:19f9867f1730 | 800 | *+ <Param4> |
iwhalk | 0:19f9867f1730 | 801 | *+ OK |
iwhalk | 0:19f9867f1730 | 802 | *+ Ejemplo: |
iwhalk | 0:19f9867f1730 | 803 | *+ AT+IPSCAN=1234,500,1200,250\r\n |
iwhalk | 0:19f9867f1730 | 804 | *+ OK |
iwhalk | 0:19f9867f1730 | 805 | *+ AT+IPSCAN? |
iwhalk | 0:19f9867f1730 | 806 | *+ +IPSCAN:1234,500,1200,250 |
iwhalk | 0:19f9867f1730 | 807 | *+ |
iwhalk | 0:19f9867f1730 | 808 | *+ 19. Set/Check –SHIFF parameter |
iwhalk | 0:19f9867f1730 | 809 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 810 | *+ AT+SNIFF=<Param1>, OK Param1: Max time |
iwhalk | 0:19f9867f1730 | 811 | *+ <Param2>, Param2: Min time |
iwhalk | 0:19f9867f1730 | 812 | *+ <Param3>, Param3: Retry time |
iwhalk | 0:19f9867f1730 | 813 | *+ <Param4> Param4: Time out |
iwhalk | 0:19f9867f1730 | 814 | *+ AT+SNIFF? +SNIFF:<Param1>, |
iwhalk | 0:19f9867f1730 | 815 | ** <Param2>, |
iwhalk | 0:19f9867f1730 | 816 | ** <Param3>, |
iwhalk | 0:19f9867f1730 | 817 | *+ <Param4> |
iwhalk | 0:19f9867f1730 | 818 | *+ OK |
iwhalk | 0:19f9867f1730 | 819 | *+ |
iwhalk | 0:19f9867f1730 | 820 | *+ 20. Set/Check securitymode |
iwhalk | 0:19f9867f1730 | 821 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 822 | *+ AT+SENM=<Param1>, 1.OK Param1: |
iwhalk | 0:19f9867f1730 | 823 | *+ <Param2> 2.FAIL 0——sec_mode0+off |
iwhalk | 0:19f9867f1730 | 824 | *+ AT+ SENM? +SENM:<Param1>, 1——sec_mode1+non_secure |
iwhalk | 0:19f9867f1730 | 825 | *+ <Param2> 2——sec_mode2_service |
iwhalk | 0:19f9867f1730 | 826 | *+ OK 3——sec_mode3_link |
iwhalk | 0:19f9867f1730 | 827 | *+ 3——sec_mode3_link |
iwhalk | 0:19f9867f1730 | 828 | *+ 4——sec_mode_unknown |
iwhalk | 0:19f9867f1730 | 829 | *+ Param2: |
iwhalk | 0:19f9867f1730 | 830 | ** 0——hci_enc_mode_off |
iwhalk | 0:19f9867f1730 | 831 | *+ 1——hci_enc_mode_pt_to_pt |
iwhalk | 0:19f9867f1730 | 832 | *+ 2——hci_enc_mode_pt_to_pt_and_bcast |
iwhalk | 0:19f9867f1730 | 833 | *+ |
iwhalk | 0:19f9867f1730 | 834 | *+ 21. DeleteAuthenticated Device |
iwhalk | 0:19f9867f1730 | 835 | *+ Comando Respuesta Parámetros |
iwhalk | 0:19f9867f1730 | 836 | *+ AT+PMSAD=<Param> OK Param: Authenticated Device Address |
iwhalk | 0:19f9867f1730 | 837 | *+ |
iwhalk | 0:19f9867f1730 | 838 | *+ Ejemplo: |
iwhalk | 0:19f9867f1730 | 839 | *+ AT+PMSAD=1234,56,abcdef\r\n |
iwhalk | 0:19f9867f1730 | 840 | *+ OK |