The OpenMV board inside a security camera shell on the left, an AprilTag on smartphone's screen on the right

Use AprilTags To Let Guests Open Your Front Gate

[Herb Peyerl] is part of a robotics team, and in his robotics endeavours, learned about AprilTags; small QR-code-like printable patterns that are easily recognizable by even primitive machine vision. Later on, when thinking about good ways to let his guests through his property’s front gate, the AprilTags turned out to be a wonderful solution. Now all he needs to do is send his guest a picture of the appropriate AprilTag, which they can present to the camera at his front gate using their smartphone.

He used an OpenMV board for this – thanks to its wide variety of available libraries, the AprilTag recognition is already baked in, and the entire script is merely a hundred lines of MicroPython. An old surveillance camera gave up its dome-shaped housing, and now the OpenMV board is doing guest access duty on a post in front of his property’s front gate. He’s shared the code with us, and says he’s personally running a slightly modified version for security reasons — not that a random burglar is likely to stumble upon this post anyway. Besides it looks like the gate would be easy for a burglar to jump over without any need for security bypass, and the convenience benefits of this hack are undeniable.

In the unlikely chance a burglar is reading this, however, don’t be sad. We do happen to have a bunch of hacks for you, too. There’s far less secure systems out there, from building RFID keyfobs to gated community access control systems, sometimes all you need is a 12 V battery. If you’re not into burglary, that’s okay too — we’ve covered other guest access hacks before, for instance, this ESP8266-powered one.

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.

Raspberry Pi Pico Makes For Expeditious Input Device

With its copious number of GPIO pins and native USB, the Raspberry Pi Pico is arguably the ideal microcontroller for developing your own platform agnostic USB Human Input Devices. But you don’t have to take our word for it. Check out how quickly the $4 USD board allowed [Alberto Nunez] to put together a pair of foot pedals for his computer.

Wiring doesn’t get much easier than this.

A peek inside the enclosure reveals…well, not a whole lot. All that’s hiding inside that heavy-duty plastic box is the Pi Pico and some screw down terminals that let [Alberto] easily wire up the female bulkhead connectors for the pedals themselves. Incidentally, while you could certainly make your own pedals, the ones used for this project appear to be the sort of commercially available units we’ve seen used in similar projects.

With the hardware sorted, [Alberto] just needed to write the software. While he could have taken the easy way out and hard coded everything, we appreciate that his CircuitPython script loads its configuration from a text file. This allows you to easily configure which GPIO pins are hooked up to buttons, and what key codes to associate them with. He didn’t really need to go through this much effort for his own purposes, but it makes the project far easier to adapt for others, so our hats off to him.

If you’re looking for a bit more inspiration, our very own [Kristina Panos] put together a Python-powered macro foot stool that you can put under your desk for rapid fire keyboard shortcuts. Plus you can stand on it to reach the top shelf, if need be.

Simple MicroPython Game Is A 30 Minute Game Dev Course

Sometimes, it’s really useful to watch a project’s parts come together one piece at a time in order to get a complete understanding and mental picture of the whole, and we found that to be the case with this simple, retro-inspired sample game from [ezContents]. (Video, embedded below.) The code is on GitHub but if you’re at all interested in what goes on behind the scenes in a game like that, don’t miss the video.

In the video, each game element and function is illustrated, showing exactly what gets done and why. This part is collision detection (click to enlarge.)

These sprite-based games are mostly about moving a small graphical object (a sprite) around a screen in response to user input, and managing what happens when collisions are detected between the player’s sprite and other sprites like enemies, projectiles, and so forth. The development process is wonderfully documented and demonstrated in a video, as each separate part of functionality gets built and explained one piece at a time.

The simple game is made using ArduPy (which is MicroPython combined with Arduino APIs) using Seeed Studios’ Wio Terminal, a small microcontroller development board with integrated screen, sensors, and button inputs including a little directional clicker that [ezContents] uses as a joystick.

The video of the whole process is embedded below; give it a watch and you’ll maybe come away with inspiration, but you’ll definitely have a much better understanding of how these types of games are developed, even if you’re not using the same hardware or development environment.

Continue reading “Simple MicroPython Game Is A 30 Minute Game Dev Course”

Simple GUI Menus In Micropython

Love ’em or hate ’em, sometimes your embedded project needs a menu system. Rather than reimplement things each and every time, [sgall17a] put together a simple GUI menu system in Micropython that can be reused in all sorts of projects. The approach uses tables to define the menus and actions, and the demo program comes with a pretty good assortment of examples. Getting up to speed using this module should be fairly easy.

The hardware that [sgall17a] chose to demonstrate the concept couldn’t have been much smaller — it’s a Raspberry Pi Pico development board, an OLED 128 x 64 pixel display, and a rotary encoder with built-in push-button switch (it’s also been tested on ESP32 and ESP8266 boards). The widget under control is one of the commonly available Neopixel development boards. The program is hosted on GitHub, but beware that it’s under development so there may be frequent updates.

This is a good approach to making menus, but is often rejected or not even considered because of the overhead cost of developing the infrastructure. Well, [sgall17a] has done the hard work already — if you have an embedded project requiring local user setup, check out this module.

Looks Like A Pi Zero, Is Actually An ESP32 Development Board

ATMegaZero ESP32- S2, showing optional color-coded 40-pin header (top)

The ATMegaZero ESP32-S2 is currently being funded with a campaign on GroupGets, and it’s a microcontroller board modeled after the Raspberry Pi Zero’s form factor. That means instead of the embedded Linux system most of us know and love, it’s an ESP32-based development board with the same shape and 40-pin GPIO header as the Pi Zero. As a bonus, it has some neat features like a connector for inexpensive SSD1306 and SH1106-based OLED displays.

Being able to use existing accessories can go a long way towards easing a project’s creation, and leveraging that is one of the reasons for sharing the Pi Zero form factor. Ease of use is also one of the goals, so the boards will ship with CircuitPython (derived from MicroPython), and can also be used with the Arduino IDE.

If a microcontroller board using the Pi Zero form factor looks a bit familiar, you might be remembering the original ATMegaZero which was based on the Atmel ATMega32U4, but to get wireless communications one needed to attach a separate ESP8266 module. This newer board keeps the ATMegaZero name and footprint, but now uses the Espressif ESP32-S2 to provide all the necessary functions.

CircuitPython has been a feature in a wide variety of projects and hacks we’ve seen here at Hackaday, and it’s a fine way to make a microcontroller board easy to use right out of the box.

Wireless MicroPython Programming With Thonny

I’ve been playing with a few MicroPython projects recently on several different embedded platforms, including a couple of ESP32 WiFi modules. There are various ways to program these modules:

  • Use a serial terminal and ampy (maintained by [devxpy] since being dropped by Adafruit in 2018).
  • If you use Pycom boards or WiFy firmware, there are the pymakr plugins for Atom and Visual Studio.
  • If you prefer the command-line like me, there is rshell by one of the top MicroPython contributors [Dave Hylands].

For over a year, I have been quite happy with rshell until I started working on these wireless nodes. Being lazy, I want to tinker with my ESP32 modules from the sofa, not drag my laptop into the kitchen or balcony to plug up a USB cable. Can’t I work with them wirelessly?

Well, you can use WebREPL. While its functional, it just didn’t strike my fancy for some reason. [Elliot] mentioned in a recent podcast that he’s using telnet to access his wireless nodes, but he’s using esp-link on an ESP8266, which means throwing another chip into the mix.

The Thonny IDE

I had all but given up when by chance I saw this video on the Dronebot Workshop channel about running MicroPython on the new Raspberry Pi Pico boards. Bill was using Thonny, a Python IDE that is popular in the education community. Thonny was introduced in 2015 by Aivar Annamaa of the University of Tartu in Estonia. Thonny was designed to address common issues observed during six years of teaching Python programming classes to beginners. If you read about the project and its development, you’ll see that he’s put a lot of effort into making Thonny, and it shows.

Leaning about Thonny got me curious, and after a little digging I discovered that it has WebREPL support for MicroPython right out-of-the-box. Although this is a new feature and classified as experimental, I found it reasonably stable to use and more than adequate for home lab use. Continue reading “Wireless MicroPython Programming With Thonny”