Announcements

Ever wondered how you could shape the future in collaboration with others? Join us at OktoberTech Asia Pacific and get inspired. Click here to sign up FREE of charge.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 5, 3 & 1 Forum Discussions

Y_r
Level 4
50 sign-ins 25 replies posted 25 sign-ins
Level 4

Hello,

If anyone has succeeded in interfacing PSOC 5LP with an ESP-01 module, a sample to get started with, would be a great way for me to start.

Also, for now, the main application is to use PSOC as a pass-through between the PC and ESP module and later on develop the firmware to initialize and connect the ESP to the internet using just PSOC.

USE CASE:
One of the PSOC's UART (UART_1) will be connected to the PC and accept commands like "AT", etc..., from the PC terminal and then forward the data to the ESP connected over the UART_2.
Once the ESP receives the command, the ESP responds with a reply (like "OK") and PSOC needs to read this response from UART_2 and pass it along to the PC terminal over UART_1.

It would be great if anyone could help me with this one.

 

Thanks and Regards,
Yash

0 Likes
1 Solution
Len_CONSULTRON
Level 9
1000 replies posted 750 replies posted 500 likes received
Level 9

Yash,

I modified your project with 2 UARTs to show how simple it is to pass data unmodified from the PC host and the ESP-01.

In this code, I just take the Host input (Host_Tx) and push it to the ESP Rx pin.   When the ESP Tx has data it is sent to the Host_Rx.  It then shows up as-is at the Host terminal output.

For this project since I don't have an ESP-01 module I left the ESP Rx and Tx pin on P1.7 and P1.6.  This is NOT ADVISABLE since as I indicated earlier that these pins will max out at 5V instead of the max of 3.3V.

Additionally because I don't have an ESP, I short out P1.7 and P1.6 to push the ESP Tx to the ESP Rx.

This shorting of the ESP Tx and Rx allows me to make sure every character I send from the host is echoed back to the host.

Project Description:

For every UART_CMD byte received, I push it to the UART_GSM Tx.

For every UART_GSM byte received, I push it to the UART_CMD Tx.

The UARTs are used but they are just pass-thrus and no data processing of the UART data occurs on the PSoC.   If PSoC processing is needed, the code can be modified.  In this project, you issue the AT commands at the host and receive the results from the ESP-01 on the Host terminal output.  This is a good starting point to prove that the host to ESP interface is working.

You mentioned:


PS: The CH_PD/EN pin of the ESP was connected to GND in my hardware setup.

 

 If CH_PD is tied to GND, the ESP-01 module is powered down and not enabled.   CH_PD = 3.3V causes the program in the ESP-01 to recognise commands through the UART interface.   This could be the cause of why the ESP is not responding at a minimum.

My warning about the ESP-01 VCC power input and other inputs exceeding 3.3V should not be ignored.  It is HIGHLY possible to permanently damage the module above 3.6V.

 

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

33 Replies
EvPa_264126
Level 7
500 replies posted 250 replies posted 100 likes received
Level 7

I did several projects(Russian), but they are very old.

0 Likes
EvPa_264126
Level 7
500 replies posted 250 replies posted 100 likes received
Level 7

I have 2 projects (in Russian), but they are very old.
- AP_Serwer.zip ( PSoC3)
- PSoC4_ESP8266_ST_WDT.zip ( PSoC4)

0 Likes
EvPa_264126
Level 7
500 replies posted 250 replies posted 100 likes received
Level 7

I have 2 projects (in Russian), but they are very old.
- AP_Serwer.zip ( PSoC3)
- PSoC4_ESP8266_ST_WDT.zip ( PSoC4)

0 Likes
EvPa_264126
Level 7
500 replies posted 250 replies posted 100 likes received
Level 7

