ESP32-CAM with UART piggyback module - pins and connections

Hi, I bought from AE this package:
package

I want to connect this to a Mega2560 board, which handles a bunch of sensors, possibly using a serial port. I'm at the very beginning with this idea (not a project yet) and I never used the ESP32-CAM before. I tested it stand-alone with the classic WEB app and it works quite well; I can see the video and configure it on my PC through the internal WiFi network (although the image quality is not what expected).

Now, I have 3 questions:

  1. how can I power the ESP, without the USB cable, since there is not any connector available on both boards?
  2. can I use the U0TXD and U0RXD to communicate with the Mega? I doubt it since I presume those pins are also used by the piggyback board.
  3. is there any other pin available on the ESP? From this picture, it seems not (if the orange ones are dedicated to the onboard hardware):

pins

I understand (maybe) that I could use the piggyback to only program the ESP and then detach it, but...and it will not solve the above point 3, anyway, right?
Thanks

the Mega uses 5V logic and the ESP32 3.3V therefore you need a potential divider on the Mega Tx signal, e.g.

the ESP32-CAM code using hardware serial port Serial1 using GPIO14 and 15

// ESP32-CAM  Serial1 test

// for loopback test connect pins 14 and 15

#define RXD1 14
#define TXD1 15

void setup() {
  // initialize both serial ports:
  Serial.begin(115200);
  Serial1.begin(115200, SERIAL_8N1, RXD1, TXD1);
  Serial.println();
  Serial.println("serial1  test Rx pin 14 Tx pin 15");
}

void loop() {
  // read from port 1, send to port 0:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(inByte);
  }

  // read from port 0, send to port 1:
  if (Serial.available()) {
    int inByte = Serial.read();
    //Serial.write(inByte);
    Serial1.write(inByte);
  }
}

and the Mega code using hardware Serial1 port on pins 18 and 19

// Arduino Mega serial1 test

// mega Serial1 pin 18 is Tx
//      Serial1 pin 19 is Rx
// for loopback test connect pin 18 to pin 19

// for RS232 shield connect pin 18 to Tx and pin 19 to Rx
// for loopback test connect 9 pin D connector pins 2 and 3
// connect GND pins together

void setup() {
  Serial.begin(115200);   // initialise serial monitor port
  Serial1.begin(115200);  // initialise Serial1
  Serial.write("Arduino Mega Serial1 test -  for loopback test connect pin 18 to pin 19\n");
}

void loop() {
  if (Serial1.available()) {      // read from Serial1 output to Serial
    Serial.write(Serial1.read());
  }
  if (Serial.available()) {       // read from Serial outut to Serial1
    char inByte = Serial.read();
    //Serial.write(inByte);     // local echo if required
    Serial1.write(inByte);
  }
}

how many sensors do you have on the Mega and what interfaces do they use? e.g. analogue, I2C, SPI, etc
could the ESP32 interface to the sensors simplifing the whole project?

do you use the ESP32 SD card?

also have a look at esp32-cam-ai-thinker-pinout

you can try powering the ESP32-CAM via the Mega 5V

if you are going to use the ESP32-CAM without connection to the serial monitor you could use GPIO1 and GPIO3 for serial communications with the Mega

I tend to say on the ESP's RX-line, that way when the TX & RX lines are swapped (for direct communication) it is still on the correct line.
You can actually assign any of the GPIO to be used by any of the UART's on an ESP32, and you can also do away with the piggy-back all together and program the ESP32 Thru the Mega. Even using a Serial-passthrough (full-duplex) it can be done, though you would have to set the upload speed to something that is supported by the Mega (921600 isn't i think, 115200 is the safest, AVR's support up to 1Mbps, but the speed is set as part of the MCU clockspeed which is 16MHz.

Thanks for your code about a sw serial, but actually my question/s is/are different.
I bought this module right to not have to attach/detach a USB/UART module every time I must program the ESP. Unfortunately this does not leave any pin available for something else.

