WLAN ESP8266 component on software uart?

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

WLAN ESP8266 component on software uart?

Post by stefan.erni »

Is it possible to use the Flowcode WLAN ESP8266 component on software uart?
It just shows me hardware uart pins.
ESP8266-52.PNG
(63.37 KiB) Downloaded 8572 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by LeighM »

Hi,
There are a lot of data transactions on the UART, so we use hardware with interrupts and buffers,
hence software UART is not selectable, it would not work too well.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by stefan.erni »

Hi LeighM

ok. I understand.Unfortunately the board has only one uart and this is connected with the USB.
The ESP8266 is connected with "normal" pins and used only with 19200kB.
It's a board with a arduino nano and an esp8266 together.
I can program it with the rs232 component from FC7 with the AT command. It's working for simply commands.
But I would like the componete of FC7 to use.

Should I simply take another board?

http://duinorasp.hansotten.com/pretzelb ... rol-duino/
NanoESP.PNG
(455.25 KiB) Downloaded 8559 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by Benj »

Hello,

It looks like a nice board but shame about the lack of a hardware UART to communicate with the ESP module. Using a software UART to talk with the ESP module will work but I can't see it being reliable. For instance if you are doing something when data starts to come in then you will essentially miss the data or receive corrupt data. This is not the case when you have a hardware UART and hence why we designed the Flowcode ESP component to only work with hardware UARTs. We also rely on the UART receive interrupt to populate our internal buffer so we don't have to continually poll for incoming data so moving away from this would be a significant change to the component.

If possible I would consider moving to another device with a hardware UART available for the ESP module.

I'll have a think on a software implementation but to me it just sounds like a bad idea. It may be possible to replace the UART receive interrupt with a pin change based interrupt so I will have a quick look into this for you.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by stefan.erni »

Hi Ben

Yes, I agree with you.
Your idea to give the software uart an interrupt, I think this is very good.
I already missed this in another project.
Would that be possible for FC7.3?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by Benj »

Right I've done some mods to the component. I have not added anything new so I would only advise using this new component if you want the software UART option. I won't be including this in the updates release as its currently a bit hacky but hopefully should work and allow you to use your board.

First copy this component file into your "Flowcode 7/Components" folder. Maybe making a backup of the original file so you can go back if you need to.
WLAN_ESP8266.fcpx
(19.71 KiB) Downloaded 257 times
Next here is an example project showing how the pin interrupt should work.
DemoProj.fcfx
(8.01 KiB) Downloaded 280 times
Let us know how you get on.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by stefan.erni »

Hi Ben

I have tried but I can not set the ssid....
And I can not understand where I have to read the response from all the commands.
In your demo, you dont read a response.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by stefan.erni »

Hi Ben
I use again the original componente esp8266 and I have tried on an another board.

https://shop.mikroe.com/clicker-pic32mx

https://shop.mikroe.com/wifi-3-click

It has five Uart and Uart5 is connected to the clickboard with an esp8266

But there is an error if I use uart5 (this is not if I compiele it with uart1)
***************************************************************************************************************** ^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_UART.c:453:4: note: in expansion of macro 'MX_UART_INT_CH5_EN'
MX_UART_INT_CH5_EN;
^
C:\Program Files (x86)\Flowcode 7\CAL\PIC32BIT\PIC32BIT_CAL_UART.c:232:31: note: each undeclared identifier is reported only once for each function it appears in
#define MX_UART_INT_CH5_EN IEC5bits.U5RXIE = 1

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by stefan.erni »

Hi Ben
I still had an idea. I connected the clickboard wifi3 to the STM32F469i Disco. This board still has two uart free. All the worse, this error message surprised me......

Flowcode_stm32f469i_touchscreen_test.c: In function 'USART2_IRQHandler':
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_UART.c:124:57: error: 'MX_HANDLE_UART2' undeclared (first use in this function)
void USART2_IRQHandler(void) {HAL_UART_IRQHandler(&(MX_HANDLE_UART2)); HAL_UART_Receive_IT(&(MX_HANDLE_UART2), (uint8_t *)&(MX_HANDLE_UART2_RX_VAL), 1);} \

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by LeighM »

Thanks for the info, looks like Ben and I have some work to do on Monday :roll:

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by LeighM »

Hi,

Could you please drop this updated UART component into your /components directory.
This should fix the ST ARM issue.

What PIC32 chip were you using?
As that error looks like it could be an FCD issue.

Thanks
Leigh
Attachments
cal_uart.fcpx
(11.07 KiB) Downloaded 227 times

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by stefan.erni »

Hi LeighM

Super Thank you
Yes the ST Board is working with the update.

On the Board is the
32-bit PIC32MX534F064H
more info under

https://shop.mikroe.com/clicker-pic32mx

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by stefan.erni »

Hi LeighM

With all these AT command test it would be easier if the USB interface could be used. Do you know if it's possible with the PIC 32 to use USB?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by Benj »

Hello,

USB is not currently available on PIC32 but we are working on it. We have it working as of last week but we are currently trying to simplify and remove the requirement for the Harmony library as it's complicated to get it working at the moment.

I'll look into the compilation problem on the mentioned device and see if I can find the cause of the issue.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by Benj »

I use again the original componente esp8266 and I have tried on an another board.

It has five Uart and Uart5 is connected to the clickboard with an esp8266

But there is an error if I use uart5 (this is not if I compiele it with uart1)
This should fix the PIC32 compile issue on UART channel 5.

Simply copy to your "Flowcode 7/CAL/PIC32" folder.
PIC32BIT_CAL_UART.c
(27.57 KiB) Downloaded 183 times
Let us know how you get on.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by stefan.erni »

I am still busy with the STM32F469 board. I can now use the ESP8266 component. I init the component and afterwards I put the ESP8266 as an AP. that will not do. But if I change uart3 and uart6 and send the command with the UART, I can set the SSID.(cable, speed and hardware is OK)
Is there a possible to see what the ESP8266 componente responds?
The board has a touchscreen ...
If I check the "init" it's always in the Loop. If I dont check it .... it's not working
also. If I test the output(TX) from the esp8266 the osziloscope show me some signals.
Here the SC.
Flowcode_stm32f469i_touchscreen_test.fcfx
(21.53 KiB) Downloaded 180 times

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by stefan.erni »

Hi Ben
This should fix the PIC32 compile issue on UART channel 5
Yes it fixed the issue with the UART.
But unfortunately I can not change the SSID.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by stefan.erni »

It's working now with the STM32F469 Board

Sorry I did not see the option "command termination". I have to change it from '"\r " to "\r\n" for the modul I used.

https://www.sparkfun.com/products/13678
ESP8266_rn.PNG
(14.81 KiB) Downloaded 8430 times

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by stefan.erni »

Hi LeighM

Now my STM32F469 with the ESP8266 works very well.

On the STM32F469 disco board, the USART6 is available twice.
Once on the "Arduino connector" and once on the ExtensionConnector

Can I switch this with flowcode alternatively?

extension.PNG
(26.2 KiB) Downloaded 8393 times
usart6_on_g9.PNG
(18.95 KiB) Downloaded 8393 times
usart6_on_c6.PNG
(7.9 KiB) Downloaded 8393 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by Benj »

Can I switch this with flowcode alternatively?
Hmm, maybe, try adding two UART components to your project, both on Channel 6 but with different pin connections.

When you want to use the first connections initialise the first UART component and then use this to communicate.

When you want to use the second connections then initialise the second UART component and then use this.

Repeat as required.

Hopefully there will be no collisions in the low level C code but Leigh might know better.

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by stefan.erni »

Hi Ben


I would like to connect the ESP8266 at Pin C6 and C7.
But there is no possibility the pin remap or something like that.
At the ArduioneConnector I put a Datalogging plate.
Later I'll make a PCB board where the ESP8266 and the hardware from the datalogger are on one board. But for one version, the ESP always remains connected to the same pin. Maybe I do not know how to remaped the pins ...
Flowcode_stm32f469i_touchscreen_webserver1.fcfx
(27.72 KiB) Downloaded 175 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by LeighM »

Hi,
I've updated and attached the FCD to give you access to pins on port C6 and C7
Just drop it into your Flowcode7\FCD\ARM directory
Leigh
Attachments
32F469Discovery.fcdx
(33.9 KiB) Downloaded 134 times

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: WLAN ESP8266 component on software uart?

Post by stefan.erni »

Hi LeighM

Thank you. It's working nice.The advantage is also that the signals and powersupply are the same plug on the STM32 board.

Post Reply