http://bbs.espressif.com/viewtopic.php?t=1613
//This one code to arduino
#include <SoftwareSerial.h>
SoftwareSerial esp8266(2,3);
char mensaje;
int cont=0;
void setup(){
pinMode(8,INPUT);
Serial.begin(9600);
esp8266.begin(9600);
}
void loop()
{
while(Serial.available()>0)
{
mensaje=Serial.read();
}
if(mensaje=='1')
{
if(digitalRead(8)==HIGH)
{
cont++;
Serial.println(cont);
delay(250);
}
}
else{
if(mensaje=='0')
{
esp8266.println(cont);
cont=0;
mensaje='1';
}
}
}
this one code to ESP8266
#include <ESP8266WiFi.h>
const char* ssid = "SSID";
const char* password = "PASSWORD";
const char* host = "10.0.0.10";//ip local of my pc
int date=0;
void setup() {
Serial.begin(9600);//
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
delay(5000);
WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
while(Serial.available()>0)
{
dato=Serial.read();
//Serial.println(date);
// This will send the request to the server
client.print("GET /Project/save.php?value=");
client.print(date);
client.println("HTTP/1.1");
}
}
any help is welcome