When developing a network-enabled project with the ESP8266 or ESP32, the easiest way to handle WiFi credentials is to just hardcode the access point and encryption key into the program. But that means recompiling the firmware if you ever want to use it on a different network, which isn’t really an option if you’re trying to make something that other people can easily use. If you’re expecting grandma to bust out the UART cable, we’ve got bad news for you.
There are various ways around this problem, but we think the one developed by [Pekka Lehtikoski] is particularly clever. With a simple application, network credentials can be literally “flashed” to the waiting microcontroller by rapidly blinking the flash LED on an Android device. This allows the information to be transferred quickly and easily regardless of the user’s technical proficiency. One could even make the argument that it’s more secure than some of the other methods of doing initial setup, since an eavesdropper would literally need to see you do it if they wanted to steal your encryption key.
[Pekka] has made the source code for the Android application and the “Gazerbeam” library open for anyone who wants to include the capability in their own projects. To pick up the blinking light you just need to add a phototransistor, an opamp, and a handful of passives to your circuit; making this solution cheap enough that you could even use it in a small-scale production run. The concept isn’t limited to network credentials either. Whenever we can hold conferences again, it could be an interesting way to let attendees customize their badge.
Of course, [Pekka] isn’t the first person to use this trick. Hackers well versed in the history of WiFi MCUs may recall that the Electric Imp used a very similar method of configuration called BlinkUp. If you ever come across a device that asks you to put your phone’s screen down on a little window to perform the initial setup, there’s a good chance it has an Imp inside.
33 thoughts on “Get Your Microcontroller Online At The Speed Of Light”
Reminds me of Timex Datalink
I had one of those, it (usually) needed a CRT to work.
But, the rubber O-ring on the back failed and my sweat found its way in.
” If you’re expecting grandma to bust out the UART cable, we’ve got bad news for you.”
If you expecting grandma to install an app on a phone I got bad news for you.
ESP32 has default applications that turns it into a AP which any device can connect to and get served a web page to see all nearby Wi-Fi AP’S and choose which one to connect to and enter in the password. Click save and it saves it to flash.
Flashing the credentials in your app is just silly (unless your developing of course).
You’ve got to be joking. The user can’t understand how to install an app on their phone, but they’ll be able to navigate a captive portal with absolutely no guidance?
Nearly every consumer device today has its own app that needs to be installed before you can use it these days, for better or for worse.
This is how its mostly done in the real world the device serves as an AP and you scan or key in its serial number as a login and get a page asking you What network and credentials
You should realize every one on this very website that’s 40 or older is already firmly in the ‘grandparent’ window…
I know it hurts to think about that, but we’re in an age where grandma is as likely to do 8 layer PCB design as anything else, and great grandma was was editing config.sys like a boss, and great great grandma sitting on a manufacturing production line could very well have more insight into the workings of a passive component than any teen today.
Welcome to old age, where we are the meme
Indeed, I know grandparents who had an 8 bit as kids, built their own PCs in the DOS/Windows era and can flash your android box if you brick it. Bit of a lie that millennials were the first digital natives, when it’s a rare western gen Xer that didn’t have their hands on something digital before the age of 10.
I think even LESS so that millennials and onward treat technology as anything but a “magic box”. I grew up with a Dad who programmed on punchcards as a hobby back in the day where you would roll up your sleeves and fix a problem for real. These days my peers can do little more than login to Netflix with ease. I’m glad for what I’d got from my dad and am happy I can now teach my kids (his grandkids) how to solder electronic kits thanks to the ethic he instilled in me.
>every one on this very website that’s 40 or older is already firmly in the ‘grandparent’ window…
Not so fast. The age of first marriage for millenials has increased to 29 years, and people are having children between 29-34 years instead of the early 20’s of the previous generations. The average millenial will not see grandchildren until they’re 60.
This boomer doesn’t want to see a grandchild for a few more years!
(She’s still in high school!)
Yup, complete with creaky joints and “back in my day we used ___ and liked it”.
Honestly aside from the back, getting older is kinda nice. Passing on those things we used to do is fun.
Yep. From Z80 / 6502 asm to FPGA / VHDL and everything in between.
Ironically, on day I gave my daughter a flash memory stick with an image.iso file on it and asked her to burn it to a CD.
She gave me a CD with the image.iso file in the root directory.
Why do you need an op-amp? I’ve never needed one in an Electric Imp design to see the significantly less bright screen flashing
The Imp is using a DAC to run the opto bias.
This MCU probably doesn’t have DAC.
You could still probably use slope conversion to a digital pin or some CPU based signal processing.
In any case it’s good to see someone showing a well designed analogue signal conditioner.
While thuis is a cool application of a very neat trick, what bandwidth are we talking here max,? Something useful to have in a bootloader to do firmware update with, or would that be days.
Firmware update would require faster transmitter than Android phone’s flash light. As is, the bandwidth is very low, approximately 10 characters per second or 80 bits/second: Shortest pulse My Motorola Android phone flash light can reliably generate from Java code is 10 ms, and it can only be on or off. Receiving end (ESP32) can handle practically 200k interrupts per second, thus it maxes at 200kbits/s.
The electricImp’s BlinkUp system is similar to this
Yeah, that’s probably why the post specifically says that.
If you’re doing this with something as bright as a camera flash, it might be possible to skip the op amp and the passives, and just directly use an ADC with an LED (running in reverse as a weak photocell).
It would require some clever programming, as much as for amplification OP amp is used to adjust signal level and filter ambient light effects out. I think it would be possible to do the same or something better in software. The op-amp approach just makes software simple: One digital input which generates interrupt on both rising and dropping edges, measure time between two consequent interrupts without caring about edge direction.
Is this not the entire purpose of Wifi Protected Setup? Just click a button on the router and then it works?
Good point. WPS is way to go, if you can assume that: WiFi access point at your client’s site supports it (most new ones do). Physical access to the AP/router is allowed or auto WPS is enabled (true for most home networks, not usually possible in corporate setting) and WPS is not blocked by IT security (again typically open at home, often blocked in corporate environment because WPS PIN vulnerability).
I fail to see the practicality of this beating any alternative other than showing off a different “thing”
If the aim was to be a little more inconspicuous with the communication and not broadcasting it out for everyone, i still think there are much better options. all of which still require an mobile application of some kind.
– QR or BAR Code for finding & connecting to a hidden BLE (or WiFi if 8266)
– NFC tag (i2c interface) with bidirectional communication.
I think it would be much more useful if it would work with the screen instead of the flash. Pretty sure this would work exactly the same way, however you’d need to be much closer. Then you could play back the config sequence as a video or GIF so it eliminates the need for a separate app.
Yep. “Wayne and Layne” did this with their “Blinky Grid Kit” about a decade ago.
Came here to say that.
The screen method allows to have a clock signal too.
The Blinkenrocket uses the 3.5mm jack plug for data transmission:
Hah! Came here to say _that_. Check their github (or the Hackaday writeup) for details.
Gratuitous linkage: https://hackaday.com/2018/02/02/you-can-learn-a-lot-from-a-blinkenrocket/
I know Flo personally, he is also our retailer for the FLipMouse construction kit ( https://hackaday.io/project/13238-flipmouse )
What’s old is new again. So it’s like IrDA but with visible light LEDs. LOL
What about OTA programming?
Please be kind and respectful to help make the comments section excellent. (Comment Policy)