APC220 esp32 and Arduino Uno

Hi everyone, i have a problem. I want to connect the apc 220 to an esp32 and another apc220 to an Arduino Uno, but i can't quite get it to work.
Here is the code i have uploaded to the esp32:

#define RXD2 16
#define TXD2 17

int number = 0;

void setup() {

  Serial.begin(9600);
  Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);

}

void loop() {
(number ++);
Serial.print ("test   ");
Serial.println (number);
Serial2.print ("test   ");
Serial2.println (number);
delay (1000);
}

And here is the code I have on the Arduino Uno:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); 

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
}

void loop() {
  if(mySerial.available() > 1){
    String input = mySerial.readString();
    Serial.println(input);    
  }
  delay(10);
}

On the esp32 i have connected the RX0 from the apc220 to GPIO16 and TX0 to the GPIO17.
Is this correct or can't it connect because it is two different arduino's?

Note: Both apc220 are on the 3.3v

But is the Uno?
This is a 5V processor so any signal it sends the ESP will be too high for it.

It needs to be cut down using a resistive potential divider.
A bit like this only the sound sensor is your Arduino:-

Of course you can.
But power the Uno one from 5V

Okay, but it will not send data to the Arduino Uno

The Uno is powered by the cable, and the APC220 is on 3.3v. The other APC220 on the esp32 is also on 3.3v. But it wont sent data from the esp32 to the Arduino via the APC220 module.

You power the Esp one at 3.3 and the Uno one at 5V.

How you know that? Instead of Arduino not receiving...

Yeah maybe the Uno isn't receiving, but when i tried it with 2 esp32 it also didn't work. I am kinda new to arduino and i don't really understand how the Serial works.

With 2 Uno's it does work.

According to the APC220 data sheet and product page, it runs on 3.5-5V and is intended for use with 5V Arduinos like the Uno.

So there is no guarantee that it will operate on a 3.3V ESP32.

I tried to connect 2 apc220 to 2 different uno's at 3.3v and that worked. So if i connected it to the 3.3v from the esp32 it wont work?

Quite probably it works at 3.3 V even if the original datasheet gives 3.5V. What's the difference on your code between working uno and non working esp32?

That is a very bad idea. It is possible the the 5V logic, interfaced to 3.3V logic, increased the effective power supply voltage, possibly also damaging the input and output pins.

When connecting 5V logic to 3.3V logic, logic level shifters are required.

Use the APC220 with a 5V Arduino. Most other radio modules operate at 3.3V only and should be used with 3.3V processors (3.3V Arduinos, ESP32, etc.).

Oops i am sorry the apc220 on the arduino is powered from the 3.3v output. The arduino is not powered from 3.3v

That is the bad idea. When powered by 3.3V, the APC220 will use 3.3V logic.

You must not directly connect an output pin on a 5V Arduino to an input pin on a 3.3V radio. A logic level shifter is required.

The APC220 is designed to be used with 5V Arduinos.

This is the code I run on the "sending" Uno with apc220:

#include <SoftwareSerial.h>
SoftwareSerial mySerial(9,10);
int number = 0;

void setup() {

Serial.begin(9600);
  mySerial.begin(9600);

}

void loop() {
(number ++);
Serial.print ("test   ");
Serial.println (number);
mySerial.print ("test   ");
mySerial.println (number);
delay (1000);
}

The only difference from the esp32, is that i have change the GPIO ports and that i don't use SoftwareSerial.


As you can see on the picture, I connected the VCC input from the apc220 to the 3.3v onboard output for the arduino Uno, as the apc220 can run on 3.3v.

Good luck, and have fun with Arduino!

2 Likes

But it's not correct setup with 5V microcontroller. Your Uno tx at 5V to Apc that is powered at 3.3 an so abusing it.
I wrote on post#3, you should power the Uno one at 5V and the Esp one at 3.3V.

Sounds strange... what esp32 board exactly you use?

I have this one:

Hi jremington, I have found the issue. I had switched the RX0 and TX0 from the acp220 around :sweat_smile:. Thanks for the ideas to help me :heart_hands:

The only problem that I now have, is that the apc220 only recieves data when i power the esp32 off. I run the program to send numbers, but i dont recieve anything, and when i power the esp32 off it sends all the numbers in one time. I created a dedicated topic for the discussion of that problem:

And that is solution for you??