rallyman Newbie
Joined: 15/02/2017 Location: HungaryPosts: 9 |
Posted: 07:25am 11 Mar 2017 |
Copy link to clipboard |
Print this post |
|
Hello Guys,
First of all, thanks your help with my pir sensors last time. Now I go further with my project and try to settle up an ESP8266 wifi connection, but I have some issues...
Let's see the topology: - PIC32MX170256D - ESP8266-01
I have also gone throuhg the panel draws, I have found TX/RX pins on my PIC. I use UART2 to connect the ESP through serial to the PIC. ON my PIC32 PIN6-7 is for TX/RX, it is connected fine, I can communicate with the ESP through the PIC. I use 3.3V for the ESP getting out it from the PIC. I have also get out the GND from the PIC.
my idea is: - power on the pic - burn the MMBASIC code via usb (uart1) /the code will do/ - use some AT commands to attach the ESP to my wifi-router (SSID, psw) (linksys wrt) (IP gets via DHCP, but I also set up a static arp in the router to get always the same IP address about some debug purposes) - with AT commands, open a tcp session to my home-server (apache port 8080) - send some charachter (in my example HTTP GET, in the fure I will call a php url)
my expereinces: Webserver is running fine (apache, mysql also), I can reach it via other pc-s in web and cli(ssh). When I start my MMBASIC program with my PIC+ESP setup, it can connect the wifi LAN, it gets the IP address via DHCP. I run a continious ping to that IP, and it starts reply when the ESP connects to the wifi-rtr. IP connection works perfect. After that I try to open the TCP session to my server and there comes the issue... I also run a whireshark on my server and there is no incoming packets ever. In the debug of MMBASIC, I can see there is a "busy" message after the AT+CIPSTART line...
I tried to figure out it is an ESP or PIC issue. If I connect the ESP directly to my pc via serial usb uart converter modul, I can use 'putty' or 'termite' program and I can communicate with AT commands perfetly and I also see the incoming session in my whireshark log.
But, unf. when I connect the ESP back to the PIC, it start, can connect to wifi, it is pingable, but cannot open the TCP session, because of "busy"...
1. pict: direct connection ESP_to_PC, manual send AT commands via termite 2. pict: ESP is connected via the PIC32, commands send by MMBASIC code, no any incoming tcp session from the ESP to the server.
Here is my SUB for the connection. Please be aware that I have to use CHR(34) instead of the charachter (") and I also have to take care of \r\n (CR,LF) charachters.
dim string CRLF=chr$(13)+chr$(10) length 2
SUB open_tcp
'local strings LOCAL dat AS STRING LOCAL ssid AS string LOCAL pass AS STRING LOCAL connstr AS STRING 'strings because of CHAR"" ssid$ = chr$(34) + "SURVIVOR_V3" + CHR$(34) pass$ = CHR$(34) + "surV1V0R" + CHR$(34) connstr$ = CHR$(34) + "TCP" + CHR$(34)+ ","+ CHR$(34) + "192.168.222.101" + CHR$(34) + ",8080"
'open com1 OPEN "COM1:115200,4096" AS #5 pause 300 PRINT #5, CRLF PRINT #5, CRLF PAUSE 300
PRINT #5, "AT+RST" PRINT #5, CRLF PRINT ">>>>>>>> ESP reset OK" 'STA mode 1 PAUSE 300 PRINT #5, "AT+CWMODE=1" PAUSE 300
'Connect to SSID using strings decl. above PAUSE 300 PRINT #5, "AT+CWJAP="+ssid+","+pass PAUSE 300 PRINT ">>>>>>>> ESP Connect OK to "+ssid+" with "+pass PAUSE 300
'single TCP/UDP session PRINT #5, "AT+CIPMUX=0" PAUSE 300 'open TCP session to 10.10.10.101:8080 PAUSE 300 PRINT #5, "AT+CIPSTART="+connstr PRINT #5, chr$(13)+chr$(10) PAUSE 500
'DAT 7. debug dat$ = INPUT$(250, #5) PRINT "/// DAT7 "+dat PAUSE 200 PRINT #5, "AT+CIPCLOSE"+CRLF PRINT ">>>>>>>> Send OK" CLOSE #5 RETURN END SUB
So, could someone has any idea, why I cannot connect open the TCP session with my ESP when it is connected to the PIC?
Much appreciate! R. |