[SOLVED] ESP32-CAM and EspSoftwareSerial with CamerWebServer

Federico66
Posts: 4
Joined: Mon Jul 29, 2019 8:54 am

[SOLVED] ESP32-CAM and EspSoftwareSerial with CamerWebServer

Postby Federico66 » Mon Jul 29, 2019 9:14 am

Hallo,
has anyone tried to use EspSoftwareSerial (https://github.com/plerup/espsoftwareserial) with ESP32-CAM?
I tried with simple tests to connect it with Arduino Uno and it works well, but as soon as I use it with the CamerWebServer sketch, ESP32-Cam can no longer identify the camera!
I tried with all the free pins, but the result is always the same.
For pin connection i used a Bi-Directional Logic Level Converter (3.3V<->5V)
I'm not using the SD card.

Code: Select all

//... omissis
#include <SoftwareSerial.h>
#define RX_PIN 2
#define TX_PIN 4
#define BAUD_RATE 57600
SoftwareSerial sSerial;

#define CAMERA_MODEL_AI_THINKER
//... omissis
void startCameraServer();

void setup() {
  Serial.begin(115200);
  Serial.setDebugOutput(true);
  Serial.println();
  
  sSerial.begin(BAUD_RATE, RX_PIN, TX_PIN, SWSERIAL_8N1, false, 95, 11);
//... omissis
  sSerial.write(WiFi.localIP());
}
//... omissis

TIA
Federico

PS
Sorry for my english
Last edited by Federico66 on Mon Aug 05, 2019 6:20 pm, edited 1 time in total.

VladTheImpaler
Posts: 16
Joined: Fri Jul 05, 2019 4:35 am

Re: ESP32-CAM and EspSoftwareSerial with CamerWebServer

Postby VladTheImpaler » Tue Jul 30, 2019 4:08 am

Why would you use softserial on a chip with 2 hardware serial?
Do you understand softwareserial is a cripple going "bang" if there is a small delay in interrupt handling? Do you understand softserial wastes cpu cycles and is unreliable? Avoid that shit like tha plague.

If you insist on using softserial be aware the cam uses timer1 so your softcripple has to use timer2.

Federico66
Posts: 4
Joined: Mon Jul 29, 2019 8:54 am

Re: ESP32-CAM and EspSoftwareSerial with CamerWebServer

Postby Federico66 » Tue Jul 30, 2019 8:01 am

VladTheImpaler wrote: Why would you use softserial on a chip with 2 hardware serial?
I'm sorry, I'm new to ESP32 and in the pinout of the ESP32-CAM module I only see U2RXD on GPIO16, but I don't see a U2TXD!
The GPIO17 (U2TXD) on the chip does not seem to be usable in this module.
So, how can I use the second hardware serial in ESP32-CAM?
VladTheImpaler wrote: If you insist on using softserial be aware the cam uses timer1 so your softcripple has to use timer2.
Thanks for the information, I will keep it in mind

TIA
Federico

lukas1000
Posts: 7
Joined: Mon Jul 29, 2019 7:29 pm

Re: ESP32-CAM and EspSoftwareSerial with CamerWebServer

Postby lukas1000 » Tue Jul 30, 2019 10:59 am

I'm not an expert, but some days ago I used all 3 HW serial ports on an ESP32 Pico Kit.
As I now, you can map TX RX to nearly every pin you like.

Code: Select all

#include <HardwareSerial.h>

HardwareSerial mySerial(1);
HardwareSerial mySerial2(2);

uint8_t byteFromSerial;
 
void setup() {  
    Serial.begin(115200);  17 TX / 16 RX 
    mySerial.begin(115200, SERIAL_8N1, 23, 19); <- set your TX/RX Pin
    mySerial2.begin(115200, SERIAL_8N1, 9, 10); <- set your TX/RX Pin
}

void loop() {
   while (mySerial.available() > 0) {
         byteFromSerial= mySerial.read();
         Serial.write(byteFromSerial);
    }
    
   while (mySerial2.available() > 0) {
         byteFromSerial= mySerial2.read();
         Serial.write(byteFromSerial);
    }
  
     while (Serial.available() > 0) {
        byteFromSerial = Serial.read();
         mySerial.write(byteFromSerial);
         mySerial2.write(byteFromSerial);
    }
}

VladTheImpaler
Posts: 16
Joined: Fri Jul 05, 2019 4:35 am

Re: ESP32-CAM and EspSoftwareSerial with CamerWebServer

Postby VladTheImpaler » Tue Jul 30, 2019 11:54 am

Define your own pins. https://circuits4you.com/2018/12/31/esp ... 2-example/

"Like all peripherals, the pins for the UARTs can be logically mapped to any of the available pins on the ESP32. "

Federico66
Posts: 4
Joined: Mon Jul 29, 2019 8:54 am

Re: ESP32-CAM and EspSoftwareSerial with CamerWebServer

Postby Federico66 » Tue Jul 30, 2019 3:14 pm

VladTheImpaler wrote: "Like all peripherals, the pins for the UARTs can be logically mapped to any of the available pins on the ESP32. "
I tried with pins 16 and 14 (RX2, TX2) and it seems to work, many thanks.

Still taking advantage of your availability, on ESP32-CAM, if I use the sd card, in addition to pin 16, there are no other pins available, correct?

TIA
Federico

Federico66
Posts: 4
Joined: Mon Jul 29, 2019 8:54 am

Re: ESP32-CAM and EspSoftwareSerial with CamerWebServer

Postby Federico66 » Mon Aug 05, 2019 6:19 pm

I solved by setting SDMMC to 1-line mode (SDMMC_HOST_FLAG_1BIT); in this mode the pins 4,12,13 are available, so I used pins 16 and 13 for a second hardware serial.

Federico

wattexi
Posts: 5
Joined: Mon Nov 25, 2019 8:21 pm

Re: [SOLVED] ESP32-CAM and EspSoftwareSerial with CamerWebServer

Postby wattexi » Sun Dec 01, 2019 11:20 pm

Hello, @Federico66 => I play with esp32-cam and I want to use "1-line mode" for use SoftwareSerial. I want to put myself in this mode but I do not know how. can you help me?
Federico66 wrote: I solved by setting SDMMC to 1-line mode (SDMMC_HOST_FLAG_1BIT); in this mode the pins 4,12,13 are available, so I used pins 16 and 13 for a second hardware serial.

Federico

nacxo@hotmail.com
Posts: 1
Joined: Wed Feb 17, 2021 3:57 pm

Re: [SOLVED] ESP32-CAM and EspSoftwareSerial with CamerWebServer

Postby nacxo@hotmail.com » Wed Feb 17, 2021 4:03 pm

Dear @federico66 can you say how we can do that?

Use finally gpios as UART por Hardware/Software comunication with other devices? (in my case Mp3-tf-16p)

I can use the next code without problems until y run the camera... then its reboot continiusly:

SoftwareSerial secondarySerial(14, 15); // RX, TX
DFMiniMp3<SoftwareSerial, Mp3Notify> mp3(secondarySerial);

PD: I get the cameraweb IDE demo and i dont use the sdcard so...

Who is online

Users browsing this forum: No registered users and 33 guests