Program Flow
Basic Workflow

Functions in the code
void connect() Connects to the Wifi and MQTT broker
void messageReceived() Callback function if MQTT message is recieved
void doCommunication() Function running on second core of esp32 to manage WiFi and communicate with MQTT broker
void
pid()
PID algorithm function, takes input,input and output variables. This funcrion updates the output variable after calculating the PID.
int getRange() Get distance from ultrasonic sensor, takes sensor pin number as input
void checkObstruction() Thread function which runs continuously and cheaks for any obstruction in the path and update the variable.
void connect() Connects to the Wifi and MQTT broker
void
preTransmission()
void
postTransmission()
Set MAX485 to recieve or transmitt mode