Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By sajado
#50396 Apologies if this is a noob question... but I am a bit of a noob...

I am currently designing a PCB with an Atmega 328P linked to an ESP12F via the TX and RX connections. In essence the ESP reads the serial output from the Atmega and sends it as an MQTT package. I would like to be able to program both chips in situ.

The Atmega is fine as I have broken out the SPI pins toa 6x2 header, but at the moment I have broken out just the GND, VCC, TX and RX for the ESP. I can foresee problems using the TX and RX to program whilst the same TX and RX are connected to the Atmega. I could set up some kind of isolator to break the link to the Atmega when the ESP's breakouts are connected to, but that seems clumsy.

Is there a way to program the ESP via the SPI pins? I have not been able to find any information regarding this, but it seems like it should be possible. I could then leave TX and RX as just communication between the ESP and ATmega. I am using the Arduino IDE to program if that makes a difference.
User avatar
By RFZ
#50442 I have no Idea about programming via SPI, but:

As long as your Arduino is in reset-mode, or its TX Pin is set to INPUT via your software, you can just interface the RX/TX pins to program the ESP as if the arduino was not connected at all. No problem there...

You may also use I2C/TWI to talk between your Arduino and ESP. It is less complicated than TTL/serial, because you have flow control implemented (which you otherwise have to implement in software your own when using TTL/serial). You have higher data rate (I tested it up to 2MHz clock speed on a 16MHz Arduino).
No need for level converters, because a 5V arduino has no problems with 3.3V I2C/TWI.
AND: You have your Serial interface free for programming/debugging on both, the ESP and the Arduino.