Last active
March 15, 2016 12:09
-
-
Save atrakeur/41779610172603db7acb to your computer and use it in GitHub Desktop.
Code to flash an ESP8266 from an arduino. See article on https://www.atrakeur.com/blog/art28-comment_charger_son_propre_firmware_sur_lesp8266_a_travers_un_arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define RST_PIN 8 //Reset pin | |
#define CHPD_PIN 9 //CHPD pin | |
#define GPIO_PIN 10 //Flashmode pin | |
void setup() { | |
//Open serial | |
Serial.begin(115200); | |
Serial1.begin(115200); | |
//Set pin modes on arduino | |
pinMode(RST_PIN, OUTPUT); | |
pinMode(CHPD_PIN, OUTPUT); | |
pinMode(GPIO_PIN, OUTPUT); | |
//CHPD et RESET in running state (HIGH) | |
//GPIO0 in flash mode (LOW) | |
digitalWrite(CHPD_PIN, HIGH); | |
digitalWrite(RST_PIN, HIGH); | |
digitalWrite(GPIO_PIN, LOW); | |
//Wait for serial to come up (Leonardo?) | |
while(!Serial); | |
} | |
void loop() { | |
//Upload firmware from computer to ESP | |
if ( Serial.available() ) { Serial1.write( Serial.read() ); } | |
//Upload ESP responces to computer | |
if ( Serial1.available() ) { Serial.write( Serial1.read() ); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment