i would like to connect STM32F4 with ELM327 via bluetooth using HC-05. I've got some specifc problem. Everytime when i try to use "AT+LINK", the HC-05 responds "FAIL".
Hardware:
- STM32F411V + HC-05
- iCar2 Vgate elm327 BT v3.0
I've already done:
- I've tested ELM327 with commercial Apps, terminals etc. - it connected, and worked well.
- I've tested HC-05 - configured, worked very well with BT terminals
- Tried to use diffrent configuration of AT Commands to get autoconnection between Elm327 and HC - everytime "FAIL".
This is part of code, which i used:
HAL_UART_Receive_IT(&huart2, BufforMsg, 1);
HAL_Delay(10000);
HAL_UART_Transmit(&huart2, (uint8_t *)"AT+ORGL\r\n", strlen("AT+ORGL\r\n"), 100); //HC-05:OK
HAL_Delay(1000);
HAL_UART_Transmit(&huart2, (uint8_t *)"AT+NAME=MASTER\r\n", strlen("AT+NAME=MASTER\r\n"), 100); //HC-05:OK
HAL_Delay(1000);
HAL_UART_Transmit(&huart2, (uint8_t *)"AT+UART=9600,1,0\r\n", strlen("AT+UART=9600,1,0\r\n"), 100); //HC-05:OK
HAL_Delay(1000);
HAL_UART_Transmit(&huart2, (uint8_t *)"AT+RESET\r\n", strlen("AT+RESET\r\n"), 100); //HC-05:OK
HAL_Delay(1000);
HAL_UART_Transmit(&huart2, (uint8_t *)"AT+ROLE=1\r\n", strlen("AT+ROLE=1\r\n"), 100); //HC-05:OK
HAL_Delay(1000);
HAL_UART_Transmit(&huart2, (uint8_t *)"AT+PSWD=1234\r\n", strlen("AT+PSWD=1234\r\n"), 100); //HC-05:OK
HAL_Delay(1000);
HAL_UART_Transmit(&huart2, (uint8_t *)"AT+INIT\r\n", strlen("AT+INIT\r\n"), 100); //HC-05:OK
HAL_Delay(10000);
HAL_UART_Transmit(&huart2, (uint8_t *)"AT+RMAAD\r\n", strlen("AT+RMAAD\r\n"), 100); //HC-05:OK
HAL_Delay(1000);
HAL_UART_Transmit(&huart2, (uint8_t *)"AT+PAIR=86DC,B0,ABF7F1,20\r\n", strlen("AT+PAIR=86DC,B0,ABF7F1,20\r\n"), 100); //HC-05:OK
HAL_Delay(21000);
HAL_UART_Transmit(&huart2, (uint8_t *)"AT+BIND=86DC,B0,ABF7F1\r\n", strlen("AT+BIND=86DC,B0,ABF7F1\r\n"), 100); //HC-05:OK
HAL_Delay(3000);
HAL_UART_Transmit(&huart2, (uint8_t *)"AT+LINK=86DC,B0,ABF7F1\r\n", strlen("AT+LINK=86DC,B0,ABF7F1\r\n"), 100); //HC-05:FAIL + INQ: Mac Address
HAL_Delay(3000);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, 0 );
I've tried also diffrent configurations of these commands, but all the time the same -> FAIL. Btw. I know that i set buadrate 9600, but it doesnt matter in AT Commands mode. The light on HC blinks very fast of 1s, then blinks slowly (as well as in connected mode) for 2s, but then blinks again very fast and then again slowly and over and over again. I guess the HC is trying to connect to the Elm all the time. The mac address is correct - i used few MacAdress scanners and the address is similar everywhere. The ELM327 require password every time when i connect to it (even if the device is paired with my smartphone). I read probably all topics on StakOVF and others sites. The solutions, which i found, didnt work. Has anyone idea, what's wrong?