Skip to content

Instantly share code, notes, and snippets.

@atrakeur
Last active March 15, 2016 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atrakeur/9e674dbfaf3d4ed420a6 to your computer and use it in GitHub Desktop.
Save atrakeur/9e674dbfaf3d4ed420a6 to your computer and use it in GitHub Desktop.
Sample code to start using an esp8266 from an arduino. See full blog post on https://www.atrakeur.com/blog/art27-ajoutez_du_wifi_sur_votre_projet_arduino_simplement
#define RST_PIN 8
#define CHPD_PIN 9
#define DISP_PIN 13
void setup() {
//Ouvre le serial vers le pc (serial) et vers l'esp (serial1)
Serial.begin(9600);
Serial1.begin(115200);
//Leonardo: On attend l'ouverture du serial sur le pc avant de continuer
while(!Serial);
//Place les reset en sortie
pinMode(RST_PIN, OUTPUT);
pinMode(CHPD_PIN, OUTPUT);
//Met a zéro (reset l'ESP)
digitalWrite(RST_PIN, LOW);
digitalWrite(CHPD_PIN, LOW);
//Délai just in case
delay(500);
//Active l'esp
digitalWrite(RST_PIN, HIGH);
digitalWrite(CHPD_PIN, HIGH);
}
void loop() {
//transfere ce qui est reçu de l'esp vers le pc
if ( Serial1.available() ) { Serial.write( Serial1.read() ); }
//Transfere ce qui est reçu du pc vers l'esp
if ( Serial.available() ) { Serial1.write( Serial.read() ); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment