25 Ağustos 2019, 08:55:20

Haberler:

Eposta uyarılarını yanıtlamayınız ( ! ) https://bit.ly/2J7yi0d


ESP8266 Wifi Module Örnek Uygulama

Başlatan MrDarK, 01 Kasım 2014, 14:47:01

MrDarK

20 Aralık 2016, 13:32:58 #45 Son düzenlenme: 22 Aralık 2016, 20:10:46 MrDarK
Alıntı yapılan: seyityildirim - 19 Aralık 2016, 21:53:11
Merhaba arkadaşlar,

Öncelikle çok faydalı bir konu olmuş. Emeği geçenlere teşekkürler... Benim sorum şu;

Örnek olması açısından https://learn.adafruit.com/diy-boost-calc/the-calculator bu sitedeki gibi kullanıcıdan değer bekleniyor.

Esp8266 kullanarak bu sitede bulunan kutucuklara değer girebilir miyim ? Konudaki ilk örnekte picproje sitesine bağlanılıyor. Ama daha sonra nasıl hareket ediliyor bir bilgim yok. Mesela bu modül ile picproje de konu açıp bu soruyu sorabilir miyim?



Selamlar;

Örnekte dediğin gibi picproje sitesine bağlantı kurup sizi orada bıraktım. Çünkü o noktadan sonra HTTP Request, PHP programlama, HTML işlemler gibi parametreler devreye giriyor. Web tarayıcılarının hangi işlemlere hangi komutları gönderdiğini tespit edersen yapabilirsin. Lakin çok zorlar seni, o yüzden hedefine yönelik bir çalışma yapmanı tavsiye ederim. Hatta yeni bir konu açıp hedefin ile ilgili tavsiye alman yararına olacaktır.
Picproje Eğitim Gönüllüleri ~ MrDarK

hasanmert

mrb arkadaşlar,
ESP8266 uygulaması ile uğraşıyorum
sonbui/mystr.c dosyasını bulamadım. Bu dosyayı nereden bulurum?


ufukv

@MrDarK 
Merhaba, Haberleşmede neden full-duplex kullandın ? Genelde wifi protocolü için half-duplex tavsiye ediliyor. Özel bir sebebi var mı ? Bende STM32L011D3'ü LPUART ile ESP-WROOM-02 yi haberleştireceğim. Yardımın için şimdiden teşekkürler.

MrDarK

Özel bir sebebi yok. Istediğiniz gibi kullanabilirsiniz.
Picproje Eğitim Gönüllüleri ~ MrDarK

ufukv

@MrDarK Hocam,
STM32F0 Discovery DK ile(STM32F051R8 mikrodenetleci) ESP WROOM-02 modülünü uart üzerinden haberleştirdim ve KEIL IDE üzerinde küçük bir buton led uygulaması yaptım. Modül çalışırken 116 mA akım çekiyor. Modülü veri alışverişi dışında belirli bir süre deep sleep modunda ve geri kalan zamanlarda power off olacak. Deep sleep modu için yazılımsal ve donanımsal müdahaleyi nasıl yapabiliriz?

https://hizliresim.com/p/yukle

MrDarK

Picproje Eğitim Gönüllüleri ~ MrDarK

BLACK_G

Alıntı yapılan: Recep METE - 30 Ocak 2015, 02:18:27yukarıdaki kodlarda hata var yeniden yayınlamak ihtiyacı doğdu

Code  Pic18f4550:

#include <18F4550.h>
#DEVICE ADC=8                 
#fuses HSPLL,MCLR,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN
#use delay(clock=48000000)  
#use rs232(UART1,baud=115200,parity=N,bits=8,stream=WIFI_ESP,errors)//Khai bao su dung uart cung  
#include <usb_cdc.h>                                 
#include <usb_desc_cdc.h> 
#define ledv  PIN_C2                                 
#define ledr  PIN_C1
#define ledon output_low                                      
#define ledoff output_high                     
#define led_on output_low                                                      
#define led_off output_high                                                       
#define LCD_ENABLE_PIN PIN_D2                   
#define LCD_RS_PIN PIN_D0               
#define LCD_RW_PIN PIN_D1               
#define LCD_DATA4 PIN_D4                                           
#define LCD_DATA5 PIN_D5
#define LCD_DATA6 PIN_D6
#define LCD_DATA7 PIN_D7
#include <lcd.c>                                      
#include"esp/wifi.c"   
#include"sonbui/mystr.c" 

