hi all,
i m actually new to esp thing and i tried a simple code which sets esp server and lights the LED on digital pin 13 , i see that esp connects to my network from my modem s interface but i cant connect to that IP. why? which ip should i use to connect to the server? i m using the code below
#define ag_ismi "SUPERONLINE_WiFi_1074"
#define ag_sifresi "*******"
void setup()
{
Serial.begin(115200); //Seriport'u açıyoruz. Güncellediğimiz
//ESP modülünün baudRate değeri 115200 olduğu için bizde Seriport'u 115200 şeklinde seçiyoruz
Serial.println("AT"); //ESP modülümüz ile bağlantı kurulup kurulmadığını kontrol ediyoruz.
pinMode(13,OUTPUT);
delay(3000); //ESP ile iletişim için 3 saniye bekliyoruz.
if(Serial.find("OK")){ //esp modülü ile bağlantıyı kurabilmişsek modül "AT" komutuna "OK" komutu ile geri dönüş yapıyor.
Serial.println("AT+CWMODE=1"); //esp modülümüzün WiFi modunu STA şekline getiriyoruz. Bu mod ile modülümüz başka ağlara bağlanabilecek.
delay(2000);
String baglantiKomutu=String("AT+CWJAP=\"")+ag_ismi+"\",\""+ag_sifresi+"\"";
Serial.println(baglantiKomutu);
delay(5000);
}
Serial.print("AT+CIPMUX=1\r\n");
delay(200);
Serial.print("AT+CIPSERVER=1,80\r\n");
delay(1000);
Serial.print("AT+CIFSR\r\n");
delay(1000);
}
void loop(){
if(Serial.available()>0){
if(Serial.find("+IPD,")){
String metin = "<head> Hello World </head>";
metin += "
<a href=\" ?pin=on\"><button type='button'>ON</button></a>";
metin += "
<a href=\" ?pin=off\"><button type='button'>OFF</button></a>";
String cipsend = "AT+CIPSEND=";
cipsend +="0";
cipsend +=",";
cipsend += metin.length();
cipsend += "\r\n";
Serial.print(cipsend);
delay(500);
Serial.println(metin);
led_yakma();
delay(2000);
Serial.println("AT+CIPCLOSE=0");
}
}
}
void led_yakma(){
String gelen ="";
char serialdenokunan;
while(Serial.available()>0){
serialdenokunan = Serial.read();
gelen +=serialdenokunan;
}
Serial.println(gelen);
if((gelen.indexOf(":GET /?pin=on")>1)){ //on butonuna basıldığında server adresinde /?pin=on var ise
digitalWrite(13,HIGH); //ledi yakar
}
if((gelen.indexOf(":GET /?pin=off")>1)){ // off butonuna basıldığında server adresinde /?pin=off var ise
digitalWrite(13,LOW); //ledi söndürür
}
}
OK this was for just a trial of WiFi module. What I actually wanna do is I have two WiFi modules and two arduinos and one dht22. I want one of modules get the temperature data of my room and send it to the other module connected to my combi by a relay module. So how can I do this?
Are you using a stand-alone esp-8266 with Arduino, or the combined esp-8266 microcontroller module? I just started testing esp-8266 (the stand alone one) tonight. I spent the last 8+ hours trying to figure out why random trash comes through serial port and I'm getting boot-failure errors returned.
Once you enter the land of "load the firmware" then welcome to a crazy maze of confusing information.
DocStein99:
Are you using a stand-alone esp-8266 with Arduino, or the combined esp-8266 microcontroller module? I just started testing esp-8266 (the stand alone one) tonight. I spent the last 8+ hours trying to figure out why random trash comes through serial port and I'm getting boot-failure errors returned.
Once you enter the land of "load the firmware" then welcome to a crazy maze of confusing information.
Standalone module and separate arduino uno. I updated module successfully but I don't know what to do now. Even if I can light a led through it I'll be happy. For my idea how can I make things work? For example I have to use 2 arduinos and 2 modules right?
With 2 modules trying to get them to communicate is twice the work. I would try and get only one 8266 module to communicate with the Arduino first. See if you can get the web page demo or any of the basics - and use the PC to connect to that.
For MY first experiments, I was getting garbage across the serial port. It took me a whole day and night to update the software, and I don't know if I did it right. There seems to be a few different types of firmware to do different things, and I do not fully understand what they all do.
For me, I just want a serial connection between the Arduino and WIFI 8266 (the tiny one, I think is 8266-1, with the 8 pins). After I finally loaded the firmware I send these commands (using serial.println()), with the 8266 rx & tx connected to pins 1 & 2 of Arduino:
"AT" (should reply "ok")
"AT+RST" (On MY setup it returns some confusing error codes. I do not know if the 8266 is expecting firmware or a program to run in stand-alone mode.)
"AT+GMR" will return the current firmware loaded with the SDK (I am still learning to understand).
There is a command after that I send to connect to the WIFI (taken from the readme file in the firmware zip file):
AT+CWMODE=3
AT+RST
AT+CWJAP="ssid","put_your_password_here"
--
The serial port should return "WIFI CONNECT" string. At that point you can check your router's dhcp table and be sure the device has connected to your local network.
I got this far, before becoming exhausted and tired from all the points of failure in my attempts.
Did you do any of that?
DocStein99:
With 2 modules trying to get them to communicate is twice the work. I would try and get only one 8266 module to communicate with the Arduino first. See if you can get the web page demo or any of the basics - and use the PC to connect to that.
For MY first experiments, I was getting garbage across the serial port. It took me a whole day and night to update the software, and I don't know if I did it right. There seems to be a few different types of firmware to do different things, and I do not fully understand what they all do.
For me, I just want a serial connection between the Arduino and WIFI 8266 (the tiny one, I think is 8266-1, with the 8 pins). After I finally loaded the firmware I send these commands (using serial.println()), with the 8266 rx & tx connected to pins 1 & 2 of Arduino:
"AT" (should reply "ok")
"AT+RST" (On MY setup it returns some confusing error codes. I do not know if the 8266 is expecting firmware or a program to run in stand-alone mode.)
"AT+GMR" will return the current firmware loaded with the SDK (I am still learning to understand).
There is a command after that I send to connect to the WIFI (taken from the readme file in the firmware zip file):
AT+CWMODE=3
AT+RST
AT+CWJAP="ssid","put_your_password_here"
--
The serial port should return "WIFI CONNECT" string. At that point you can check your router's dhcp table and be sure the device has connected to your local network.
I got this far, before becoming exhausted and tired from all the points of failure in my attempts.
Did you do any of that?
Yes i did all of them. and i can see my wifi module ip on my routers interface. and when i try to connect that ip from my browser it keeps saying "waiting" when i try to ping that ip it returns some values so its working actually and i could also send temperature readings of my room to "thingspeak" website. but what i actually want is to make my other module read the values of the module inside my room and send a command to arduino to make one of the digital pins HIGH or LOW according to the temperature values. so how can i do this ? nobody knows?
So, you can read data from the WIFI/Arduino, you just can't post data to it - right?