UPDATE 15. Dez 2020:
if you want to control multiple ESP32 robots/gadgets, use this guide instead: https://www.robot-maker.com/forum/topic/13329-vigibot-pi-to-multiple-esp32-wlan-communications-example/
if you want to control a single ESP32 robot/gadget, continue.
This code allows control of ESP32 robots or gadgets over WLAN using vigibot.
A raspberry is still required for the camera and needs to be on the same network. the serial data usually sent and received to an Arduino over UART ( https://www.robot-ma...cation-example/ ), is being sent over WLAN instead, allowing control of small robots or gadgets.
usage example: a pi with a camera watches an arena where multiple small ESP32 robots can be driven, the ESP32 bots do not have an on-board camera.
second usage example: open or close a door or toy controlled fron an ESP32.
1) insert your network info and upload the following sketch to your ESP32 from the arduino IDE using an usb cable.
2) open the serial monitor to confirm a successful WLAN connection.
3) the pi needs to create a virtual serial point that's being forwarded over WLAN to the ESP32. install socat on your raspberry:
sudo apt install socat4) create a new script:
sudo nano /usr/local/socat-esp.sh5) paste the following code and replace your ESP's IP:
#!/bin/bash sudo socat pty,link=/dev/ttyVigi0,rawer,shut-none pty,link=/dev/ttyEsp0,rawer,shut-none & sleep 1 while true do sudo socat -T15 open:/dev/ttyEsp0,raw,nonblock tcp:192.168.1.62:7070 done6) add permissions
sudo chmod +x /usr/local/socat-esp.sh7) run the script
sudo /usr/local/socat-esp.sh8) test the pi <-> ESP connection by logging in as root in a new shell (needs root) :
su -and sending a test text frame:
echo '$T hello from cli $n' > /dev/ttyVigi0the arduino serial monitor now says "hello from cli "
9)if it works add it to start at boot:
sudo nano /etc/rc.localand add
/usr/local/socat-esp.sh &above the line "exit 0".
10) add an entry on the vigibot online remote control config -> SERIALPORTS -> 3 with value: "/dev/ttyVigi0"
11) set WRITEUSERDEVICE to "3"
12) set READUSERDEVICE to "3"
restart the client and wake your robot up, if it wakes up then everything works.