I am looking to build real time measurement detection by using multiple TFmini-s and ESP32 but I can not seem to get even one working properly in harmony. I have tested the TFmini seperately using RPi4 and it seems to be working fine. However the upon connecting it with the ESP32 it seemingly ceases to work.
I have flashed my ESP32 to publish the data via mqqt and that works fine but as you can see on the serial monitor the output is just a continuous bunch of zeros with and without the tfimini actually connected,
so I suspect it is either caused by the wiring (I have read about people using different pins for data transmission none which however have worked for me) or something in my Arduino script.
I am not comfortable sharing the entire script as it is created as part of an unpublished paper that is not mine but here are some snippets that might relate to my issue. I think I can provide further snippets on request if required.
#include <ArduinoJson.h> //Json library
#include <PubSubClient.h>
#include <WiFi.h>
#define RXD2 16
#define TXD2 17
[...]
Serial.begin(115200);
Serial.println("\n" + esp_name + "& Benewake TFmini-S UART LiDAR Program");
Serial2.begin(115200);
[...]
// thresholds for triggering (ROI)
int roi_min = 60; // in cm
int roi_max = 150; // in cm
[...]
I use UART wiring to connect TFmini Power supply and ground to 5V and ground pins on ESP32 respectively aswell as RX and TX on 16,17 respectively. Furthermore I use 5V/3A Usb-mini power supply for the ESP32.
Apologies for the vagueness in some part I am unsure as to how much I can share.
Down below are the datasheet for the sensor in question aswell as the pin chart for the ESP32.