Tell us about yourself!

Complete Your Profile
  • jay777. commented on JayconSystems's instructable Using ESP-01 and Arduino UNO2 years ago
    Using ESP-01 and Arduino UNO

    Found a few issues with the code on this one and also the one from Jaycon. I reflashed my esp-01 using the ESP8266Flasher with v0.9.2.2 AT Firmware. This got me down to 9600 baud. If not you will need to set " mySerial.begin(9600); " to " mySerial.begin(115200); " 115200 is the default baud rate for the module. For the button was pressed part of it you have to refresh the web page then push the button. To turn the led off and on, you do just like in the how to. IP/LED=ON or IP/LED=OFF.Here is the corrected code that I just tested as working.#include <SoftwareSerial.h>#define TIMEOUT 5000 // mS#define LED 5SoftwareSerial mySerial(6, 7); // RX, TXconst int button = 11;int button_state = 0;void setup(){pinMode(LED,OUTPUT);pinMode(button,INPUT);Serial.begin(9600)...

    see more »

    Found a few issues with the code on this one and also the one from Jaycon. I reflashed my esp-01 using the ESP8266Flasher with v0.9.2.2 AT Firmware. This got me down to 9600 baud. If not you will need to set " mySerial.begin(9600); " to " mySerial.begin(115200); " 115200 is the default baud rate for the module. For the button was pressed part of it you have to refresh the web page then push the button. To turn the led off and on, you do just like in the how to. IP/LED=ON or IP/LED=OFF.Here is the corrected code that I just tested as working.#include <SoftwareSerial.h>#define TIMEOUT 5000 // mS#define LED 5SoftwareSerial mySerial(6, 7); // RX, TXconst int button = 11;int button_state = 0;void setup(){pinMode(LED,OUTPUT);pinMode(button,INPUT);Serial.begin(9600);mySerial.begin(9600);SendCommand("AT+RST", "Ready");delay(5000);SendCommand("AT+CWMODE=3","OK");SendCommand("AT+CIFSR", "OK");SendCommand("AT+CIPMUX=1","OK");SendCommand("AT+CIPSERVER=1,80","OK");}void loop(){button_state = digitalRead(button);if(button_state == HIGH){SendCommand("AT+CIPSEND=0,23","OK");delay(250);mySerial.println("<h1>Button was pressed!</h1>");delay(250);SendCommand("AT+CIPCLOSE=0","OK");}String IncomingString="";boolean StringReady = false;while (mySerial.available()){IncomingString=mySerial.readString();StringReady= true;}if (StringReady){Serial.println("Received String: " + IncomingString);if (IncomingString.indexOf("LED=ON") != -1) {digitalWrite(LED,HIGH);}if (IncomingString.indexOf("LED=OFF") != -1) {digitalWrite(LED,LOW);}}}boolean SendCommand(String cmd, String ack){mySerial.println(cmd); // Send "AT+" command to moduleif (!echoFind(ack)) // timed out waiting for ack stringreturn true; // ack blank or ack found}boolean echoFind(String keyword){byte current_char = 0;byte keyword_length = keyword.length();long deadline = millis() + TIMEOUT;while(millis() < deadline){if (mySerial.available()){char ch = mySerial.read();Serial.write(ch);if (ch == keyword[current_char])if (++current_char == keyword_length){Serial.println();return true;}}}return false; // Timed out}

    Found a few issues with the code on this one. I reflashed my esp-01 using the ESP8266Flasher with v0.9.2.2 AT Firmware. This got me down to 9600 baud. If not you will need to set " mySerial.begin(9600); " to " mySerial.begin(115200); " 115200 is the default baud rate for the module. For the button was pressed part of it you have to refresh the web page then push the button. To turn the led off and on, you do just like in the how to. IP/LED=ON or IP/LED=OFF.Here is the corrected code that I just tested as working.#include <SoftwareSerial.h>#define TIMEOUT 5000 // mS#define LED 5SoftwareSerial mySerial(6, 7); // RX, TXconst int button = 11;int button_state = 0;void setup(){pinMode(LED,OUTPUT);pinMode(button,INPUT);Serial.begin(9600);mySerial.begin(9600);SendCom...

    see more »

    Found a few issues with the code on this one. I reflashed my esp-01 using the ESP8266Flasher with v0.9.2.2 AT Firmware. This got me down to 9600 baud. If not you will need to set " mySerial.begin(9600); " to " mySerial.begin(115200); " 115200 is the default baud rate for the module. For the button was pressed part of it you have to refresh the web page then push the button. To turn the led off and on, you do just like in the how to. IP/LED=ON or IP/LED=OFF.Here is the corrected code that I just tested as working.#include <SoftwareSerial.h>#define TIMEOUT 5000 // mS#define LED 5SoftwareSerial mySerial(6, 7); // RX, TXconst int button = 11;int button_state = 0;void setup(){pinMode(LED,OUTPUT);pinMode(button,INPUT);Serial.begin(9600);mySerial.begin(9600);SendCommand("AT+RST", "Ready");delay(5000);SendCommand("AT+CWMODE=3","OK");SendCommand("AT+CIFSR", "OK");SendCommand("AT+CIPMUX=1","OK");SendCommand("AT+CIPSERVER=1,80","OK");}void loop(){button_state = digitalRead(button);if(button_state == HIGH){SendCommand("AT+CIPSEND=0,23","OK");delay(250);mySerial.println("<h1>Button was pressed!</h1>");delay(250);SendCommand("AT+CIPCLOSE=0","OK");}String IncomingString="";boolean StringReady = false;while (mySerial.available()){IncomingString=mySerial.readString();StringReady= true;}if (StringReady){Serial.println("Received String: " + IncomingString);if (IncomingString.indexOf("LED=ON") != -1) {digitalWrite(LED,HIGH);}if (IncomingString.indexOf("LED=OFF") != -1) {digitalWrite(LED,LOW);}}}boolean SendCommand(String cmd, String ack){mySerial.println(cmd); // Send "AT+" command to moduleif (!echoFind(ack)) // timed out waiting for ack stringreturn true; // ack blank or ack found}boolean echoFind(String keyword){byte current_char = 0;byte keyword_length = keyword.length();long deadline = millis() + TIMEOUT;while(millis() < deadline){if (mySerial.available()){char ch = mySerial.read();Serial.write(ch);if (ch == keyword[current_char])if (++current_char == keyword_length){Serial.println();return true;}}}return false; // Timed out}

    View Instructable »