Enable Javascript


Last Arduino/ESP8266 project (click to open)

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

Take advantage of four ESP8266-01 D-Pins
Get 2 extra D-pins by using simple OTA upload.

  1. Upload the OTA sketch over Serial (see the lower image - flash mode: hold flash, reset and release flash).
  2. Add the LEDs and upload over OTA (Serial cannot be used)..

On a reset: GPIO-1(TX)-led flickers a short time with initialize data (for some applications less useful).
Sketch is written in Arduino IDE with boards manager esp8266 Arduino and ESP8266 OTA.

/***************** FourESP-01Pins *****************
    ESP8266-01 using four D-pins with simple OTA
  by Ewald Kendziorra sr, 2016 www.kendziorra.nl
**************************************************/

#include <ESP8266WiFi.h>
#include <ArduinoOTA.h>

/** edit ssid/pw **/
const char mySSID[] = "-edit-edit-";
const char myPASSWORD[] = "-edit-edit-edit-edit-";

void setup() {
  /** NO Serial!!! **/
  /** WiFi **/
  WiFi.disconnect();
  WiFi.mode(WIFI_STA);
  WiFi.begin(mySSID, myPASSWORD);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {delay(5000); ESP.restart();}
  /** OTA options **/
  ArduinoOTA.setHostname("pintest");
  ArduinoOTA.setPassword((const char *)"1qazxsw2");
  ArduinoOTA.onError([](ota_error_t error) {/** ERROR handling HERE **/;});
  /** OTA start **/
  ArduinoOTA.begin();

  /** ESP8266-01: GPIO 0, 1(TX), 2, 3(RX) **/
  for (uint8_t i = 0; i <= 3; i++) pinMode(i, OUTPUT);
}

void loop() {
  ArduinoOTA.handle();

  /** ESP8266-01: GPIO 0, 1(TX), 2, 3(RX) **/
  for (uint8_t i = 0; i <= 3; i++) digitalWrite(i, !digitalRead(i));
  delay(1000);
}