Some help with a simple UART program

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Some help with a simple UART program

Jump to solution
1,467 Views
vincent_kenbeek
Contributor II

I have a FRDM-KL25Z connected to an ESP 01 through UART1.

The polling example provided with the SDK seems pretty simple, however when I adjust it to print the received data instead of echoing it, it prints the data I sent to the ESP 01 instead of the data I should have received from it.

My code look as follows:

uint8_t txbuff[] = "AT+GMR\r\n";
uint8_t rxbuff[20] = {0};

int main(void)
{
    uint8_t ch;
    uart_config_t config;

    BOARD_InitPins();
    BOARD_BootClockRUN();

    UART_GetDefaultConfig(&config);
    config.baudRate_Bps = BOARD_DEBUG_UART_BAUDRATE;
    config.enableTx = true;
    config.enableRx = true;

    UART_Init(DEMO_UART, &config, DEMO_UART_CLK_FREQ);


    UART_WriteBlocking(DEMO_UART, txbuff, sizeof(txbuff) - 1);
    UART_ReadBlocking(DEMO_UART, &rxbuff, 6);
    printf("%s\n", rxbuff);
}

The printf all the way at the bottom prints "AT+GMR" which is the string that I sent to the ESP 01.

The response should be something along the lines of "00170901".

How can I see what the response from the ESP 01?

Labels (1)
Tags (2)
0 Kudos
1 Solution
1,188 Views
mjbcswitzerland
Specialist V

Hi

It sounds as though the ESP-01 has echo enabled (typical default for AT interfaces) and so you will receive the string that you send to it.
Either reconfigure it to not echo or read once (as you do) to discard the echo and then read again to read the response.

Regards

Mark


Complete Kinetis solutions for professional needs, training and support: http://www.utasker.com/kinetis.html
Kinetis KL25, KL26, KL27, KL28, KL43, KL46, KL82
- http://http://www.utasker.com/kinetis/FRDM-KL25Z.html
- http://www.utasker.com/kinetis/TWR-KL25Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL26Z.html
- http://www.utasker.com/kinetis/TEENSY_LC.html
- http://www.utasker.com/kinetis/FRDM-KL27Z.html
- http://www.utasker.com/kinetis/Capuccino-KL27.html
- http://www.utasker.com/kinetis/FRDM-KL28Z.html
- http://www.utasker.com/kinetis/FRDM-KL43Z.html
- http://www.utasker.com/kinetis/TWR-KL43Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL46Z.html
- http://www.utasker.com/kinetis/TWR-KL46Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL82Z.html
uTasker: supporting >1'000 registered Kinetis users get products faster and cheaper to market
Request Free emergency remote desk-top consulting at http://www.utasker.com/services.html

Open Source version at https://github.com/uTasker/uTasker-Kinetis

View solution in original post

3 Replies
1,189 Views
mjbcswitzerland
Specialist V

Hi

It sounds as though the ESP-01 has echo enabled (typical default for AT interfaces) and so you will receive the string that you send to it.
Either reconfigure it to not echo or read once (as you do) to discard the echo and then read again to read the response.

Regards

Mark


Complete Kinetis solutions for professional needs, training and support: http://www.utasker.com/kinetis.html
Kinetis KL25, KL26, KL27, KL28, KL43, KL46, KL82
- http://http://www.utasker.com/kinetis/FRDM-KL25Z.html
- http://www.utasker.com/kinetis/TWR-KL25Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL26Z.html
- http://www.utasker.com/kinetis/TEENSY_LC.html
- http://www.utasker.com/kinetis/FRDM-KL27Z.html
- http://www.utasker.com/kinetis/Capuccino-KL27.html
- http://www.utasker.com/kinetis/FRDM-KL28Z.html
- http://www.utasker.com/kinetis/FRDM-KL43Z.html
- http://www.utasker.com/kinetis/TWR-KL43Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL46Z.html
- http://www.utasker.com/kinetis/TWR-KL46Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL82Z.html
uTasker: supporting >1'000 registered Kinetis users get products faster and cheaper to market
Request Free emergency remote desk-top consulting at http://www.utasker.com/services.html

Open Source version at https://github.com/uTasker/uTasker-Kinetis

1,188 Views
vincent_kenbeek
Contributor II

Thank you so much Mark, echo was indeed turned on on the ESP.

I had no idea that was even an option.

0 Kudos
1,188 Views
nxf51211
NXP Employee
NXP Employee

Hi Vincent,

When you debug your project, if you place your cursor over the "rxbuff" variable (when you receive a new character) you will see the values stored inside the array. In the following example I've sent the "b" character to my board (which is highlighted as the new value added to the rxbuff array).

pastedImage_1.png

By the way, please make sure that your connections between your board and the ESP-01 are correct (TX from board is connected to RX of ESP-01 and vice versa).

Best Regards, 

Ricardo Delsordo

0 Kudos