Go Down

Topic: HOW TO USE SERIAL TO TRIGGER PIN? (Read 644 times) previous topic - next topic

Juraj

you need to ground the gpio0 only for the reset. so a delay will do it.

Code: [Select]

    pinMode(ESP_GPIO0_PIN, OUTPUT);
    digitalWrite(ESP_GPIO0_PIN, LOW);
    pinMode(ESP_CH_EN_PIN, OUTPUT);
    digitalWrite(ESP_CH_EN_PIN, LOW);
    delay(5);
    pinMode(ESP_CH_EN_PIN, INPUT); // let it to esp module pull-up resistor
    delay(50);
    pinMode(ESP_GPIO0_PIN, INPUT); // let it to esp module pull-up resistor


set a boolean variable true after you detected data on Serial and make the reset.

in some intervals read all data from Serial, wait 100 ms and check if more data are still available, if not the flashing is over. set the boolean flag to false

 

Juraj

BUT, why you do not use Arduino OTA?

mixamode

#17
Dec 07, 2017, 12:41 pm Last Edit: Dec 07, 2017, 12:56 pm by mixamode
BUT, why you do not use Arduino OTA?
Thanks for the reply, I will try what you say,

In the mean time to answer your question with a question- can you use arduino serial monitor with OTA and esp8266? What I mean is that to my knowledge you cannot sent data from esp8266 to arduino serial monitor, say you want to read time on esp8266, can this data be sent to serial monitor OTA? I don't think so, besides the fact that the first sketch you always have to connect usb serial to esp8266 to upload OTA, not to mention memory limits with OTA... just a few I can think of I am sure there are more...

... another factor, which I don't want to sound funny about is why did Espressif come out with esp32?

Juraj

can you use arduino serial monitor with OTA and esp8266?
I use Eclipse IDE. there is the port for the Serial Monitor independent from the upload port. But the truth is I do not use SM, because I log to telnet.
you can open a second Arduino IDE, if only the port selection is the problem.

What I mean is that to my knowledge you cannot sent data from esp8266 to arduino serial monitor, say you want to read time on esp8266, can this data be sent to serial monitor OTA?
OTA telnet

the fact that the first sketch you always have to connect usb serial to esp8266 to upload OTA,
that is true, but bluetooth? it is a usb cable length range. a ftdi with dtr will do.

not to mention memory limits with OTA...
valid argument, but only with very small flash memory



Juraj

#19
Dec 07, 2017, 01:29 pm Last Edit: Dec 07, 2017, 01:29 pm by Juraj
I work with Uno WiFi. It connects on-board chips ATmega328 to ESP8266 on Serial1 (an additional on board UART  connected to Atmega as I2C device)

On UNO WiFi you can't disconnect the ESP from ATMega and connect it to USB adapter for flashing like you do it with a module. The solution is a software bridge, a sketch EspProxy in ATmega which copies bytes from USB to ESP and back.

Flashing tools send DTR signal to USB chip to trigger the reset of the processor to bootloader. The signal causes the reset of the ATmega with the EspProxy sketch. And EspProxy calls in setup() a reset or a reset to bootloader of ESP. This way the ESP is in bootloader mode if the tool or IDE requires it.

EspProxy detects esp flashing sync frame and resets ESP to botloader.

mixamode

I think that UnoWifi has a usb to serial adaptor, where all the magic takes place I suspect apart from pin manipulation in software. I have noted that there is a break on TX on my FTDI adaptor as serial data comes in, this break is exploited as a signal to place esp8266 into flash mode in some cases. The HC 05 does not transmit any break on TX line. Which is where the problem is.

So even to do this simple trick (see image attached)with HC 05 will not work. In other words if a physical USB to serial device is involved it will not work with HC 05, since they operate differently, that is why there are different kinds of usb to serial adaptors.

mixamode

As well as what the others have said you will need to clear the data from Serial f you want your trigger to go back to low. You can do that with
Code: [Select]
void loop() {
  if (Serial.available() >0 ) {
     digitalWrite(triggerPin, HIGH);
     while(Serial.available() >0 {
        Serial.read();
     }
  }
  else {
    digitalWrite(triggerPin, LOW);
  }
}


However you should consider that carefully as I suspect it is not what you actually need. You have not told us what you project is trying to do.

...R
Thanks alot this worked

Go Up