- Wed Aug 12, 2015 12:36 pm
#25811
Michaelo wrote:Looks interesting... have you determined the set up time for the ESP?
Barnabybear wrote:I don't have a scope so the only way I could think of to test the actual setup time would be to setup a second ESP with a loop taking a GPIO high for slowly increasing perids of time & using that as a trigger untill a stable value is reached.
Tested replacing the PIR with a second ESP, GPIO 2 was used in place of the PIR output running the code below:
Code: Select all//THIS CODE IS NOT PART OF THE SUBJECT OF THIS THREAD
//USED ONLY TO TEST THE DURATION OF TRIGGER NEEDED
//RUN ON A SECOND ESP TO TRIGGER THE FIRST IN PLACE OF A PIR
int GPIO2 = 2;
int val = 350;
void setup() {
pinMode(2, OUTPUT);
digitalWrite(GPIO2, LOW);
Serial.begin(115200);
Serial.println();
Serial.println("setup");
}
void loop() {
digitalWrite(GPIO2, HIGH);
delay(val);
digitalWrite(GPIO2, LOW);
Serial.println(val);
delay(60000);
Serial.println();
}
The requirement was to boot and take GPIO 0 high to hold CH_PD keeping the ESP active when the trigger was removed.
Results:
300ms triggered exactly 50% of the time & was every other attempt (strange needs more investigation), (50 tests).
350ms triggered 100% of the time, (200 tests).
325ms triggered 100% of the time, (200 tests).
From this testing on 2 prototype boards with lots of link wires for connections & measurement, it looks like 325ms is the shortest reliable trigger pulse needed to boot & hold CH_CP high on an ESP running the code listed in the first post of this thread.
This could possably be speeded up as
Code: Select allWiFiClient client; // starts a WiFi client.
& some other lines of code run before
Code: Select alldigitalWrite(holdPin, HIGH); // sets GPIO 0 to high (this holds CH_PD high even if the PIR output goes low)
I'm not sure how long it takes to set up a WiFi client. If needed, rearranging the code could save this time, weather it makes a significant difference is to be proven.