Connection ESP8266 to UART 1 of 328PB

Hi,

I have successfully connected the ESP8266 module on UART 0 of the 328PB. I have flashed a BareMinimum with the 'https://arduino.esp8266.com/stable/package_esp8266com_index.json' added to the boards manager.

However, I would like to use the UART 1 (pin 15 and pin 16) of the 328PB. How can I do this? I do not see how UART 0 (pin 30 and pin 31) has been set as the default.

Thanks for your help!

Mike

Welcome to the forum

Why did you start a topic in the Uncategorised category of the forum when its description explicitly tells you not to ?

Your topic has been moved to a relevant category. Please be careful in future when deciding where to start new topics

Hi @MikeHoogendam.

I'm not sure I understood correctly what you mean by this. Please provide a more detailed description of what you mean by this in a reply on this forum thread to help us to understand it.

What exactly do you want to use UART 1 for?

Have you tried using it already? If yes, please provide a detailed description of what you tried, including circuit connections and any code you used. Please also provide the following information:

  • What were the results you expected when you used it?
  • What were the results you observed that did not match your expectations?

Hi @ptillisch,

Thank you for your reply.

I have a prototype PCBA with the 328PB. I am using an 5V usb to TTL converter for flashing purposes. I would like to connect an ESP8266 to the 328PB.

I have connected the ESP8266 to an external 3V3 PS, with the GND of the PS ESP8266 and prototype PCBA connected. The reset of the ESP8266 is connected to 3V3 as well. And I connected the Rx of the ESP8266 to pin 31 (Tx) of the 328PB and the Tx of the ESP8266 to pin 30 (Rx) of the 328PB. Next I flash the firmware and open the serial monitor, I then sent AT at baudrate 115200 and I get an OK. WIFI_BASIC.zip (445 Bytes)

However, I want to connect the Rx of the ESP8266 to pin 15 (Tx) of the 328PB and the Tx of the ESP8266 to pin 16 (Rx) of the 328PB. This is UART 1 and not UART 0. Ofcourse I have tried this, but the serial monitor of the Arduino IDE uses UART 0 for serial data and not through UART 1.

So my questions are:

  1. How can I connect the ESP8266 to UART 1 and sent commands through the Arduino IDE serial monitor when the USB to TTL converter is connected to UART 0?
  2. If I want to set the 8266 up as a node which has to be connected to WIFI later, do I have to flash the ESP8266 directly through a USB to TTL converted or can I do this through the 328PB?

Thanks for your help!

Mike

You should be aware that, if the ATmega328PB is running at 5 V, then you are subjecting the RX pin of the 3.3 V ESP8266 to 5 V, which is above the rated maximum of 3.6 V (per figure 5.1 in the datasheet). It is possible this could cause permanent physical damage to the ESP8266. The correct way to make such a connection is via a level shifter.

As you and many other members of the Arduino community have discovered, it is possible to get away with subjecting the pin to 5 V. There is even a "official" statement in a Facebook group that it is 5 V tolerant from someone with username "Teo Swee Ann" who claimed (I don't have any reason to disbelieve it, but you must always be skeptical when it comes to social media) to be the CEO of Espressif (the manufacturer of the ESP8266):

However, I find it strange that Espressif would choose to announce such critical information only in an obscure location, while contradicting it in the datasheet, which is the canonical source of such information. The explanation given for this is ludicrous:

Chris Gimson: I would really appreciate it if you could explain (again) why you took it out of the spec sheet.

Teo Swee Ann: the reason is too many users took it to mean that the chip is 5 V tolerant. When we say 5 V tolerant, we are only referring to the IOs. So some users mistook this to make that they can power the chip entirely off the 5 V supply.

You must upload a sketch to the ATmega328PB that acts as a "passthrough" of data between Serial and Serial1:

void setup() {
  Serial.begin(115200);
  Serial1.begin(115200);
}

void loop() {
  if (Serial.available()) {        // If anything comes in Serial
    Serial1.write(Serial.read());  // read it and send it out Serial1
  }

  if (Serial1.available()) {       // If anything comes in Serial1
    Serial.write(Serial1.read());  // read it and send it out Serial
  }
}

You should be able to do it via the ATmega328PB, acting as a "passthrough" for the upload serial data.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.