Hello Everyone,
I would like to use a wemos D1 mini (ESP12) for a project (replace an old sanguino)
The configuration is a Wemos D1 mini, a simple pushbutton (with resistor to ground) on pin D3, and SDA et SCL ports to 3 MCP23017 with pullup resistors.
I have two problems, quite similar i think:
1- In my program, when the board is powered, if D3 input is activate, the board has to activate update function by ota. The problem: if the pushbutton is activate before the board is powered, the program don't start
Here is the test program i did
byte mode_update = 0;
int ledState = LOW;
unsigned long previousMillis_manuel = 0;
unsigned long previousMillis_OTA = 0;
const long interval_manuel = 800;
const long interval_OTA = 50;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(D3, INPUT);
Serial.begin(115200);
delay(3000);
}
void loop() {
if (mode_update == 0 && !digitalRead(D3) || mode_update == 1) {
mode_update = 1;
Mode_update();
}
else {
mode_update = 2;
Mode_manuel();
}
digitalWrite(LED_BUILTIN, ledState);
}
void Mode_update() {
Serial.println("Programme Update OTA");
unsigned long currentMillis_OTA = millis();
if (currentMillis_OTA - previousMillis_OTA >= interval_OTA) {
previousMillis_OTA = currentMillis_OTA;
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
}
}
void Mode_manuel() {
Serial.println("boucle manuel");
unsigned long currentMillis_manuel = millis();
if (currentMillis_manuel - previousMillis_manuel >= interval_manuel) {
previousMillis_manuel = currentMillis_manuel;
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
}
}
2- I have nearly the same problem, my D1 mini use 3 MCP23017 on the I2C ports. But some time the program don't start because of I2C ports plug in?
Does someone know how to fix that?
thanks for your help