У меня есть 2 проекта (на русском), но они очень старые.
AP_Serwer.zip (PSoC3) and PSoC4_ESP8266_ST_WDT.zip
(_http://mylab.wmsite.ru/moi-razrab/cypress-psoc/rabota-s-wifi/)

0 Likes
EvPa_264126
Level 7
500 replies posted 250 replies posted 100 likes received
Level 7

I have 2 projects (in Russian), but they are very old.
AP_Server.zip (PSoC3) and PSoC4_ESP8266_ST_WDT.zip
I can't add a link - the message is being deleted as spam.
Evgeny

0 Likes
EvPa_264126
Level 7
500 replies posted 250 replies posted 100 likes received
Level 7

(_http://mylab.wmsite.ru/moi-razrab/cypress-psoc/rabota-s-wifi/)

0 Likes
Y_r
Level 4
50 sign-ins 25 replies posted 25 sign-ins
Level 4

Hi Evgeny,

Thank you for pointing to the thread and the link, but unfortunately, after I changed the device to PSOC5 LP and using appropriate updated components in the design and building the code.

There is no display on LCD (only black boxes) and no output on the UART terminal as well.
Also, when I tried debugging the firmware in debug view, the control is always struck at the following line as in below image and never does anything else:

Yash_r_0-1644262765837.png

PS: I tried the AP_server.zip firmware above.

 

Thanks and Regards,
Yash

0 Likes
EvPa_264126
Level 7
500 replies posted 250 replies posted 100 likes received
Level 7

mylab.wmsite.ru/moi-razrab/cypress-psoc/rabota-s-wifi/

0 Likes
EvPa_264126
Level 7
500 replies posted 250 replies posted 100 likes received
Level 7
0 Likes
ETRO_SSN583
Level 9
100 sign-ins 5 likes given 1000 replies posted
Level 9

A very interesting GUI tool for doing code for ESP8266 can be found at 

http://easycoding.tn/tuniot/demos/code/    Free if you use it online.

Here is an example solution done in roughly an hour from scratch -

https://www.electro-tech-online.com/articles/verizon-hotspot-remote-control.949/

 

Regards, Dana.

0 Likes
Y_r
Level 4
50 sign-ins 25 replies posted 25 sign-ins
Level 4

Hi Dana,

The GUI tool would come in handy when developing application to be run standalone on the ESP, but would not be useful in my use case since I want the PSOC to act as a middleman between the PC and ESP (and ESP has a blank sketch uploaded to it).

Thanks and Regards,
Yash

0 Likes
ETRO_SSN583
Level 9
100 sign-ins 5 likes given 1000 replies posted
Level 9

Actually, I think you could use TUNIOT and Creator, depending on what you are doing.

 

Regards, Dana.

0 Likes
EvPa_264126
Level 7
500 replies posted 250 replies posted 100 likes received
Level 7

Try the option for Creator4.3

If there is no ESP01 you will see NO DEVICE:!!!  on LCD  (3.3V)

PSoC resets ESP01 (pin RST)
and listens for its initialization start message.

the message must contain a known fragment (in my firmware "eady" )

main.c
52     if (!WaitText("eady", 1000))....

Only after this fragment is found does the UART start working.

You can replace this line with a simple delay

0 Likes
Y_r
Level 4
50 sign-ins 25 replies posted 25 sign-ins
Level 4

Hi Evgeny,

"the message must contain a known fragment (in my firmware "eady" )"
>> Is this "eady" message supposed to come from the ESP? 
Like, does a sketch need to be uploaded in the ESP, which sends the "eady" message in the void main() function after reset?

It would be great if you could provide steps on how to test your project with the CY8CKIT-059 (PSOC5 LP?.

Thanks and Regards,
Yash

0 Likes
EvPa_264126
Level 7
500 replies posted 250 replies posted 100 likes received
Level 7

At the beginning, it is not necessary to upload the sketch to the ESP:
When you first turn on the ESP01, it displays a message via UART about its readiness (it seems baudrate 57600).
For different firmware, these messages are different. For example Ready or ready.
Therefore, I'm waiting for the "eady" fragment that is common to all.
Can you connect your PC and ESP01 and see this message in any terminal program ?
if enter the AT command, OK should come in response.

For test your project with the CY8CKIT-059
You can use UART_Full_Duplex example (File->CodeExample...)
to send AT commands

0 Likes
Y_r
Level 4
50 sign-ins 25 replies posted 25 sign-ins
Level 4

Hi Evgeny,

"For test your project with the CY8CKIT-059
You can use UART_Full_Duplex example (File->CodeExample...)
to send AT commands"
>> I tried doing as advised, but as I understand the UART_Full_Duplex example is a loopback example, and so the text received from the terminal (AT in blue) is looped back and sent to the terminal again, AT in green (and not the response "OK" for "AT" from the ESP) as can be seen below:

Yash_r_0-1644305416458.png

 

Also, when the device is connected and the RST of ESP is pulled to GND, the following text and a bunch of ERROR messages is seen on the terminal as below:

Yash_r_1-1644305485059.png

PS: I can see the ready message once the RST is pulled to GND.

Can you advise on what I can change to get the response from the ESP instead of the looped back text in the example?

Regards,
Yash

0 Likes
ETRO_SSN583
Level 9
100 sign-ins 5 likes given 1000 replies posted
Level 9

Is "eady" something you can guarantee for open source firmware and

product evolution ? Not so sure of this.

Maybe you can contact vendor and find if there is specific JTAG like  info, or

hard wired product ID, that will ALWAYS be there until product is discontinued.

 

Just a thought.

 

Regards, Dana.

0 Likes
EvPa_264126
Level 7
500 replies posted 250 replies posted 100 likes received
Level 7

I see that you have connected PC and PSoC and the UART_Full_Duplex example works.
Yes, PSoC just returns an echo.
I see that you also connected ESP01 and it also responded at a speed of 115200 :
ai-thinker technology co. ltd
and then ready.

those. connection is correct and baud rate = 115200

judging by the screenshot, you have 3 devices on the line: PC PSoC and ESP01
Only 2 are allowed.
First connect only the PC and ESP01 (I hope you are using TTL negotiation) and try to use the terminal to send AT commands.

 

0 Likes
Y_r
Level 4
50 sign-ins 25 replies posted 25 sign-ins
Level 4

Hi Evgeny,

I used the UART_FullDuplex example, and connected the ESP's TX and RX to PSOC_UART_RX (P12[6]) and PSOC_UART_TX (P12[7]), and shared the above terminal screenshots where the AT loopback is being seen on the PC terminal instead of an "OK" response from the ESP.

"Only 2 are allowed."
>> Why are only 2 devices allowed and not 3, even when there is a chance to configure up to 24 UDB's in the PSOC5 LP (mentioned in datasheet Pg.1, under Digital Peripherals)?

"First connect only the PC and ESP01 (I hope you are using TTL negotiation) and try to use the terminal to send AT commands."
>> This works which can be seen in the below snapshot of the connection between PC and ESP, with the help of an Arduino (being used as a middleman UART translator) and the ESP responds to the AT commands properly. 
The snapshot:

Yash_r_0-1644326273872.png

How would you suggest I proceed further?

Regards,
Yash

0 Likes
EvPa_264126
Level 7
500 replies posted 250 replies posted 100 likes received
Level 7

In order for it to work, you need to remove the jumper J43 on the CY8CKIT-050_Kit board.
Or use another contact contact.

0 Likes
Y_r
Level 4
50 sign-ins 25 replies posted 25 sign-ins
Level 4

But, as I mentioned before, I am using CY8CKIT-059 and not 050.
So, there's no jumpers on this.

0 Likes
EvPa_264126
Level 7
500 replies posted 250 replies posted 100 likes received
Level 7

CY8CKIT-059 also has capacitors: P0.2(C12) P0.3(C13) P0.4 (C9) P3.2(C7) P5.4(C4)
You need to select other contacts.

I installed firmware 0020000903 but couldn't revive this project. ESP works differently.
PSoC creates an AP, I can connect to it and after that PSoC hangs.
Before writing a program for PSoC, I debugged the process using ESP8266-Config.
Try working with ESP with this (similar) program.

0 Likes
Y_r
Level 4
50 sign-ins 25 replies posted 25 sign-ins
Level 4

Thanks for your Suggestions Evgeny.

Hi @MotooTanaka and @Len_CONSULTRON ,

I am trying to connect the ESP-01 module with PSOC5 LP.
I am trying, for now, to use the PSOC as a middleman between the ESP module and PC to pass AT commands from the PC and get a response back from the ESP via the PSOC.

I will then later modify that firmware by which the PSOC will send the AT commands coded in the firmware and then based on the response from ESP, send the next commands...

While checking for similar threads, I stumbled on this thread (with PSOC4 and GSM module) but couldn't successfully port it as a working example for the PSOC5 LP like this person.

I would be grateful if you could help me on how to get this PC <-> PSOC <-> ESP setup working.

Thanks and Regards,
Yash

0 Likes
Len_CONSULTRON
Level 9
1000 replies posted 750 replies posted 500 likes received
Level 9

Yash,

Based on your description of what you are trying to do, the thread contributions and reading the ESP-01 datasheet, I have uploaded a very simple project.

Please note the following assumptions:

  • You are using a stock CY8CKIT-059.
  • You are using the USBUART on the KitProg board.
  • You are using the 5V from the USB cable from the host PC.
  • You are adding a 5V to 3.3V LDO voltage regulator to power the ESP-01.

Here is a schematic of the TopDesign.

Len_CONSULTRON_1-1644415923456.png

 

You will see that the PSoC5 is not using any UARTs.  It's a "direct wire" of the host Rx to the RXD of the ESP and the TXD of the ESP to the host Tx.   The PSoC in effect is acting as a HW level-translator from the host 5V to the ESP 3.3V levels.

The UARTs involved is the USB UART on the -059 kit KitPRog board and it connects directly to the ESP-01 UART.

You will notice also two more design criteria.

The ESP-01 supply voltage can be NO higher than 3.6V.  Therefore I show a 5V to 3.3V LDO voltage regulator.  I has no 3.3V bulk bypass cap.  These caps exist on the ESP-01 module.   

Also the VDAC8_3V3 supplies 3.3V to the reference input to the SIO pins.   This 3.3V reference is used to define the input threshold of Tx_ESP and the maximum output high voltage of Rx_ESP and XRES_ESP pins.

The last design criteria is hooking up the PSoC XRES signal to another PSoC pin and pass a 3.3V limited version of that signal to the ESP-01 RST signal.  Therefore a PSoC reset causes a ESP-01.

I could not find the UART baud rate used on the ESP-01.   Determine what baud this is and use this baud rate on the host terminal program.   When you open the port, the AT commands should be accessible to the ESP-01.

You will also notice the simple main.c code.

 

#include "project.h"

int main(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */
	VDAC8_3V3_Start();
    for(;;)
    {
        /* Place your application code here. */
    }
}
/* [] END OF FILE */

 

The only thing done is to start up the 3.3V VDAC.  The for(;;) loop does nothing.

Let me know if this works.

Len
"Engineering is an Art. The Art of Compromise."
Y_r
Level 4
50 sign-ins 25 replies posted 25 sign-ins
Level 4

Also, after making the necessary changes to the two_uarts firmware attached in the above link, the ESP and PSOC are connected on the two mentioned UART's as below:
ESP_TX  <--> P1[6]
ESP_RX  <--> P12[7]
P12[6]  <--> P1[7]

The modified firmware is attached along with the snapshot of the teraterm which shows ERROR from the ESP as below:

Y_r_0-1644411907895.png



Please help and advise on how I can reach the desired application as mentioned above (using PSOC as a middleman and send AT commands from PC and ESP responses back to the PC).


Regards,
Yash

0 Likes
Len_CONSULTRON
Level 9
1000 replies posted 750 replies posted 500 likes received
Level 9

Yash,

I have downloaded your project and have found the following issues:

  • You are using Port 1  pins (P1.7 and P1.6) to communicate to the ESP.   These pins will expect 5V inputs and output 5V.  This could damage the ESP module which can tolerate up to 3.6V.   Use SIO Port12 pins with input and output level-shifting.
  • Are you supplying no more than 3.3V to the VCC pin of the ESP-01?  5V at VCC could damage the ESP-01 module.  The ESP can tolerate up to 3.6V.
  • You are not controlling the following ESP-01 pins from the PSoC: CH_PD or RST.   This might be a problem if the ESP-01 doesn't enter the proper boot mode after reset and doesn't load the AT command set code.
  • I also noticed you have assigned the CY8C5868LTI-LP039 for the project.  This is the IC being used on the KitProg board for the CY8CKIT-059 board.  The Target board uses the CY8C5888LTI-LP097.   Is this intentional?

I have provided uploaded code that uses the Port12 pins in level-shifting mode to interface to the ESP-01.  It also uses NO UARTs on the target PSoC.  It uses the USBUART bridge on the KitProg board directly connected to the ESP-01 using the level-shifting.  The 5V for the PSoC is sourced from the USB cable on the host.

My latest project upload is my best understanding given the sometimes confusing and conflicting info available.

Len
"Engineering is an Art. The Art of Compromise."
Len_CONSULTRON
Level 9
1000 replies posted 750 replies posted 500 likes received
Level 9

Yash,

 

Here's an update to my ESP-01 project.   The changes were made because of the lack of good information about the ESP-01 boot mode after RST.

I've found some other information on other websites.   Hopefully I've better understood the boot mode needs.

Here are my assumptions of the changes:

  • The ESP-01 ALREADY CONTAINS AT command boot code on the modules external FLASH.  There I'm creating a SW RST and BOOT mode timing sequence from the  PSoC with GPIO0 = High;  GPIO2=High; CH_PD = Low

Here's the changes to the TopDesign:

Len_CONSULTRON_0-1644420961316.png

Here's the changes to the code in main.c

#include "project.h"

int main(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */

    /* Place your initialization/startup code here (e.g. MyInst_Start()) */
	VDAC8_3V3_Start();	// Start up the 3.3V vref for the SIO pins.
	XRES_ESP_Write(1);	// Take the ESP-01 out of reset.  The ESP is in reset when the PSoC is reset.
	// Since the ESP-01 GPIO0 and GPIO2 pins have internal pullups to 3.3V (High)  This should be the FLASH boot mode.
	CyDelay(1000);   // Allow 1 sec before enabling ESP-01 module after boot mode.
	ESP_en_Write(1);	// Enable the ESP-01 module
	
	
    for(;;)
    {
        /* Place your application code here. */
    }
}

/* [] END OF FILE */

 

In general the information about interfacing to the ESP-01 is a bit lacking and sometimes apparently conflicting.

Uploaded is the project of my latest understanding.

Len
"Engineering is an Art. The Art of Compromise."
Y_r
Level 4
50 sign-ins 25 replies posted 25 sign-ins
Level 4

Hi @Len_CONSULTRON,

First of all, thanks a lot for reaching out to help me with my application.

I will take a look at the firmware and update the findings tomorrow as soon as I test it.

I was wondering if there was a way to use the UART's (with Interrupts) instead of USBUART, like a two_uart firmware like the one pointed out in the above thread?

I really appreciate your help and will test the firmware and get back to you if I find any issues in the process.

PS: The CH_PD/EN pin of the ESP was connected to GND in my hardware setup.

Thanks and Regards,
Yash

0 Likes
Len_CONSULTRON
Level 9
1000 replies posted 750 replies posted 500 likes received
Level 9

Yash,

I modified your project with 2 UARTs to show how simple it is to pass data unmodified from the PC host and the ESP-01.

In this code, I just take the Host input (Host_Tx) and push it to the ESP Rx pin.   When the ESP Tx has data it is sent to the Host_Rx.  It then shows up as-is at the Host terminal output.

For this project since I don't have an ESP-01 module I left the ESP Rx and Tx pin on P1.7 and P1.6.  This is NOT ADVISABLE since as I indicated earlier that these pins will max out at 5V instead of the max of 3.3V.

Additionally because I don't have an ESP, I short out P1.7 and P1.6 to push the ESP Tx to the ESP Rx.

This shorting of the ESP Tx and Rx allows me to make sure every character I send from the host is echoed back to the host.

Project Description:

For every UART_CMD byte received, I push it to the UART_GSM Tx.

For every UART_GSM byte received, I push it to the UART_CMD Tx.

The UARTs are used but they are just pass-thrus and no data processing of the UART data occurs on the PSoC.   If PSoC processing is needed, the code can be modified.  In this project, you issue the AT commands at the host and receive the results from the ESP-01 on the Host terminal output.  This is a good starting point to prove that the host to ESP interface is working.

You mentioned:


PS: The CH_PD/EN pin of the ESP was connected to GND in my hardware setup.

 

 If CH_PD is tied to GND, the ESP-01 module is powered down and not enabled.   CH_PD = 3.3V causes the program in the ESP-01 to recognise commands through the UART interface.   This could be the cause of why the ESP is not responding at a minimum.

My warning about the ESP-01 VCC power input and other inputs exceeding 3.3V should not be ignored.  It is HIGHLY possible to permanently damage the module above 3.6V.

 

Len
"Engineering is an Art. The Art of Compromise."
Y_r
Level 4
50 sign-ins 25 replies posted 25 sign-ins
Level 4

Hi Len,

I have tested the attached project and can confirm that the ESP now responds as expected to the AT commands on the terminal.

" If CH_PD is tied to GND, the ESP-01 module is powered down and not enabled.   CH_PD = 3.3V causes the program in the ESP-01 to recognise commands through the UART interface.   This could be the cause of why the ESP is not responding at a minimum."
>> The CH_PD when connected to the 3.3V or left floating, the ESP responds properly ( as you pointed out).

"My warning about the ESP-01 VCC power input and other inputs exceeding 3.3V should not be ignored.  It is HIGHLY possible to permanently damage the module above 3.6V."
>> I have used a 5-3.3V LDO to power the ESP as well as a 5-3.3V logic level shifter for the TX and RX pins.

Since I now know that the ESP and PSOC respond to each other and that the AT commands sent to the ESP can also connect the ESP to the network and get an IP address using the above firmware.

Also, I couldn't test the USBUART based example that you provided above since the USB port on my PSOC is damaged 😥.
Thanks for sharing the project, being the awesome person you are, will surely help someone in the future 🙂.

PS: I will accept the above firmware as a solution and create a new thread for the next part which is for the PSOC to configure the ESP on its own without user intervention and only print out the IP address to the user.

Thanks and Regards,
Yash

0 Likes
Len_CONSULTRON
Level 9
1000 replies posted 750 replies posted 500 likes received
Level 9

Yash,

I'm glad to hear you have gotten your project working.   It's always a good feeling to see the project moving forward to the next step in the design.

I'm also glad to hear you have the ESP-01 powered at 3.3V and have level-shifters to protect the module.

For future reference, the PSoC being  powered by 5V can still provide 3.3V logic level shifting using the SIO pins on Port 12.   This eliminates the need to purchase level-shifting ICs.

You mentioned:


...The CH_PD when connected to the 3.3V or left floating, ...

The info I saw on the CH_PD signal did not indicate that the input was biased high.  This info also included a schematic.  No bias resistor.   Therefore, if the pin is left floating there is no guarantee that it will enable the module.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes