Network Time Protocol On The ESP32

Network Time Protocol (NTP) is one of the best ways to keep networked computers synchronized to the same time. It’s simple, lightweight, and not only allows computers to maintain a time standard together, but it also allows some computer manufacturers to save some money on hardware costs. The Raspberry Pi is perhaps the most well-known example of a low-cost computer without the extra expense of a real-time clock (RTC). While the Pi sets up NTP essentially automatically, other microcontrollers like the ESP32 don’t, but it is possible to configure them to use this time standard with some work.

For this project the MicroPython implementation for the ESP32 is required. MicroPython is a way of running Python code on microcontrollers or other embedded systems without all of the overhead that Python would normally require. Luckily enough, the NTP libraries are built right in so once MicroPython is running on the ESP32 it’s nearly as easy as calling the library. Of course you will have to make sure there is an internet connection, and then grab the time, sync it to the machine, and then set the timezone.

For a bonus exercise, the project’s creator [Bhavesh] suggests attempting to configure Daylight Savings Time, although this can be a surprisingly difficult problem to solve. In the meantime, there are a few other ways of installing a clock on a microcontroller like this one. An RTC module is an obvious choice, but you can also get incredibly accurate time by using a GPS module as well.

Easy Network Config For IoT Devices With RGBeacon

When you’re hooking up hardware to a network, it can sometimes be a pain to figure out what IP address the device has ended up with. [Bas Pijls] often saw this problem occurring in the classroom, and set about creating a simple method for small devices to communicate their IP address and other data with a minimum of fuss.

[Bas] specifically wanted a way to do this without adding a display to the hardware, as this would add a lot of complexity and expense to simple IoT devices. Instead, RGBeacon was created, wherin a microcontroller flashes out network information with the aid of a single RGB WS2812B LED.

In fact, all three colors of the RGB LED are used to send information to a computer via a webcam. The red channel flashes out a clock signal, the green channel represents the beginning of a byte, and the blue channel flashes to indicate bits that are high. With a little signal processing, a computer running a Javascript app in a web browser can receive information from a microcontroller flashing its LEDs via a webcam.

It’s a neat hack that should make setting up devices in [Bas]’s classes much easier. It needn’t be limited to network info, either; the code could be repurposed to let a microcontroller flash out other messages, too. It’s not dissimilar from the old Timex Datalink watches which used monitor flashes to communicate!

The microcontroller described in the article, on the PCB taken out of the kettle

Dumping Encrypted-At-Rest Firmware Of Xiaomi Smart Kettle

[aleaksah] got himself a Mi Smart Kettle Pro, a kettle with Bluetooth connectivity, and a smartphone app to go with it. Despite all the smarts, it couldn’t be turned on remotely. Energized with his vision of an ideal smart home where he can turn the kettle on in the morning right as he wakes up, he set out to right this injustice. (Russian, translated) First, he tore the kettle down, intending to dump the firmware, modify it, and flash it back. Sounds simple enough — where’s the catch?

This kettle is built around the QN9022 controller, from the fairly open QN902X family of chips. QN9022 requires an external SPI flash chip for code, as opposed to its siblings QN9020 and QN9021 which have internal flash akin to ESP8285. You’d think dumping the firmware would just be a matter of reading that flash, but the firmware is encrypted at rest, with a key unique to each MCU and stored internally. As microcontroller reads the flash chip contents, they’re decrypted transparently before being executed. So, some other way had to be found, involving the MCU itself as the only entity with access to the decryption key.

Continue reading “Dumping Encrypted-At-Rest Firmware Of Xiaomi Smart Kettle”

Tiny RISC Virtual Machine Is Built For Speed

Most of us are familiar with virtual machines (VMs) as a way to test out various operating systems, reliably deploy servers and other software, or protect against potentially malicious software. But virtual machines aren’t limited to running full server or desktop operating systems. This tiny VM is capable of deploying software on less powerful systems like the Raspberry Pi or AVR microcontrollers, and it is exceptionally fast as well.

The virtual machine is built from scratch, including the RISC processor with only 61 opcodes, a 64 bit core, and runs code written in his own programming language called “Brackets” or in assembly. It’s designed to be modular, so only those things needed for a given application are loaded into the VM. With these design criteria it turns out to be up to seven times as fast as comparably small VMs like NanoVM. The project’s creator, [koder77], has even used its direct mouse readout and joystick functionality to control a Raspberry Pi 3D camera robot.

For anyone looking to add an efficient VM to a small computing environment, [koder77] has made the project open-source on his GitHub page. This also includes all of the modules he has created so far which greatly expand the project’s capabilities. For some further reading on exceedingly tiny virtual machines, we featured this project way back in 2012 which allows users to run Java on similar hardware.

Flashing TI Chips With An ESP

Texas Instruments is best known to the general public for building obsolete calculators and selling them at extraordinary prices to students, but they also build some interesting (and reasonably-priced) microcontrollers as well. While not as ubiquitous as Atmel and the Arduino platform, they can still be found in plenty of consumer electronics and reprogrammed, and [Aaron] aka [atc1441] demonstrates how to modify them with an ESP32 as an intermediary.

Specifically, the TI chips in this build revolve around the 8051-core¬† microcontrollers, which [Aaron] has found in small e-paper price tags and other RF hardware. He’s using an ESP32 to reprogram the TI chips, and leveraging a web server on the ESP in order to be able to re-flash them over WiFi. Some of the e-paper displays have built-in header pins which makes connecting them to the ESP fairly easy, and once that’s out of the way [Aaron] also provides an entire software library for interacting with these microcontrollers through the browser interface.

Right now the project supports the CC2430, CC2510 and CC1110 variants, but [Aaron] plans to add support for more in the future. It’s a fairly comprehensive build, and much better than buying the proprietary TI programmer, so if you have some of these e-paper displays laying around the barrier to entry has been dramatically lowered. If you don’t have this specific type of display laying around, we’ve seen similar teardowns and repurposing of other e-paper devices in the past as well.

Continue reading “Flashing TI Chips With An ESP”

Careful Cuts Lets Logger Last A Year On A Coin Cell

Coin cells are great for backup power for things like real-time clocks, or even for powering incredibly small mechanical devices like watches. But for something like a data logger, running on a standard microcontroller, most people would reach for a lithium cell of some sort. Not so with this build, though, which squeezes every joule of energy from a coin cell in order to run a data logger for a full year.

Won’t be needing that anymore.

Most of the design and engineering required to improve the efficiency of the data logger involve standard practices for low-power devices such as shutting off unnecessary components and putting the device to sleep when not actively running, but this build goes far beyond that. The Vcc pin on the RTC was clipped which disables some of its internal logic but still keeps its basic functionality intact.

All of the voltage regulators were removed or disabled in favor of custom circuitry that doesn’t waste as much energy. The status and power LEDs were removed where possible, and the entire data logger is equipped with custom energy-efficient code as well.

If you’re starting a low-power project, even one that isn’t a datalogger, it’s worth checking out this build to see just how far you can go if you’re willing to hack at a PCB with cutting tools and a soldering iron. As to why this data logger needed such a low power requirement, it turns out it’s part of a kit being used in classrooms and using a coin cell brought the price of the entire unit down tremendously. Even if you have lithium cells on hand, though, it’s still worthwhile to check out the low power modes of your microcontroller.

Thanks to [Adrian] for the tip!

ESP32 Virtual Machine Lets You Change Programs On The Fly

Often, reprogramming a microcontroller involves placing it in reset, flashing the code, and letting it fire back up. It usually involves shutting the chip down entirely. However, [bor0] has built a virtual machine that runs on the ESP32, allowing for dynamic program updates to happen.

The code is inspired by the CHIP-8, a relatively ancient interpreter that had some gaming applications. [bor0] had already created a VM simulating the CHIP-8, and repurposed it here, taking out the gaming-related drawing instructions and replacing them with those that control IO pins. Registers have also been changed to 16 bits for added flexibility and headroom.

It’s probably not something with immediate ground-breaking applications for most people, but it’s a different way of working with and programming the ESP32, and that’s pretty neat.

The ESP32 is a powerful chip, too, as we all know – and it makes a great 8-bit emulator to boot. Sound off in the comments with your thoughts on what would make a killer application for the ESP32 VM!

[Thanks to satancete for the tip!]