- Mon Jun 13, 2016 5:50 pm
#49148
I am pretty sure it is not a software issue.
Here is a schematic i am using using an esp12 module. It works with OTA programming.
https://snag.gy/Oh805l.jpgThe huzzah breakout board does not.
https://www.adafruit.com/product/2471I have uploaded the same code to each board. After i upload, the huzza product will upload, but when it resets it resest into bootloader. With my own ESP, it resets into normal mode.
Code: Select all#include <Wire.h>
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <Ticker.h>
#include <Button.h>
#include <Encoder.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Ticker tickerOSWatch;
IPAddress controller(192, 168, 0, 30);
IPAddress ip(192, 168, 0, 35);
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
WiFiServer TelnetServer(23);
WiFiClient TelnetClient;
WiFiUDP toController;
Adafruit_SSD1306 display(19);
#define encoderA 5
#define encoderB 4
#define encSw 13
#define SCL 14
#define SDA 12
Button select(encSw, true, true, 20);
Encoder navigation(encoderA, encoderB);
#define OSWATCH_RESET_TIME 100
static unsigned long last_loop;
char ssid[] = "gilchrest2";
char pass[] = "mike2323";
unsigned int localPort = 8888;
void ICACHE_RAM_ATTR osWatch(void) {
unsigned long t = millis();
unsigned long last_run = abs(t - last_loop);
if (last_run >= (OSWATCH_RESET_TIME * 1000)) {
TelnetClient.println("WatchDog Reset Activated");
// save the hit here to eeprom or to rtc memory if needed
ESP.restart(); // normal reboot
//ESP.reset(); // hard reset
}
}
long oldPosition = -999;
void setup(){
Wire.begin(SDA, SCL);
pinMode(encSw, INPUT_PULLUP);
display.begin(0x78);
display.clearDisplay();
tickerOSWatch.attach_ms(((OSWATCH_RESET_TIME / 3) * 1000), osWatch);
Serial.begin(115200);
Serial.println("Booting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, pass);
WiFi.config(ip, gateway, subnet);
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("Connection Failed! Rebooting...");
delay(5000);
ESP.restart();
}
// Port defaults to 8266
// ArduinoOTA.setPort(8266);
// Hostname defaults to esp8266-[ChipID]
ArduinoOTA.setHostname("Front Switch");
// No authentication by default
// ArduinoOTA.setPassword((const char *)"123");
ArduinoOTA.onStart([]() {
Serial.println("Start");
});
ArduinoOTA.onEnd([]() {
Serial.println("\nEnd");
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed");
});
ArduinoOTA.begin();
Serial.println("Ready");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
TelnetServer.begin();
toController.begin(4525);
TelnetServer.setNoDelay(true);
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("LOADINGS..");
display.display();
delay(1000);
display.clearDisplay();
display.setCursor(0,0);
display.println(" 12345678 ");
display.display();
}
void loop(){
last_loop = millis();
ArduinoOTA.handle();
if(!TelnetClient) {
TelnetClient = TelnetServer.available();
}
select.read();
if(select.wasPressed()){
TelnetClient.println("Button Pressed");
}
long newPosition = navigation.read();
if (newPosition != oldPosition) {
oldPosition = newPosition;
TelnetClient.print("Encoder Position: ");
TelnetClient.println(newPosition);
}
if(newPosition < 0){
navigation.write(90);
}
if(newPosition > 90){
navigation.write(0);
}
if(newPosition < 10){
display.clearDisplay();
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println(" ");
display.drawLine(11, 0, 11, 15, WHITE);
display.setTextColor(BLACK, WHITE);
display.setCursor(12,0);
display.println("1");
display.setTextColor(WHITE);
display.setCursor(24,0);
display.println("2345678 ");
display.display();
}
else if(newPosition < 20){
display.clearDisplay();
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println(" 1");
display.setTextColor(BLACK, WHITE);
display.setCursor(24,0);
display.println("2");
display.drawLine(23, 0, 23, 15, WHITE);
display.setTextColor(WHITE);
display.setCursor(36,0);
display.println("345678 ");
display.display();
}
else if(newPosition < 30){
display.clearDisplay();
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println(" 12");
display.setTextColor(BLACK, WHITE);
display.setCursor(36,0);
display.println("3");
display.drawLine(35, 0, 35, 15, WHITE);
display.setTextColor(WHITE);
display.setCursor(48,0);
display.println("45678 ");
display.display();
}
else if(newPosition < 40){
display.clearDisplay();
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println(" 123");
display.setTextColor(BLACK, WHITE);
display.setCursor(48,0);
display.println("4");
display.drawLine(47, 0, 47, 15, WHITE);
display.setTextColor(WHITE);
display.setCursor(60,0);
display.println("5678 ");
display.display();
}
else if(newPosition < 50){
display.clearDisplay();
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println(" 1234");
display.setTextColor(BLACK, WHITE);
display.setCursor(60,0);
display.println("5");
display.drawLine(59, 0, 59, 15, WHITE);
display.setTextColor(WHITE);
display.setCursor(72,0);
display.println("678 ");
display.display();
}
else if(newPosition < 60){
display.clearDisplay();
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println(" 12345");
display.setTextColor(BLACK, WHITE);
display.setCursor(72,0);
display.println("6");
display.drawLine(71, 0, 71, 14, WHITE);
display.setTextColor(WHITE);
display.setCursor(84 ,0);
display.println("78 ");
display.display();
}
else if(newPosition < 70){
display.clearDisplay();
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println(" 123456");
display.setTextColor(BLACK, WHITE);
display.setCursor(76,0);
display.println("7");
display.drawLine(75, 0, 75, 14, WHITE);
display.setTextColor(WHITE);
display.setCursor(89,0);
display.println("8 ");
display.display();
}
else if(newPosition < 80){
display.clearDisplay();
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println(" 1234567");
display.setTextColor(BLACK, WHITE);
display.setCursor(86,0);
display.println("2");
display.drawLine(85, 0, 85, 14, WHITE);
display.setTextColor(WHITE);
display.setCursor(99,0);
display.println(" ");
display.display();
}
}