2020-03-31 03:55 AM
Board: STM32 NUCLEO F103RB (MB1136 C-01)
Wire cable with ESP8266: UART1_tx (PA9) -> RX_ESP8266 and UART1_rx (PA10) -> TX_ESP8266
Hi all,
I try to send AT command between board and ESP8266, without success.
I send the command but I don't see no reply.
The UART baud rate is: 115200 baud.
Below the code:
char data[] = "AT\r\n"; //I want send: AT
char rsp[6]; //I expect the response OK: \r\nOK\r\n, six character
HAL_UART_Transmit(&huart1, (uint8_t*)data, strlen(data) , 10000); \\Send command
HAL_UART_Transmit(&huart2, (uint8_t*)data, strlen(data) , 10000); \\Show the command sent on serial monitor
HAL_Delay(100);
HAL_UART_Receive(&huart1, (uint8_t*)rsp, strlen(rsp), 10000); \\In rsp, i expect the respons: OK
HAL_UART_Transmit(&huart2, (uint8_t*)rsp, strlen(data) , 10000); \\Show the response on serial monitor
Can you help me?
Solved! Go to Solution.
2020-04-02 03:03 AM
I have configure ESP8266 with success, but i can't send html page. Below the steps:
1) Send: AT+CIPSERVER=1,80 -> ESP8266 as server, listen on port 80
2) On Client (my phone) I write on the browser: 192.168.4.1:80 -> this is the ip of the ESP8266
3) I Receive the ESP8266 response:
4) I Send: AT+CIPSEND=0,184 -> I want send my html page to my phone, the page content 184 character or 184 byte
5) I receive '>' character
6) I run this code:
char web_page[] =
"<!doctype html>\r\n"
"<html lang=\"it\">\r\n"
"<head><title>Connected</title></head>\r\n"
"<body>\r\n"
"<body bgcolor = \"6699FF\">\r\n"
"<h1>Hello!</h1>\r\n"
"<p>You're connect!</p>\r\n"
"</body>\r\n"
"</html>\r\n"
HAL_UART_Transmit(&huart1, (uint8_t*)web_page, strlen(web_page) , 10000);
memset(rsp,0,sizeof(rsp)); //char rsp[500];
HAL_UART_Receive(&huart1, (uint8_t *)rsp, sizeof(rsp)-1, 10000);
HAL_UART_Transmit(&huart2, (uint8_t*)rsp, strlen(rsp) , 10000);
The original code of html page that i want send is:
<!doctype html>
<html lang="it">
<head><title>Connected</title></head>
<body>
<body bgcolor = "6699FF">
<h1>Hello!</h1>
<p>You're connect!</p>
</body>
</html>
but after CHIPSEND, i wait a long time without receiving anything on the phone browser. If i close the browser receive SEND FAIL.
My opinion is that the html page is write in C wrong, I'm not sure that to enter "\r\n" for every line and maybe a server should response in different mode. Can you help me?
2024-08-28 10:47 AM
I realise this response is 4 years old so I apologise for being late to the party but I am having the same issue as the OP. When I attempt to send AT commands in code, with a similar approach, I receive no response from the modem, but have tested the same commands manually with success. Could you elaborate on the approach you have outlined here? The eventual system I am attempting to implement will receive CAN BUS traffic with a NUCLEO-F429ZI and send it via MQTT to *some broker* through a SIM7600G-H modem. I am at the stage of trying to get the modem to send AT commands and receive a response from the modem; the CAN part will come later. The AT command and response set on manual testing is as follows:
AT
OK
AT+CGSOCKCONT=1,"IP","telstra.internet"
OK
AT+CMQTTSTART
+CMQTTSTART: 0
OK
AT+CMQTTACCQ=0,"client01"
OK
AT+CMQTTCONNECT=0,"tcp://test.mosquitto.org:1883",60,1
OK
+CMQTTCONNECT: 0,0
AT+CMQTTTOPIC=0,9
>pot/adc/1
OK
AT+CMQTTPAYLOAD=0,8
>01011011
OK
AT+CMQTTPUB=0,1,60
OK
+CMQTTPUB: 0,0
AT+CMQTTDISC=0,120
+CMQTTDISC: 0,0
OK
AT+CMQTTREL=0
OK
AT+CMQTTSTOP
+CMQTTSTOP: 0
OK
+CMQTTNONET
Context: I am a 3rd year mechatronics engineering student and am very new to embedded systems engineering.