For the power, I have both 3.3 and 5V from the MEGA, but where could I connect this voltage? I mean, the UART auxiliary board has it own regulator which takes the 5V from the USB connector; when I do not connect any USB cable I have not other point to attach; I could solder two wire onto the ESP module, but it will still be connected to the other board and I'm not sure this is something correct.

Regarding your example to use the hardware serial port Serial1 on GPIO14 and 15, does it mean that these pins are freely available? The fact that they are marked in orange as HS2-something made me think they are reserved.

For your info I do not use/need the SD card and the Mega is required since I have to handle several peripheral (I2C, SPI, dedicate pins for servos and displays), to many for any other MCU.

Hope this is all clear.

the esp32-cam-ai-thinker-pinout states
You can power the ESP32-CAM through the 3.3V or 5V pins. However, many people reported errors when powering the ESP32-CAM with 3.3V, so we always advise to power the ESP32-CAM through the 5V pin.

the HS2 pins are SPI and used for the SD so if you are not using them they may be used as normal IO

So just connect 5v to mega 5v.

Does the piggy-back module does not forward the 5v & GND pins ?

unless you are very good at soldering I would not recommend soldering wires on to the ESP32-CAM pins
plug the ESP32-CAM or the piggy-back module into a Solderless Prototype Breadboard, e.g.
image

I did several MSOP soldering, so I do not have any problems with that.
The point is that if I do not disconnect the below module, the 5V will go to its circuit; I do not know exactly where, but possibly at the voltage regulator output that will be then reverse biased. I should need 2 or 3 welds for the other signals too.
Then there is a practical and aesthetic issue; I will have a bunch of flying wires (gnd, +5, tx, rx, a possible other pin) ; at the end, quite a mess.
Sure, I could accept a flying 6 pin dupont (or similar) connector, but it is not a wonder.

I'm going to rethink everything.

That is a possible issue. But not only do some regulators allow for that, there may be some diodes in place to prevent issues. You need the schematic to know what is what. You can power an ESP32 devkit thru either the 5v or the 3.3v pin. Those boards have similar regulators on board.

I tend to build an adapter on a bit of experimentation board, and solder female header pins onto that and make connectors to connect boards.

I don't like dupont flying wires either - OK for quick prototyping but give rise to poor connections and intermittent problems
one can get Prototype screw terminal boards for the Mega etc which can give a more reliable connection
for large numbers of devices goto custom PCBs

The origin of this confusione comes directly from the ESP32-CAM module that is, it's just my poor opinion, bad engineered. It would have been quite easy to provide a connector for, at least, the 4 needful pins (+,-,tx,rx) and a jumper to short IO0 to ground. Said that, the piggy-back module is even worst. No schematics and all then pins connected between the boards (really or just to have a unique female connector?) which possibly prevent to use the pin themselves.

When I started to think about using this CAM module I saw all the example about the programming method and I thought that it is quite stupid to have an external signal converter (that I do not have, yet), attach 4 flying wires, make a shoring jumper any time a new upload is required. From this the idea to buy this combo which make it easier, at least at the very beginning; I did not think enough to the follow up.

Now, since I can not, unfortunately, change the ESP, I'm now trying to figure out a different approach which is: buy a FTDI-USB module and hack it a little (?) to take only the needed signals and make an auxiliary PCB to provide the connector (a nice JST), the programming jumper (or switch) and a switch (or just a schottky diode) to avoid the power issue...maybe it will a mess, but...I will sleep tonight and tomorrow I'll see.
'night

Hold on, hold on.

But there are OTA updates on an ESP !! seriously if you make OTA updates part of your sketch once(and every sketch you upload after that) you can upload Over The Air without issue straight from the IDE or use HTML uploads for updates at a distance when the IDE is not available or the ESP is being used as an Access Point.

Yeah, hold on.

The ESP32CAM is really a plug in module, for a breadboard\stripboard, in the same way that ESP32 Dev modules are.

Its not at all difficult to make it do a lot of stuff, but you need to understand the schematic and have a bit of imagination.

It is what it is, if you think the design could be improved, then do it, think of the money you would make ..........

Examples;

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