With the onboard WiFi capability that the ESP8266 and ESP32 boards provide, the natural next question is, can they be reprogrammed this way, too?
As it turns out, they can — and it’s fairly straightforward, thanks to the ArduinoOTA library (OTA standing for Over-The-Air.) Once programmed with an initial sketch to get the OTA functionality up and running (as well as provide the SSID and password for your WiFi), ESP8266 (and ESP32) boards can accept new sketches via their WiFi connection. There is even provision in the stock Arduino IDE to do this.
Random Nerd Tutorials has an excellent tutorial (as I guess you’d expect) on how to get started with this. If you’re in a hurry, here are my impressions after playing with it for an evening or so:
(The tutorial says Python 2.7 is required. I had it already, so I can’t say for sure.)
Add the Arduino core for your ESP8266 board (NodeMCU etc.) if you haven’t already.
Open the “Files–>Examples–>Ardruino OTA–>Basic OTA” example sketch. (If you can’t find it, the code is available here.
Modify the SSID and password lines to match your local WiFi network setup.
Compile and upload your sketch, using a USB cord like a cave dweller this one last time.
Since you’re connected via USB, you have Serial Monitor available, so you can watch it connect to the network (unless you’re like me and entered the wrong network name at first.)
Once it’s up and running, you should see a “Network Ports” section under Ports in the Arduino IDE. If all went well, you should see your board here. Select it and you can now upload to it this way.
That’s it — except for a few details that might not come to mind right away:
Make sure your new sketch also has the same OTA functionality (and your SSID and password) baked in, or once it is successfully uploaded, your board will no longer be listening for OTA updates, until you sheepishly ask the museum to borrow your USB cable back.
I’ve had the best luck with putting the ArduinoOTA.handle() call at the end of loop(). I suspect it might tend to use up most (or all) of the processor’s time, otherwise.
Don’t be a hog with time in your loop — do what you need and pass control back to the OTA handler.
If you move your board to a new network with a different SSID and/or password, it will need to be updated before the move. Unless you write the sketch to handle multiple networks, this will disconnect it from the former network.
This kind of functionality suggests some interesting applications — like encasing a system completely in resin, to be programmed wirelessly and powered by light or magnetic couplings.
I discovered something new this week — or rather, my computer did.
Conway’s Life (which I’ve covered before) is a fascinating, simple yet Turing-complete set of rules to be run on a 2D binary lattice. Each generation, cells are born if they have exactly three live neighbors in the previous generation, and cells which were alive and had two or three neighbors stay alive. Otherwise, the cell dies (or no cell is created).
“Still Life” patterns are those Life patterns (like a 2×2 block of four) which are completely stable, and don’t change from one generation to the next. No new cells are generated, and the existing ones remain without any dying off. Absent any outside influence like a stray glider crashing into it, check back in a million generations and everything will still be where it is.
Still Life patterns are relatively common — start with any large random field and apply the Life rules and you’ll get lots of small ones — but larger ones don’t occur “naturally” (in Life sequences starting from random fields) nearly as often. The vast majority of patterns in Life aren’t stable, and large groups of randomly-initiated cells usually settle down into a mix of small Still Life patterns and small oscillators, along with gliders that shoot off in whichever diagonal direction they’re pointed in.
Life happens to be one of those interesting computational phenomena which is both easy to experiment with on a small scale and still interesting/challenging even for modern, fast computers. “Catagolue” [sic] is a project that has been underway since 2015 to try to catalogue all of the various patterns that exist in Conway’s Life. Programs like APGSearch can search through randomized primordial 16×16 “soup” patterns, evolving them according to the rules of Conway’s Life and running a quick analysis to see if anything interesting happens.
There are a huge number to go through, with 2^256 possibilities — but modern PCs are quick, going through tens of thousands of such patterns per second by running them in parallel. Every few minutes, the program uploads another “haul” of perhaps a few interesting finds, each time it checks ten million patterns. Contrast this with the way the “famous” Life patterns were found — by Conway and his graduate students, using tokens on a Go board! The glider — maybe the most famous Life pattern of all — was noticed when one student (Richard Guy) reported, “Hey, my bit is moving,” while helping Conway determine the evolution of the R-Pentomino “methuselah.”
Conway and his crew found most of the easy ones long ago. But we have cooler toys now. By simply running APGSearch in the background (for less than a day so far), I’ve already come across the Conway’s Life equivalent of a new, interesting beetle that we think nobody has come across before — the population-33 Still Life pattern shown above. (The same search also apparently provided the seventeenth confirmed sighting of a rare period-2 oscillator. Not nearly as exciting as a first find, but peer review is an important part of science, too, and it’s nice to see it applied so thoroughly here.)
It’s always fun to learn of new processes and capabilities — especially when processes which used to be prohibitively expensive themselves benefit from new technologies such as CNC and 3D printing.
Since our department bought an LPKF PC board mill in 2010, we’ve had the in-house capability to produce what I call “1.5-layer” boards. Our mill can do the insulation passes on the top and bottom — and I have it dialed in well enough that the solder pads are viable on both sides and aligned. However, the process doesn’t plate vias. Any connections between the two sides of the board must rely on a manually-soldered lead through a hole. With complex designs involving dozens of vias, this adds not only hours of benchtop time but dozens of potential failure points to the board.
The existing solution has been, wherever possible, to keep all traces on the bottom side of the board, and use resistors and similar components as natural bridges across other traces. This has worked well for relatively simple boards like the TIL311 replacement hex decoder — but even this is pushing the style close to the reasonable limit. For more complex boards, 2- or 4-layer processes are needed.
These days, provided you can wait a few days for the boards, there’s a better option. Modern PCB houses like PCBWay can accept your Gerber files over the ‘Net, apply a DRM check, and produce them with far more options than in-house production could provide. Even with shipping from China, you can have your boards in just a few days.
This capability has been available (for a steep price) for a number of years now — but recently, Just-In-Time manufacturing techniques and high levels of automation have meant that even small, custom orders can be turned around in a few days at surprisingly low cost.
Full disclosure: PCBWay kindly provided the boards ($41 value) for this Hex Decoder project free of charge in return for a writeup, but this review is my honest opinion — as is everything on this site.
With more students (and seemingly fewer remaining hex decoder boards) each year, I needed to make up some more hex decoders for next year’s Microprocessors class. PCBWay had recently contacted me, asking if I would be interested in reviewing their services, so I thought this would be the perfect opportunity. (Making boards with the LPKF is fun but time-consuming anyway, and there’s always the chance that something will go wrong and you’ll have to start the batch over. Maybe if I had an apprentice?)
So I packaged up the original FreePCB design into a semblance of normal-looking Gerber files, and uploaded it to PCBWay’s site. Somehow it passed the DFM checks, and within a few days (I may have submitted it on a Friday night right before Lunar New Year), a package with 20 boards was on its way to me.
PCB design cognoscenti (of which I am not one!) will note that the pads are significantly larger (90 mil) than normal (50ish mil?), and the traces are quite large, too. This was because the original board was designed to be produced in-house using our PC board mill. This process produces untinned, hard-to-solder-to pads — and thin traces sometimes don’t survive the cutting process. Because of this, the DFM rules I used (25-50 mil traces, 90-mil pads on 100-mil spacings) could probably be met by a competent blacksmith.
PCBWay still manages to make it look pretty good, but I’m looking forward to designing boards with modern tolerances. No doubt fine-tuning the milling process would help, but outsourcing to a modern PC board house makes for much more reliable boards. So far, I’ve tried PCBWay as well as JLCPCB, and had very good results with both. PCBWay’s site seems a little easier to use, and they have some nice design sharing/selling features, and great customer support.
Once I found my old plans and got the necessary parts together, soldering was very easy; the plated pads and solder mask mean the solder goes where it should and not where it shouldn’t. Through-hole soldering is a piece of cake, and even SMD components — which are very experimental on the LPKF process — should be straightforward.
Bottom line: Even though PCBWay kindly comped the boards for this project, I’m impressed. These are decent, professional-quality boards with good tolerances, plated vias, solder masks, silkscreening, and more. They’re far better than we could make in-house, for something like a few dollars each — maybe even less, in quantity — and they can arrive in a week or two. If they’d only add yellow or gold silkscreen, we could even have them in school colors.
PCBWay isn’t the only good PC board house out there, but they provide good boards quickly at a nice low price, and have an easy-to-use site. Check them out.
One of the projects I’ve been meaning to build for a while now is an accelerator / elevator for 12mm steel bearing balls running in a 3D printed track. This will mean experimenting with coil pulse timings and durations, and it would really help speed things up if this could be automated.
So, Step 1 was to build a speedometer. (After all, it’s difficult to improve something if you don’t measure it.) Microcontrollers, especially fast ones like the ESP32 family, are really good at measuring differences in timing. If you set photodiode gates across the track from a fixed LED and have the microcontroller scan the photodiode output, it can sense when the beam is blocked, to high precision (microseconds). If you place two of these a fixed distance apart (I’m using 50mm), you can calculate average velocity between them by V = D/T.
The .stl for the frame itself is available here on Thingiverse. It should be printable without supports (the ceiling of the ball channel is arched to allow for airflow and for printability.) A Gikfun photodiode set is used to sense when the ball blocks two light beams 50mm apart. The difference in timing, along with the fixed distance, allows speed to be calculated. This is displayed on the screen in m/sec, along with an arrow showing direction of motion.
Next step, build an accelerator and use this to automate dialing in the parameters. (With the addition of some ramps and such, it wouldn’t make a half-bad experiment for our department’s undergrad Metrology course, too.)