Friday Hack Chat: CircuitPython With Adafruit Engineers

What the heck is CircuitPython? Get that question answered along with many more during this Friday’s Hack Chat. Three engineers from Adafruit join us as [Ladyada], [Tony DiCola], and [Scott Shawcoft] lead a CircuitPython discussion at Noon PST on 1/27/17.

CircuitPython is Adafruit’s new extension on the MicroPython codebase. It adds support for SAMD21 processors in MicroPython and reworks the API for better support across platforms and better documentation. Does this still sound like jibberish? The Python programming language has been extended to microcontrollers. CircuitPython is furthering that work and this Hack Chat is the perfect opportunity to talk with the people who are doing that work. They will also be doing a giveaway of five CircuitPlayground m0 Express boards (brand new, not yet released hardware).

Don’t miss this Hack Chat! Here’s a handy web tool to help convert Friday, January 27 at noon PST to your local time.

Here’s How to Take Part:

join-project-team-message-buttons
Buttons to join the project and enter Hack Chat

Hack Chats are live community events that take place in the Hackaday.io Hack Chat group messaging. Visit that page (make sure you are logged in) and look for the “Join this Project Button” in the upper right. Once you are part of the project, that button will change to “Team Messaging” which takes you to the Hack Chat.

You don’t have to wait for Friday, join Hack Chat whenever you like and see what the community is currently talking about.

A new display wedged into a car-based fridge

New Brains Save 12 V Fridge From The Scrap Heap

Recently [nibbler]’s Evakool 55L vehicle fridge started to act strangely, reporting crazy temperature errors and had no chance of regulating. The determination was that the NTC thermistor was toast, and rather than trying to extricate and replace this part, it was a lot easier to add a new one at a suitable location

Bog-standard fridge internals

A straight swap would have been boring, so this was a perfect excuse for an overboard hack. Reverse engineering the controller wouldn’t be easy, as the data wasn’t available, as is often the case for many products of this nature.

While doing a brain transplant, the hacker way, we can go overboard and add the basics of an IoT control and monitoring system. To that end, [nibbler] learned as much as possible about the off-the-shelf ZH25G compressor and the associated compressor control board. The aim was to junk the original user interface/control board and replace that with a Raspberry Pi Pico W running CircuitPython.

For the display, they used one of the ubiquitous SH1106 monochrome OLED units that can be had for less than the cost of a McDonald’s cheeseburger at the usual purveyors of cheap Chinese electronics.  A brief distraction was trying to use a DS18B20 waterproof thermometer probe, which they discovered didn’t function, so they reverted to tried and trusted tech — a simple NTC thermistor.

Continue reading “New Brains Save 12 V Fridge From The Scrap Heap”

Thumbs Up To This Pico MIDI Kalimba

The kalimba, or thumb piano, is an easy way to make some music even if you have next to no idea what you’re doing. The only real downside is that they are limited to the twinkly sounds of metal tines being plucked by thumbs.

[Jeremy Cook] broke the sonic possibilities wide open by converting a couple of kalimbas into capacitive-touch MIDI instruments using the Raspberry Pi Pico. He started with a small one that is curiously made of solid wood. Usually these instruments are at least partially hollow to allow air to resonate inside the body.

After soldering up all the 1 MΩ resistors necessary to utilize the capacitive touch capabilities of the Pico, [Jeremy] found it a bit difficult to play individual notes on such a small instrument, so he made version two out of a much larger specimen.

This time, [Jeremy] cooked up a custom PCB which he is calling the Pico Touch 2, which adds the necessary resistors at the SMD level for capacitive touch sensing and in turn cleans up the wiring a bit. Be sure to check it out in action after the break.

Okay, so you don’t have an iota of musical talent. You could always build a kalimba that plays itself.

Continue reading “Thumbs Up To This Pico MIDI Kalimba”

Human-Interfacing Devices: Packing For The Descriptor Heist

We started with figuring out HID descriptors a week ago, and I’ve shown you how to send raw HID packets using a MicroPython fork. We do still have the task in front of us – making a touchscreen device. For that, let’s give you the tools to capture an existing descriptor from a touchscreen, then show you how to tweak it and how it turns out in the end.

Packing For The Heist

When it comes to this kind of adventure, we can’t go without tools and weapons – it could be dangerous! Without them, you could even abandon your project halfway! Here’s enough high-precision tools and ammunition to last you through whatever obstacles you might encounter. Except for the web-based tools, these tools are for Linux, but please remember that you can always use a virtual machine or a Raspberry Pi. Nobody would use Windows for a heist anyway, what’s with all the telemetry and such.

The first tool is for reading descriptors – we need one to learn from, it’s just like a keycard you can flash to a security guard and scan at the vault entry. Of course, with RFID, you want to have enough examples, compare bits between a few cards and all. For now, HID descriptors don’t have authenticity checks, but it looks like that might just change in the future. Leave it to Apple and Microsoft to add them, as usual. On Linux, seeing descriptors is simple – as root, go into /sys/bus/usb/devices/, find your device by its lsusb device tree path, then follow the directory with the VID/PID in it. That directory will contain a report_descriptor file – hexdump it. The entire command could look like this:

sudo hexdump -v -e '/1 "%02X "' /sys/bus/usb/devices/3-6.2/3-6.2\:1.1/0003\:0C40\:8000.0022/report_descriptor`

Again, you might need root to even find this path, so use sudo -i if you must. The format string in the hexdump command gives you parser-friendly output. Specifically, for parsing, I use this webpage – it’s wonderful, even adding tabs that delineate different sections of the descriptor, making its output all that more readable! You can also save this webpage locally, it’s a very neat tool. Other than that, you can try other local tools like this one!

Continue reading “Human-Interfacing Devices: Packing For The Descriptor Heist”

Human-Interfacing Devices: The Descriptor Heist

Today, we’ll build our own input devices. And they will be easy to create and write firmware for, they will work perfectly, and they will be cross-platform. We can do that with help of the Human Interface Device (HID) standard, and by way of introduction, so that you never get confused by what a “descriptor” means, and we’ll build our own HID device — a Human Interface Device device. The way we build them won’t require reading specifications – instead, I’ll teach your how to steal HID descriptors from existing devices, tweak them for our purposes, and use them in our devices to harness the power of HID.

For decades now, it’s been possible to build a HID mouse or keyboard by using a library or two, and it’s been a godsend for hackers all around the world. However, these libraries are typically confined to a certain template and inflexible, and we hackers often go outside of what’s expected. HID allows for much more than a simple keyboard or a mouse. That’s why today we’re building a touchscreen – something not yet covered online or by libraries.

HID lets you build devices that are friendly. They don’t need drivers, they are plug and play, and they do what you expect them to do. At its core, the HID standard is as simple as is ubiquitous. You can tunnel HID over USB, Bluetooth, I2C, and modern-day operating systems support all three of these. Today, let’s go through the basics of HID, and then build a USB touchscreen out of a SPI-connected resistive touchscreen, with help of the usual RP2040+MicroPython combo. I will also give you a toolkit for how to debug a Human Interface Device device as thoroughly as possible – specifically on Linux, showing all the HID debug and introspection capabilities that Linux gives you. But it’ll work on Windows too through the beauty of standardization.

Continue reading “Human-Interfacing Devices: The Descriptor Heist”

When Is A Typewriter A Printer? When It Has A Parallel Port

If you want to talk to a typewriter using something other than your fingers on the keys, you could do a lot worse than to pick up a specimen featuring a Centronics parallel port. That’s what happened to [mlupo], who came across an old Swintec 1146 CMP and decided to hack it into an art installation.

At the push of a giant, clicky button, the typewriter now spits out family stories. This is all thanks to an Adafruit KB2040 keyboard driver being used in a new, exciting way — as a printer driver.

More specifically, the CircuitPython program running on the KB2040 takes in a text file and then sends the data one character at a time until a newline is reached. At that point, the typewriter sends a busy signal and the characters are typed.

As soon as the typewriter is no longer occupied, the data stream picks back up until the next newline or until the file is completely typed out.

Once [mlupo] figured out enough of the parallel port protocol, they were able to build a custom breakout board with the KB2040, a female parallel port, and a row of LEDs for debugging that [mlupo] kept because they look cool.

The KB2040 sets the values high on a series of the parallel port’s data pins, along with the port’s STROBE pin, which pulls low when data is ready. During each STROBE cycle, the high and low pins are read by the Swintec as a binary character.

Of course, you can always use the power of Pi to build your own modern typewriter.

Thanks to [foamyguy] for the tip!

An ebike motor with the controller cover removed. A number of wires and connectors take up most of the space in the cavity.

Open Brain Surgery For EBikes And EScooters

Personal Electric Vehicles (PEVs) all contain the same basic set of parts: a motor, a battery, a motor controller, some sensors, and a display to parse the information. This simplicity allowed [casainho] to develop a custom controller setup for their own PEVs.

Built around the venerable VESC motor controller, [casainho]’s addition is the EBike/EScooter board that interfaces the existing motor of a device to the controller. Their ESP32-powered CircuitPython solution takes the sensor output of a given bike or scooter (throttle, cadence, or torque) and translates it into the inputs the controller uses to set the motor power.

They’ve also designed an ESP32-based display to interface the rest of the system to the user while riding. Since it also runs CircuitPython, it’s easy to reconfigure the functions of the three button device to display whatever you’d like as well as change various drive modes of your system. I know I’d love to see my own ebikes have a different mode for riding on road versus on shared paths since not getting run over by cars and not harassing pedestrians aren’t going to have the same power profile.

If you want to find more ways to join the PEV revolution, check out this wild omni-wheeled bike or this solar car built from two separate e-bikes. If that doesn’t suit your fancy, how about an off-label use for an e-bike battery to power your laptop off grid?