char *SSID_JOIN="TU HU";//"SonBui-AP";
char *PASS_JOIN="12345679";//"a12344321";   
char *DATA_SEND="GET /data/2.5/weather?id=1581130 HTTP/1.0\r\nHost: api.openweathermap.org\r\n\r\n" ;     //1581130: Hanoi-Viet nam
char *WEATHER_IP"188.226.224.148"//api.openweathermap.org    
void get_internet()
{    
	
char *write ">";  
	
int1 OK False;
	
printf(LCD_PUTC"\fGData Hanoi,VN\nopenweathermap.org");  
	
delay_ms(1000);
	
if( 
client_Start(0,TYPE_TCP,WEATHER_IP,80))   //kET NOI TOI SERVER DE LAY DU LIEU  
	
{  
	
	
printf(LCD_PUTC"\fGet data"); 
	
	
int16 length=strlen(DATA_SEND);                                                           
	
	
DO
	
	
{
	
	
	
clear_mem();
	
	
	
fprintf(WIFI_ESPAT_SEND);                     
	
	
	
fprintf(WIFI_ESP"=%u"0);       
	
	
	
fprintf(WIFI_ESP",%lu",length);  
	
	
	
fprintf(WIFI_ESPCRLF); 
	
	
	
for (
int mem_loop 0mem_loop 150mem_loop++) { 

	
	
	
	
wifi_buff[n] = timed_getc();
	
	
	
	
n++;
	
	
	
	
if (
1500;
	
	
	
	
if (
timeout_error) break;
	
	
	
}

	
	
	
char *pch strstr(wifi_buffwrite);

	
	
	
IF(
pch) {
	
	
	
	
OK TRUE;
	
	
	
	
break;                                
	
	
	
}
	
	
	
delay_ms(100);
	
	
}
	
	
WHILE(!
OK);  
	
	
//Send http get
	
	
clear_mem();       
	
	
printf(LCD_PUTC"\fSend Get"); 
	
	
fprintf(WIFI_ESP"%s",DATA_SEND);
	
	
Long LONG timeout;   
	
	
timeout 0
	
	
WHILE(!
kbhit(WIFI_ESP) && (++timeout 2000000))  //20 second 
	
	
{
	
	
	
delay_us(10); 
	
	
	

	
	
}                                                         
	
	
WHILE(!(
fgetc(WIFI_ESP)=='{')) ;        
	
	
printf(LCD_PUTC"\f{"); 
	
	

	
	
wifi_buff[0]='{';n=1;                               
	
	
do {         
	
	
	
wifi_buff[n] = mili_getc();           
	
	
	
n++;                                           
	
	
	
if (
5120;   
	
	
	

	
	
}while(!
timeout_error) ;
	
	
printf(LCD_PUTC"\fPrint Data");
	
	
//printf(usb_cdc_putc, "\r\nWF:%s"wifi_buff);   
	
	
char *jstart="\"main\":{";
	
	
char *jstop=",\"wind\"";
	
	
char *p1 strstr(wifi_buff,jstart);
	
	

	
	
if(
p1)                              
	
	
{    
	
	
	
// printf(usb_cdc_putc, "\r\n\fp1:%s"p1);  
	
	
	
char *p2 strstr(p1,jstop); 
	
	
	
if(
p2)  
	
	
	
{  
	
	
	
	
// printf(usb_cdc_putc, "\r\n\fp2:%s"p2);
	
	
	
	
size_t len p2-p1;   
	
	
	
	
char *jmain = (char*)malloc(sizeof(char)*(len+1));  
	
	
	
	
strncpy(jmainp1len);                                  
	
	
	
	
jmain[len] = '\0';  
	
	
	
	
// printf(usb_cdc_putc, "\r\nRes:%s"jmain); 
	
	
	
	
char *temp="\"temp\":";
	
	
	
	
char *temp_min=",\"temp_min\":";    
	
	
	
	
char *ap_suat=",\"pressure\":";
	
	
	
	
char *ap_suat_end=",\"sea_level"
	
	
	
	
char *do_am="\"humidity\":";    
	
	
	
	
char *do_am_end="}";                               
	
	
	
	
double d_nhiet_do
	
	
	
	
free(res) ; 
	
	
	
	
char *nhiet_do=extract_string(temp,temp_min,jmain);
	
	
	
	
if(
nhiet_do)                                                  
	
	
	
	
{
	
	
	
	
	
// printf(usb_cdc_putc, "\r\nNhiet do:%s"nhiet_do); 
	
	
	
	
	
d_nhiet_do atof (nhiet_do);//treo neu gia tri nhiet do sai dinh dang 
	
	
	
	
	
d_nhiet_do -= 273.15//kelvin-celsius 
	
	
	
	
	
printf (LCD_PUTC"\fT=%f"d_nhiet_do); 
	
	
	
	
}
	
	
	
	
free(res) ; 
	
	
	
	
char *ap_suat_khi=extract_string(ap_suat,ap_suat_end,jmain); 
	
	
	
	
if(
ap_suat)
	
	
	
	

	
	
	
	
	
//  printf(usb_cdc_putc, "\r\nAp suat:%s"ap_suat_khi); 
	
	
	
	
	
printf (LCD_PUTC"\nP=%s hpa"ap_suat_khi);   
	
	
	
	
}                                                          
	
	
	
	
free(res) ;                                                              
	
	
	
	
char *do_am_khi=extract_string(do_am,do_am_end,jmain);
	
	
	
	
if(
do_am_khi)
	
	
	
	
{
	
	
	
	
	
// printf(usb_cdc_putc, "\r\nDo am khi:%s"do_am_khi);
	
	
	
	
	

	
	
	
	
	
lcd_gotoxy(10,1) ;                                     
	
	
	
	
	
printf (LCD_PUTC"H=%s %%"do_am_khi);                  
	
	
	
	
}
	
	
	
	
free(jmain) ;
	
	
	
}
	
	
}
	
}
	
else
	
{                                      
	
	
printf (LCD_PUTC"\f Can't connect to\nopenweathermap.org"); 
	
	
delay_ms(1000);
	
}                          
}
void main()                             
{  
	
lcd_init ();                                                                     
	
printf (LCD_PUTC"\f MuaLinhKien.Vn\nPIC 16/18 Basic Kit"); 
	
delay_ms(1000);
	
printf (LCD_PUTC"\fESP8266 Test\nmualinhkien.vn");   
	
esp_init();
	
setup_AP(SSID_SET,PASS_SET,5,ECN_WAP2_PSK);                                                                                               
	
delay_ms(1000);  
	
join_AP(SSID_JOIN,PASS_JOIN);             
	
delay_ms(1000);
	
client_Start(0,TYPE_TCP,WEATHER_IP,80);   //kET NOI TOI SERVER DE LAY DU LIEU   
	
delay_ms(1000);
	
get_ip();
	
clear_mem(); 
	
//!   usb_cdc_init();
	
//!   usb_init();                                       
	
//!   usb_task();                                       
	
//!   usb_wait_for_enumeration();
	
//!     while(!usb_cdc_connected());                              
	
while (
TRUE)                                                       
	
{                                                         
	
	
get_internet();
	
	
for(
int loop=0;loop<120;loop++)      
	
	
{
	
	
	
output_toggle(ledr);
	
	
	
delay_ms(500);       
	
	
}
	
	

	
}


Wifi.c:

/*
Dung while de doc du lieu tra ve
Dung ngat de lay du lieu bat ki
*/
#INCLUDE <stdlibm.h> 
#include <stdio.h>
#include <stdlib.h>
#include <string.h> 
#include <wifi.h>  
char wifi_buff[512];            

int16 n 0;
INT1 timeout_error;
INT8 timeout_error_count 0;                          
char CRLF[] = "\r\n";                                                                                                            
char *SSID_SET "VISMART.CO";
char *PASS_SET "12345678";                                        
char *STR_OK="\r\nOK\r\n" ;                                           
char *STR_START=":" ;                                      
char data_out[50];      
                                                  
void clear_mem(void) {                                             
   for (
int16 mem_loop 0mem_loop 512mem_loop++) {
      if (
wifi_buff[mem_loop] == '\0')
      break;           
      else
      
wifi_buff[mem_loop] = '\0';
   }
   
0;             
}  
void clear_data(void) {                                             
   for (
int16 mem_loop 0mem_loop 50mem_loop++) {
      if (
data_out[mem_loop] == '\0')
      break;           
      else
      
data_out[mem_loop] = '\0';
   }
   
0;             
}

char timed_getc() {

   WHILE(!
kbhit(WIFI_ESP));
   IF(
kbhit(WIFI_ESP))    
   RETURN(
fgetc(WIFI_ESP));                     
   ELSE
   {
     
      RETURN(
0);
   }
}

char *send_AT_result(char *command) {

   
clear_mem();
   
fprintf(WIFI_ESP"%s"command);
   
fprintf(WIFI_ESPCRLF);   
   for (
int mem_loop 0mem_loop 150mem_loop++) {

      
wifi_buff[n] = timed_getc();
      
n++;
      if (
1500;
      if (
timeout_error) break;
   }
   return 
wifi_buff;
}                                                

void send_AT_OK(char *command) {
   
int1 OK False;
   
char *oks "OK";
   DO
   {
      
clear_mem();
      
fprintf(WIFI_ESP"%s"command);
      
fprintf(WIFI_ESPCRLF);
      for (
int mem_loop 0mem_loop 150mem_loop++) {

         
wifi_buff[n] = timed_getc();
         
n++;
         if (
1500;
         if (
timeout_error) break;
      }

      
char *pch strstr(wifi_buffoks);

      IF(
pch) {
         
OK TRUE;
         break;
      }
      
delay_ms(100);
   }
   WHILE(!
OK);

                                                       
}

void esp_init() {
   
int1 OK False;
   
char *oks "OK";
   
char *nc "no change";         
do { 
//ATE0   
      
clear_mem(); 
     
fprintf(WIFI_ESPAT_RESET);
      
fprintf(WIFI_ESPCRLF); 
   
delay_ms(2000); 
      
fprintf(WIFI_ESPAT_ECHO_OFF);
      
fprintf(WIFI_ESPCRLF);
      for (
int mem_loop 0mem_loop 150mem_loop++) {

         
wifi_buff[n] = timed_getc();
         
n++;
         if (
1500;
         if (
timeout_error) break;
      }
      
char *pch strstr(wifi_buffoks);

      IF(
pch) {
         
OK TRUE;
         
printf(LCD_PUTC"\fATE0");
      }
      
delay_ms(100);
   }
   WHILE(!
OK);

   
//
   
do { //AT+CWMODE=3
      
clear_mem();                               
      
fprintf(WIFI_ESPMODE_AT_STA);
      
fprintf(WIFI_ESPCRLF);
      for (
int mem_loop 0mem_loop 150mem_loop++) {

         
wifi_buff[n] = timed_getc();
         
n++;
         if (
1500;
         if (
timeout_error) break;
      }

      
char *pch strstr(wifi_buffoks);

      IF(
pch) {
         
OK TRUE;
         
printf(LCD_PUTC"\fAT+CWMODE=3");
      } else {
         
char *no_change strstr(wifi_buffnc);

         IF(
no_change) {
            
OK TRUE;
            
printf(LCD_PUTC"\fAT+CWMODE=3\nNo change");
         }

      }
      
delay_ms(100);
   }
   WHILE(!
OK);

}

void setup_AP(unsigned char *ssidunsigned char *passwordint chlint enc) {
   
//AT+CWSAP="ssid","password",chl,enc
   
int1 OK False;
   
char *oks "OK";
   for (
int loop 0loop 5loop++) {
      
clear_mem();
      
fprintf(WIFI_ESPAT_SET_AP_PARAMS);
      
fprintf(WIFI_ESP"=\"%s\""ssid);
      
fprintf(WIFI_ESP",\"%s\""password);
      
fprintf(WIFI_ESP",%u"chl);
      
fprintf(WIFI_ESP",%u"enc);
      
fprintf(WIFI_ESPCRLF);

      for (
int mem_loop 0mem_loop 150mem_loop++) {

         
wifi_buff[n] = timed_getc();
         
n++;
         if (
1500;
         if (
timeout_error) break;
      }

      
char *pch strstr(wifi_buffoks);

      IF(
pch) {
         
OK TRUE;
         
printf(LCD_PUTC"\fAT+CWSAP\nloop=%u"loop);
         break;
      }
      
delay_ms(100);
   }
}

void join_AP(unsigned char *ssidunsigned char *password//Thuc hien mot lan vi khoi dong lai se tu ket noi
{
   
//AT+CWJAP="ssid","password"
   
int1 OK False;
   
char *oks "OK";
   for (
int loop 0loop 3loop++) {
      
timeout_error_count 0;
      
printf(LCD_PUTC"\fCn to:%s\nLan %u"ssidloop);
      
clear_mem();
      
fprintf(WIFI_ESPAT_JOIN_AP);
      
fprintf(WIFI_ESP"=\"%s\""ssid);
      
fprintf(WIFI_ESP",\"%s\""password);
      
fprintf(WIFI_ESPCRLF);
      
Long LONG timeout;
      
timeout 0

      WHILE(!
kbhit(WIFI_ESP) && (++timeout 3000000)) //30 second         
      
{       
         
delay_us(10);   
         if (
timeout 3000 == 0) {
            
timeout_error_count++;
            
lcd_gotoxy(102);
            
int pos timeout_error_count 4;
            if (
pos == 0)
            
printf(LCD_PUTC"    ");
            if (
pos == 1)                 
            
printf(LCD_PUTC" .  ");
            if (
pos == 2)
            
printf(LCD_PUTC"  . ");
            if (
pos == 3)
            
printf(LCD_PUTC"   .");
         }               
      }
      for (
int mem_loop 0mem_loop 150mem_loop++) {
         
wifi_buff[n] = timed_getc();
         
n++;
         if (
1500;
         if (
timeout_error)
         break;
      }
      
char *pch strstr(wifi_buffoks);

      IF(
pch) {
         
OK TRUE;
         
printf(LCD_PUTC"\fCnt To:%s\nLoop=%u"ssidloop);
         break;
      }
      ELSE
      {
         
printf(LCD_PUTC"\fCn To:%s\nError!"ssid);

      }
      
delay_ms(100);
   }
}

void quit_AP() {
   
//AT+CWQAP
   
int1 OK False;
   
char *oks "OK";
   DO
   {
      
clear_mem();
      
fprintf(WIFI_ESPAT_QUIT_AP);
      
fprintf(WIFI_ESPCRLF);

      for (
int mem_loop 0mem_loop 150mem_loop++) {

         
wifi_buff[n] = timed_getc();
         
n++;
         if (
1500;                      
         if (
timeout_error) break;
      }

      
char *pch strstr(wifi_buffoks);

      IF(
pch) {
         
OK TRUE;
         
printf(LCD_PUTC"\fAT+CWQAP");
         break;
      }
      
delay_ms(100);
   }                                 
   WHILE(!
OK);
}


void get_ip()
{
   
//AT+CIFSR
   
int1 OK False;
   
char *oks "OK";
   DO
   {
      
clear_mem();
      
fprintf(WIFI_ESPAT_GET_IP);
      
fprintf(WIFI_ESPCRLF);

      for (
int mem_loop 0mem_loop 150mem_loop++) {

         
wifi_buff[n] = timed_getc();
         
n++;      
         if (
1500;                      
         if (
timeout_error) break;
      }

      
char *pch strstr(wifi_buffoks);

      IF(
pch) {
         
OK TRUE;
         
printf(LCD_PUTC"\fIP:%s",wifi_buff);
         break;
      }
      
delay_ms(100);
   }                                 
   WHILE(!
OK);

}
int1 client_Start(int idint typechar *ipunsigned int16 port)
{

   
char *cmd AT_SET_MUL_CON;
   
int1 OK False;
   
char *oks "OK";
   
char *connected="ALREAY CONNECT"//Ket noi da duoc ket noi tu truoc toi ip nay hoac ip khac voi id nay

   
   
   
DO                     
   {
      
char *pch strstr(send_AT_result(cmd), oks);

      IF(
pch) {
         
OK TRUE;
         
printf(LCD_PUTC"\f%s"AT_SET_MUL_CON);
         break;
      }
      
delay_ms(100);
   }
   WHILE(!
OK);
   
//
   
for (int loop 0loop 5loop++) {
      
timeout_error_count 0;
      
printf(LCD_PUTC"\f%s\nPort:%5lu    %u"ipportloop);
      
clear_mem();                                                 
      
fprintf(WIFI_ESPAT_START_CON);
      
fprintf(WIFI_ESP"=%u"id); 
      if (
type == TYPE_TCP)  
      
fprintf(WIFI_ESP",\"TCP\"");                                     
      else                                  
      
fprintf(WIFI_ESP",\"UDP\"");  
      
fprintf(WIFI_ESP",\"%s\""ip);
      
fprintf(WIFI_ESP",%lu"port);
      
fprintf(WIFI_ESPCRLF);
      
Long LONG timeout;
      
timeout 0;
      
      WHILE(!
kbhit(WIFI_ESP) && (++timeout 3000000)) //30 second         
      

         
delay_us(10); 
         if (
timeout 3000 == 0) {
            
timeout_error_count++;
            
lcd_gotoxy(112);                         
            
int pos timeout_error_count 4;            
            if (
pos == 0)
            
printf(LCD_PUTC"    ");
            if (
pos == 1
            
printf(LCD_PUTC" .  ");
            if (
pos == 2)                                  
            
printf(LCD_PUTC"  . ");
            if (
pos == 3)
            
printf(LCD_PUTC"   .");
         }
      }
      for (
int mem_loop 0mem_loop 150mem_loop++) {
         
wifi_buff[n] = timed_getc();
         
n++;                           
         if (
1500;
         if (
timeout_error)
         break;
      }
      
char *pch strstr(wifi_buffoks); //chu y con "ALREAY CONNECT"

      
IF(pch) {
         
OK TRUE;  
         
printf(LCD_PUTC"\fIP:%s\nP:%5lu lan %u OK    "ipportloop);
         break;                                  
      }
      ELSE
      {  
         
char *link strstr(wifi_buffconnected);    

         IF(
link) {
            
OK TRUE;                                             
            
printf(LCD_PUTC"\fID CONNECTED!\nloop=%u"loop); 
            break;       
         }        
         else                       
         {
         
OK FALSE;   
         
printf(LCD_PUTC"\fIP:%s\nP:%5lu Error"ipport);     
         }                                             

      }
      
delay_ms(100); 
    
   }
     return 
OK;
   
}
void server_Start(unsigned int16 port)   // Truoc khi chay phai restart                                     
{

   
char *cmd AT_SET_MUL_CON;
   
int1 OK False;
   
char *oks "OK";
   
char *link_builded "link is builded";

   
   
   DO
   {
      
char *pch strstr(send_AT_result(cmd), oks); //chu y:link is builded

      
IF(pch) {
         
OK TRUE;
         
printf(LCD_PUTC"\f%s"AT_SET_MUL_CON);
         break;
      }
      else
      {   
         
char *pch strstr(send_AT_result(cmd), link_builded); //chu y:link is builded

         
IF(pch) {
            
OK TRUE;
            
printf(LCD_PUTC"\fLink is Builded");
            break;
         }
         
      }
      
delay_ms(100);                                        
   }
   WHILE(!
OK);
   
//
   
for (int loop 0loop 5loop++) {
      
timeout_error_count 0;
      
printf(LCD_PUTC"\fServ Port:%5lu\nLan %u"portloop);
      
clear_mem();                                                 
      
//AT+CIPSERVER=1,9999      

      
fprintf(WIFI_ESPAT_SET_SERVER);
      
fprintf(WIFI_ESP"=1"); 
      
fprintf(WIFI_ESP",%lu"port);
      
fprintf(WIFI_ESPCRLF);
      
Long LONG timeout;
      
timeout 0;
      
      WHILE(!
kbhit(WIFI_ESP) && (++timeout 3000000)) //30 second         
      
{
         
delay_us(10);         
         if (
timeout 3000 == 0) {
            
timeout_error_count++;
            
lcd_gotoxy(112);                         
            
int pos timeout_error_count 4;            
            if (
pos == 0)
            
printf(LCD_PUTC"    ");
            if (
pos == 1
            
printf(LCD_PUTC" .  ");
            if (
pos == 2)
            
printf(LCD_PUTC"  . ");
            if (
pos == 3)
            
printf(LCD_PUTC"   .");
         }
      }
      for (
int mem_loop 0mem_loop 150mem_loop++) {
         
wifi_buff[n] = timed_getc();
         
n++;
         if (
1500;        
         if (
timeout_error)
         break;
      }
      
char *pch strstr(wifi_buffoks);

      IF(
pch) {
         
OK TRUE;                                                        
         
printf(LCD_PUTC"\fServ Port:%5lu\nLan %u OK"portloop);   
         break;
      }
      ELSE
      {
         
printf(LCD_PUTC"\fServ Port:%5lu\nLan %u Error!"portloop);   

      }
      
delay_ms(100);              
   }


//Cip close khi ket noi toi server phai co id
//close ket noi toi clinet(modlue khac hoac may tinh) thi ko can

void  close_connect(int id//Tra ve ok hoac "link is not"
{                                                                                         
   
// AT+CIPCLOSE=<id> 
   
int1 OK False;
   
char *not_link="link is not";   //chua ket noi  
   
char *oks="OK";
   for (
int loop 0loop 5loop++) {                                                             
      
clear_mem();
      
fprintf(WIFI_ESPAT_CLOSE_CON);
      
fprintf(WIFI_ESP"=%u"id);    
      
fprintf(WIFI_ESPCRLF);                           

      for (
int mem_loop 0mem_loop 150mem_loop++) {

         
wifi_buff[n] = timed_getc();
         
n++;
         if (
1500;
         if (
timeout_error) break;                          
      }                                      

      
char *pch strstr(wifi_buffoks);    

      IF(
pch) {
         
OK TRUE;                                             
         
printf(LCD_PUTC"\fCLOSE CONNECT\nloop=%u"loop);  
         break;
      }
      ELSE
      {
         
char *link strstr(wifi_buffnot_link);    

         IF(
link) {
            
OK TRUE;                                             
            
printf(LCD_PUTC"\fNOT CONNECT\nloop=%u"loop); 
            break;
         }
      }                                               
   }
}
void send_data(int idchar  *data
{                                          
   
// AT+CIPSEND= <id>,<length>
   
int1 OK False;                
   
char *write ">";
   
char *send_ok="SEND OK";
   
int16 length=strlen(data);
   for (
int loop 0loop 5loop++) {                                                             
      
clear_mem();                      
      
fprintf(WIFI_ESPAT_SEND);
      
fprintf(WIFI_ESP"=%u"id);    
      
fprintf(WIFI_ESP",%lu",length);  
      
fprintf(WIFI_ESPCRLF);                           

      for (
int mem_loop 0mem_loop 150mem_loop++) {

         
wifi_buff[n] = timed_getc();
         
n++;
         if (
1500;
         if (
timeout_error) break;
      }                                      

      
char *pch strstr(wifi_buffwrite);

      IF(
pch) {
         
OK TRUE;                                             
         
printf(LCD_PUTC"\fSEND >\nlenght=%lu"length);
         
         
         
//Gui noi dung                
         
char *sent strstr(send_AT_result(data), send_ok);

         IF(
sent) {              
            
OK TRUE;
            
printf(LCD_PUTC"\fSEND OK\nlenght=%lu"length);
            break;                     
         }        
      }                                   
      else
      {
         
OK FALSE;                                             
         
printf(LCD_PUTC"\fSEND FAIL!\nloop=%u"loop);  
      }
      
delay_ms(100);                                                 
   }                            
   
}


                   


//Loi khi module reset ma client ko biet no dong      




Wifi.h:

#define    ECN_OPEN          0      //Che do bao mat
#define    ECN_WEP           1
#define    ECN_WAP_PSK       2
#define    ECN_WAP2_PSK      3
#define    ECN_WAP_WAP2_PSK  4

#define    TYPE_TCP     1            //Che do ket noi
#define    TYPE_UDP     0                                 

#define    TRAN_OPEN    1         //Che do truyen nhan           
#define    TRAN_CLOSE   0

#define    MODE_STA     "AT+CWMODE=1"         //Che do wifi
#define    MODE_AP      "AT+CWMODE=2"                                          
#define    MODE_AT_STA  "AT+CWMODE=3"

#define WIFI_TX_BUFFER_SIZE 128      //Bo dem
#define WIFI_RX_BUFFER_SIZE 128   

//COMMAND 
#define AT_ECHO_ON                  "ATE1"  
#define AT_ECHO_OFF                 "ATE0"  
#define AT_RESET                    "AT+RST"  
#define AT_CFW                      "AT+GMR"  
#define AT_WIFI_MODE                "AT+CWMODE"
#define AT_JOIN_AP                  "AT+CWJAP" 
#define AT_GET_IP                   "AT+CIFSR" 
#define AT_LIST_AP                  "AT+CWLAP"
#define AT_QUIT_AP                  "AT+CWQAP"  
#define AT_SET_AP_PARAMS            "AT+CWSAP" 
#define AT_CHECK_JOIN_AP            "AT+CWQAP" 
#define AT_GET_CON_STATUS           "AT+CIPSTATUS"
#define AT_START_CON                "AT+CIPSTART" 
#define AT_CIP_MODE                 "AT+CIPMODE"  
#define AT_SEND                     "AT+CIPSEND"  
#define AT_CLOSE_CON                "AT+CIPCLOSE"           
#define AT_SET_MUL_CON              "AT+CIPMUX=1"
#define AT_SET_SERVER               "AT+CIPSERVER"  
#define AT_SET_SERVER_TIMEOUT       "AT+CIPSTO"  
#define AT_RECEIVED_DATA            "+IPD" 




115200 baud hızında RS232 haberleşme yoluyla AT komutları kullanarak modülle iletişim kurmak için:

//COMMAND 
#define AT_ECHO_ON                  "ATE1"  
#define AT_ECHO_OFF                 "ATE0"  
#define AT_RESET                    "AT+RST"  
#define AT_CFW                      "AT+GMR"  
#define AT_WIFI_MODE                "AT+CWMODE"
#define AT_JOIN_AP                  "AT+CWJAP" 
#define AT_GET_IP                   "AT+CIFSR" 
#define AT_LIST_AP                  "AT+CWLAP"
#define AT_QUIT_AP                  "AT+CWQAP"  
#define AT_SET_AP_PARAMS            "AT+CWSAP" 
#define AT_CHECK_JOIN_AP            "AT+CWQAP" 
#define AT_GET_CON_STATUS           "AT+CIPSTATUS"
#define AT_START_CON                "AT+CIPSTART" 
#define AT_CIP_MODE                 "AT+CIPMODE"  
#define AT_SEND                     "AT+CIPSEND"  
#define AT_CLOSE_CON                "AT+CIPCLOSE"           
#define AT_SET_MUL_CON              "AT+CIPMUX=1"
#define AT_SET_SERVER               "AT+CIPSERVER"  
#define AT_SET_SERVER_TIMEOUT       "AT+CIPSTO"  
#define AT_RECEIVED_DATA            "+IPD"


[imghttp://laptrinhpic.info/wp-content/uploads/2014/10/esp8266_pinout-300x124.png]http://[/img]


http://youtu.be/FD3tVrwhxxw

Alıntı yapılan: hasanmert - 08 Mart 2017, 12:55:19mrb arkadaşlar,
ESP8266 uygulaması ile uğraşıyorum
sonbui/mystr.c dosyasını bulamadım. Bu dosyayı nereden bulurum?




Bu dosya eksik görünüyor. Kodda geçen mystr.c dosyasını eklememişsiniz.