Hi, I want to send a signal from ESP32CAM that runs FOMO model, to Arduino UNO via UART after ESP32CAM detects the object.
I tried to integrate this code below into Examples ESP32 Camera code generated from Arduino Library
#define RXp2 14
#define TXp2 15
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial2.begin(115200, SERIAL_8N1, RXp2, TXp2);
}
void loop() {
for (int i =0; i<301; i++)
{
Serial2.println(i);
//Serial.println(Serial2.readString());
Serial.print("sent packet ");Serial.println(i);
delay(500);
}
}
Here’s is how I put the serial2.println to test it
void setup()
{
// put your setup code here, to run once:
Serial.begin(115200);
Serial2.begin(115200, SERIAL_8N1, RXp2, TXp2);
//comment out the below line to start inference immediately after upload
while (!Serial);
Serial.println("Edge Impulse Inferencing Demo");
if (ei_camera_init() == false) {
ei_printf("Failed to initialize Camera!\r\n");
}
else {
ei_printf("Camera initialized\r\n");
}
ei_printf("\nStarting continious inference in 2 seconds...\n");
ei_sleep(2000);
}
#if EI_CLASSIFIER_OBJECT_DETECTION == 1
bool bb_found = result.bounding_boxes[0].value > 0;
for (size_t ix = 0; ix < result.bounding_boxes_count; ix++) {
auto bb = result.bounding_boxes[ix];
if (bb.value == 0) {
continue;
}
ei_printf(" %s (%f) [ x: %u, y: %u, width: %u, height: %u ]\n", bb.label, bb.value, bb.x, bb.y, bb.width, bb.height);
}
if (!bb_found) {
ei_printf(" No objects found\n");
}
#else
for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) {
ei_printf(" %s: %.5f\n", result.classification[ix].label,
result.classification[ix].value);
if (result.classification[ix].value > 0.1)
{
Serial2.println("Detected");
Serial.println("Detected"); //local serial print
delay(500);
}
}
#endif
The problem is how can I serial print the results of result.classification[ix].label and
result.classification[ix].value
Thank you.
If I am not mistaken, the ESP32-CAM has only one Serial interface.
I’d suggest to have a look at Espressif or Arduino’s forum as it’s more related to the code logic than the inference itself.
Hi @louis , the serial communication is successful if I try with other code. But I can’t integrate with code from edge impulse. Because when I serial print using the code below after ei_printf, it doesn’t show anything. So I wonder where should I put if else code to serial print result.classification[ix].label and result.classification[ix].value.
Hey @sio_yx I am also trying the same process with my project. Had planned to use R-Pi but am stuck with esp32 cam and Arduino Uno. I have hit a roadblock in my project. Can you please help me replicate your methods, how you did what you did? It would be a great help if you could, also tell me how you made the Uno and the ESP communicate. Thanks.
Thanks for the reply. Can you also tell me how you were able to perform object detection? What was the condition that you set in order to make your system detect the object? How did you communicate that the object has been detected through the serial communication? Thanks.
@sk99 you may refer to Detect objects with centroids - Edge Impulse Documentation as well. After I trained my FOMO model, I uploaded the code using Arduino IDE. You can follow @MMarcial ‘s reply on this thread for the condition you mentioned. If the object has been detected, ESP32-CAM will send signal to Arduino UNO. The example can be found on Arduino forum, you can try to search that.