Many years ago, I modified RC car to control it with my phone via Wi-Fi just like many other makers.
The Raspberry Pi Zero W was an overkill for this project, so I replaced it with my favorite Wi-Fi development board, WeMos D1 Mini. The plan is to make the Phone (Station) automatically connect to the Camera (Access Point) to tell it to become a Station and connect to the Board (Access Point). The phone will then connect to the Board where it can control the RC car movement, Stream Video, and control the camera. The code at the bottom of this tutorial needs to be uploaded to the board.
The PhoneAn Android phone will be used to run an application developed in MIT App Inventor. We needed to import three extensions that come from different locations:
WebSocketConnector: to control the board
ClientSocketAI2Ext: to control the camera
TaifunWiFi: to switch between Wi-Fi networks
We want the app to have six movement buttons in addition to a button to stop movement (just in case), a button to quit the App, a button to toggle recording, and a button to take a picture.
We also added non-visible components, couple of images for backgroung and icon, and set a timer to keep the phone screen active. Note that the app has to be terminated using the Quit button to avoid draining the phone battery.
Using blocks, we declare some variables and kept the screen active.
Connected to camera.
Told the camera what it needs to do via http call then connected to board.
Opened Web Socket to control RC car, used a Client Socket to control the camera, and streamed video.
The RC car needs to stop if connection has been lost.
Defined non-movement buttons.
Defined movement buttons.
We are using SQ13 which cost only $20. Not very high quality, but for less than one tenth of the price of an action camera, it is amazing. Other similar cheap Wi-Fi cameras might be running the same firmware even if they don’t have the same shape. By default, this camera works in Access Point Mode which can be changed to Station Mode until it is powered off. This can be done by going to http://192.168.25.1 after connecting to camera’s Wi-Fi. This URL is also where we need to change the camera’s password. More details available at https://gist.github.com/gitfvb/09085fd0cd4993549feb7470430d40e9.That link has good information, but not everything we need. So we installed Sports DV app and PCAP Remote app from Google Play. This was only needed to understand how to communicate with the camera and it is not necessary to build the project. After intercepting the network traffic, we copied the pcap file to a PC that has Wireshark on it. We know that commands will be sent over tcp.port==8081.
We started video recording then stopped it and that caused two shift disruptions in the flow of the diagonal lines.
Red text is phone to camera commands and Blue text is the camera’s acknowledgment to the phone.
Clicking on the Red text revealed 4750534f434b4554 0100 0100 at the bottom left corner. The first group of numbers translate to ASCII GPSOCKET followed by 0100 then the command to toggle recording which is 0100. Similarly, we found the command to take a picture is 0200. This information has been used to construct the blocks in App Inventor.
Demo
Comments