Skip to content

Instantly share code, notes, and snippets.

@elmarcoh
Created December 2, 2015 20:05
Show Gist options
  • Save elmarcoh/dc7414838ec36a9e2edb to your computer and use it in GitHub Desktop.
Save elmarcoh/dc7414838ec36a9e2edb to your computer and use it in GitHub Desktop.
Arduino Wifi
#include <SoftwareSerial.h>
SoftwareSerial ESP8266(2, 3);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); //HARDWARE
ESP8266.begin(9600);//SOFTWARE
enviar_dato("AT", 1000);
}
void loop() {
/*/ put your main code here, to run repeatedly:
if(Serial.available()){
char c = Serial.read();
ESP8266.print(c);
}
if(ESP8266.available()){
char c = ESP8266.read();
Serial.print(c);
}
*/
}
String enviar_dato(String comando, int delay_) {
String respuesta = "";
ESP8266.println(comando);
long tiempo = millis();
while ( (tiempo + delay_) > millis()) {
while (ESP8266.available()) {
char c = ESP8266.read();
respuesta += c;
}
}
Serial.print(respuesta);
return respuesta;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment