3D printing
Building a 3D Printed Pit Droid, Part 6: The Brain Wakes Up
The Waveshare board arrived, and the droid now has its own WiFi network, a login and safe updates. A progress report with what I tested and what I did not.
- 3D printing
- 15 min read
Hi, it’s Achim again. In Part 5 I fitted the neck and tested the five servos. I ended that part with a promise: when the Waveshare board arrives, the next part covers the first test with it. It arrived on 21 November, so here we are.
No servo moves in this part. This one is about the brain: the board, and the software that lets me set the droid up, log in and update it from my phone. It is a long one, because a lot happened in two days, including a few things that went wrong.
This is a progress report, not a finished build. Some things I tested properly, some I only built, and some I have not touched yet. I will tell you which is which.
By the end you know what the board can do, how the droid sets itself up from a phone, how an update is checked before it is installed, what went wrong along the way, and what comes next.
What Are We Doing?
| Goal | Give the droid a brain that I can set up, log in to and update from a phone, with no cables |
| Status | Board tested, setup and login working, safe updates working. Servos, camera and sound in the droid software not done yet |
| Difficulty | Intermediate to advanced if you write the firmware yourself, easy if you only use it |
| Parts | The Waveshare ESP32-S3-CAM board, a USB-C cable, a phone |
| Tools | ESP-IDF v6.1 in Docker, a Mac to flash from |
Why I Changed the Plan
My first plan used two boards: an ESP32-S3 DevKit as the brain and an ESP32-CAM as the eyes, plus a separate amplifier and microphone. On 8 November I dropped that. The Waveshare ESP32-S3-CAM board does all of it on one board: a camera, two microphones, a speaker amplifier and a speaker connector. One board means fewer wires in a small head.
What is on it, as far as I have checked: an ESP32-S3 with 16 MB of flash and 8 MB of extra memory, an OV5640 camera, a chip for two microphones, an audio chip with a small amplifier, a TF card slot, a USB-C port, and two small headers for I2C and UART.
The First Test of the Board
I wrote three small test programs and ran them on the board. This is what I measured, not what the datasheet promises:
- Camera: the OV5640 works. One JPEG picture of 640 by 480 took about 145 ms.
- I2C: a scan found four devices: the audio chip, an extra chip that controls some pins, the camera, and a fourth address that I think is the microphone chip (I have not confirmed that).
- Speaker: I heard beeps, and then eleven short sound clips played from a flash partition.
- Microphone: the level moves when I make a sound.
Two things surprised me. The switch that turns the speaker amplifier on is not on a normal pin. It sits on the extra chip, and you have to talk to that chip before you hear anything. And Waveshare’s own software package for this board did not build with the newest ESP-IDF (v6.1), so I wrote my own small start-up code for the audio.
The droid sounds themselves are third party material, so they are not part of anything I share.
What I did not test yet: the SD card, the servo driver, the servos, the UART header, and sound inside the real droid software.
One Droid, One WiFi Network
I want to set the droid up without a laptop and without a cable. So the droid makes its own WiFi network, named PitDroid- and four characters. When you join it with a phone, a page opens by itself, just like the login page of a hotel WiFi. That is called a captive portal.
The page is a small Star Wars style terminal. It is about 5 KB when compressed, and it comes straight from the board: no internet needed.

The login screen of the first version. The text at the bottom has changed since then.
What the terminal does today:
- It scans for WiFi networks and saves up to five of them, so the droid can join your home WiFi and the WiFi of a show.
- The droid’s own network stays on, also while it is connected to another network. That was a decision I made on purpose: if I bring the droid to an exhibition, I must always be able to log in, add the WiFi of that place and update it.
- It shows what the chip knows about itself: memory, chip temperature, uptime and why it last restarted.
- It can join company or school networks that need a username and password (WPA2-Enterprise). I built that, but I never tested it against a real network.
Limits you should know: the board only does 2.4 GHz WiFi, and it cannot join networks that want you to click through a login page in a browser, like many hotels.
I tested this with an iPhone and a Mac. I did not test Android.
What Went Wrong With the Portal
It worked on the first try, and then it did not, and I did not know why. Later I saw that I had changed several things at once and that iOS remembers a network that is gone. The lesson is old but true: change one thing at a time, and keep a log open while you test, because opening the serial port restarts the board.
Another one: I used the browser’s own confirm() pop-up to ask “are you sure?” when removing a network. In the small window that a phone opens for these portals, that pop-up does nothing at all. The button turned red and nothing happened. I now build the question into the page itself: the first tap says “Sure?”, the second tap removes the network.
Logging In, and Keeping Strangers Out
A droid with its own WiFi network and a page that can change settings needs a login. This is what I built:
- An access code for the terminal. The board does not store the code itself, only a scrambled version of it (a salted PBKDF2 hash). Checking a code takes about 1.5 seconds on purpose.
- After five wrong tries you have to wait, 5 seconds at first and up to 5 minutes.
- Your login expires after 30 minutes of doing nothing.
- The droid’s WiFi network is always WPA2, with a password.
Two Phrases Everyone Can Read
Here I made a decision that I want to explain honestly. I want other builders to be able to download the software, flash it and use it, without a setup wizard. So a fresh droid starts with two fixed phrases:
- WiFi password:
Hello there! - Access code:
may the force be with you
They are public. Anyone can read them in the instructions. That is a risk, and I know it: until you change them, anyone within WiFi range who has read the instructions can join your droid network and log in. So the terminal shows a red warning at the top for as long as a default is in use, and the instructions tell you to change both right away. I chose not to force the change, because I would rather give people the choice. If you ignore the warning, that is on you, and I say so in the instructions.
I changed my mind on one thing here, and it is a good example of why you should check how the thing will be built before you decide. First the droid’s network was open for the first 10 minutes after switching on, so you could set it up. That is not safe. Then I changed it so that you had to press the BOOT button to start the setup. That is safer, but once the controller is built into the droid, I cannot reach the BOOT button any more. So I put it back, and I replaced the setup wizard with the two phrases above. To get back to the phrases after forgetting your own password, you can hold BOOT for 5 seconds. I have not verified that in a log, and it needs the button, so for a built-in board you would have to solder two wires to an external button, or erase the settings over USB.
Updating the Droid Over the Air, Safely
I want to update the droid without taking its head off. The risk is obvious: if someone could send my droid any firmware, or if an update breaks it, I have a brick on my desk. So the update works like this:
- The board has two program slots. An update is written to the slot that is not running.
- The new file is checked against a digital signature made with a private key that only I have. If the signature does not match, the update is refused.
- Only then does the droid switch slots and restart.
- After the restart, it checks itself for 20 seconds. If it cannot answer its own web request, it goes back to the old version by itself.
I tested all of this with a small test server on my own network.

The update screen: version 0.1.0 installed, 0.2.0 available.
The bad signature. I changed one byte in the signature on purpose. The droid downloaded everything, did its check and refused:

“Signature invalid, update refused.” It did not switch slots and kept running.
The good one. With a correct signature, the droid installed the update, restarted from the other slot and approved itself 21 seconds later. I could see it in the log:

The rollback. This is the test I care about most. I built a version 0.3.0 that is broken on purpose: it cannot answer its own web request. It has a correct signature, so the droid accepts it:


The droid installed it and restarted. Its self-test failed 27 seconds after the start. Then it restarted again by itself, from the old slot. The terminal shows version 0.2.0 again:

The key that signs the updates stays on my own computer. It is never uploaded to GitHub. GitHub builds the update as a draft, and a script on my computer checks it, signs it and publishes it. That way, even if my GitHub account were taken over, an attacker could make a draft, but not an update that a droid will install. I built this and tested the signing part on my own computer, but I have not run the whole chain against GitHub yet.
It Took Three Tries
The first update tests failed several times in a row, for different reasons:
- The repository was private, and GitHub answers “not found” to a device without a key. The log showed the 404 from GitHub, so that one is certain.
- The window on my Mac probably still had the old page open, which did not save the source I typed. I could not confirm this one, it is my best guess.
- The page contained two fields with the same name, so my code kept reading the hidden one and sent the wrong address to the droid. I only found this because I added one log line that showed what the droid really received.

On top of that: my test server ran on the same Mac I used to reach the droid. The Mac has one WiFi card, so when it joined the droid’s network, it left my home network, and the droid could no longer reach the server. The phone worked fine. Don’t run your test server on the machine that has to leave your network.
A Review of My Own Code
Before I hand the software to anyone, I reviewed all of it. This review was done by me, so it is not an independent review. It found 27 points, four of them serious. A few examples:
- A WiFi password with an accent could make the droid’s network silently stay open, because the error from the WiFi chip was ignored.
- A form that arrives in two pieces was treated as complete, so a password could be stored shorter than I typed it.
- The self-test for the rollback had never actually run.
- I found a bug in my own checking script: it did not search anything, and I thought it found nothing. A check that finds nothing only means something if you know it can find something.
I fixed the first group. The rest is written down and I am working through it.
One thing I cannot fix: everything the droid saves is readable by someone who holds the board. That includes WiFi passwords. There is no flash encryption, and turning that on cannot be undone, so I will not do that for a hobby project. Use a dedicated account for company networks, or a phone hotspot.
Letting Other Builders Use It
I want other builders to be able to use this, so I am preparing it:
- The code is under the MIT license.
- A browser page will let you put the firmware on the board with one click, in Chrome or Edge, without installing anything. This page is built and loads on my own computer. It is not online yet and I have not tested it with the board.
- Updates will come from my own account, signed with my key.
- If you want to run your own version with your own updates, you can: it is allowed, and I wrote down the steps. I assume you know what you are doing, and I will not be able to help you one on one.
While building the page, I found out that you cannot download the firmware straight from a GitHub release in a web page: those files do not allow it. The file has to sit on the same site as the page. I checked this on a real release before I wrote the instructions.
A Note on Power
Not done yet, so only the plan: the board runs from USB-C, and the servos get their own 5 V supply. I am thinking of powering the board from the same 5 V 10 A supply, through a flat USB-C cable that I ordered. I will look at this properly later. The supply can deliver far more than a thin cable can take, so I will put a small fuse in the plus wire, measure the voltage and the polarity before I connect anything, and give the board its own pair of wires instead of sharing the servo wiring. Servos pull hard when they start, and that can make the board restart. The terminal shows BROWNOUT when it happens. I also ordered a cable with a 1 mm plug for the I2C header, to connect the servo driver, because the first one does not look like it is going to arrive. None of this is connected or tested.
Not Tested Yet
I want to be clear about this:
- A real WPA2-Enterprise network (like a school network).
- Updates downloaded from GitHub over HTTPS, and the build and signing chain on GitHub itself. The repository is still private, so I only tested with my own test server.
- The browser installer page on a live website, and with a real board.
- Android.
- The servos, the servo driver, the SD card, the speaker and the camera inside the droid software.
- Powering the board from the supply, and the new cables.
- Anything that needs the droid to be built: the board is still on my desk.
Mistakes I Want You to Avoid
- Changing several things at once, and not keeping a log while you test.
- Using a browser pop-up (
confirm()) in a captive portal. It does nothing there. - Believing a check that finds nothing. Test it on a case you know is wrong.
- Running your test server on the same computer you use to reach the device.
- Deciding on a safety measure that needs a button, before you know whether you can reach the button in the finished build.
- Using one name for two fields on the same page.
- Flashing a board by cable after an over-the-air update, without erasing the update data first. The board starts the other slot and ignores your new file.
Words Explained
- Captive portal: the page that opens by itself when you join a WiFi network, like the login page in a hotel.
- Access point: a device that makes a WiFi network.
- OTA (over the air): updating firmware through WiFi, without a cable.
- Digital signature: a code that proves a file comes from the owner of a private key and has not been changed.
- Hash: a scrambled version of a password that cannot be turned back into the password.
- Rollback: going back to the previous version when a new one fails.
- Partition: a separate area of the flash memory, like a drive on a computer.
Conclusion: The Droid Has a Brain, and It Does Not Think Yet
The board works, the droid makes its own network, you can log in, and I can update it safely, including the case where an update is broken. That is the foundation. What it cannot do yet is anything that makes it a droid: it does not move, it does not see, it does not listen and it does not speak.
That is what comes next, and it is the part I am most curious about. I want the droid to react to what is around it, with the camera, the two microphones and the speaker, and possibly with the help of AI. Before I write any of that firmware, I want to find out what is realistic: what the board can do by itself, what would need a connection to the internet, how much delay is acceptable, what it costs, and how much noise the servos make for the microphones. That research is the next step, and I will report what I find, including the things that turn out to be impossible.
Next up: researching what the droid can actually do with its camera, microphones and speaker, and the first servo on the servo driver.
Previous: Part 5: The Neck, the Head and the Servo Test
Unofficial fan project
Pit Droid and Star Wars are trademarks of Disney/Lucasfilm. This site is not affiliated with, endorsed by or sponsored by Disney. The droid in this series is based on the PD-23 files by DroidDivision (Dave Moog), which are used under a single-person licence.
More projects
Keep building.
Electronics, 3D printing and CNC builds, documented from the first idea to the last screw.
All projects

