HackerBox 0080: Entropy

by HackerBoxes in Circuits > Wearables

5676 Views, 17 Favorites, 0 Comments

HackerBox 0080: Entropy

HB0080 Whole Box.png

Welcome to HackerBox 0080 where we will explore entropy (aka disorder, randomness, chaos, uncertainty) and its importance to cryptography and information security. Our primary mission this month, will be to assemble and program the Amulet of Entropy (AoE). Based on the Raspberry Pi RP2040 dual-core ARM microcontroller, the Amulet of Entropy features a circular 240x240 pixel 1.28 inch full-color IPS display, eight RGB LEDs, four user input buttons, and a LiPo battery manager.  The AoE will allow us to experiment with four entropy sources to harness randomness from nature through ambient light, thermal noise, motion, and semiconductor junction noise. We will also take this opportunity to step up our soldering game with some new tools and supplies.

HackerBox is the original monthly subscription box for electronics, computer technology, and hacker culture. Each HackerBox is a discovery box, which means all members await and enjoy a new surprise each month. Tech, toys, knowledge, and fun. It's like having a hacker convention, your birthday, and the first day of school - every month - right in your mailbox.

There is a wealth of information for current and prospective members in the HackerBoxes FAQ. Almost all of the non-technical support emails that we receive are already answered there, so we'd really appreciate it if you can take a few minutes to read the FAQ.

Supplies

This Instructable contains information for getting started with HackerBox 0080. The full box contents are listed on the product page for HackerBox 0080 where the box is also available for purchase while supplies last. If you would like to automatically receive a HackerBox like this right in your mailbox each month, you can subscribe at HackerBoxes.com and join the party! Subscribers save at least $15 every month and get each new HackerBox shipped immediately off of the production line.

A soldering iron, solder, and basic soldering tools are generally needed to work on the monthly HackerBox. A computer for running software tools is also required. Have a look at the HackerBox Workshops for basic tools and a wide array of introductory activities and experiments.

The most import thing you will need is a sense of adventure, hacker spirit, patience, and curiosity. Building and experimenting with electronics, while very rewarding, can be tricky, challenging, and even frustrating at times. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from this hobby. Take each step slowly, mind the details, and don't be afraid to ask for help.

WEAR SAFETY GLASSES WHEN SOLDERING, WHEN TRIMMING WIRE LEADS, OR WHEN CUTTING, DRILLING, ETC.

Entropy and Information Security

entropy.png

Entropy is a scientific concept as well as a measurable physical property that is most commonly associated with a state of disorder, randomness, chaos, or uncertainty. The term and the concept are used in diverse fields, from classical thermodynamics, where it was first recognized, to the microscopic description of nature in statistical physics, and to the principles of information theory. It has found far-ranging applications in chemistry and physics, in biological systems and their relation to life, in cosmology, economics, sociology, weather science, climate change, and information systems including the transmission of information in telecommunication. (Wikipedia)

In Cryptography, entropy refers to the randomness collected by a system for use in algorithms that require random data. A lack of good entropy can leave a cryptosystem vulnerable and unable to encrypt data securely. A challenge is that computers are deterministic. Deterministic machines are machines that do exactly what we tell them to do. In order to coax a machine into doing something random, we have to introduce a source of random input from outside the machine. For example, we can gather “environmental noise” from the computer’s environment and use that noise to generate random numbers. Sources of randomness from the environment might include inter-keyboard timings, inter-interrupt timings from some interrupts, and other events which are both (a) non-deterministic and (b) hard for an outside observer to guess or measure. (What Is Entropy In Cryptography?)

Firewalls Don't Stop Dragons

Ep279: Necessary Chaos

The Amulet of Entropy is part of a collaboration with Carey Parker, author of the book “Firewalls Don’t Stop Dragons: A Step-by-Step Guide to Computer Security and Privacy for Non-Techies”. Carey is also the host of a podcast by the same name. An episode of the podcast related to this project is embedded above. The episode is entitled, Necessary Chaos.

Additional Links:

FirewallsDontStopDragons.com

AmuletOfEntropy.com

Amulet of Entropy Badge

Amulet Kit.png

The Amulet of Entropy (AoE) is an indie conference badge supplied in DIY kit form. The kit serves many purposes. First and foremost: the challenge, experience, and exercise of building a complex electronic system. When it doesn't work: learning about the components, design, and how to tame the dragon. When it does work: exploring the four entropy sources, hacking code, expressing creative modifications, and victoriously displaying the results - Rockin' the #badgelife

Video: BadgeLife - A Hackaday Documentary

AoE KIT CONTENTS

The Amulet of Entropy comprises two printed circuit boards (PCBs) that plug together sandwiching all of the components, and an optional LiPo battery, inside. The two PCBs are the "Main Board" and the "Display Board". PDF Schematics for the two boards are attached below.

Here is a complete list of the many elements found in the AoE kit:

  • 1 Amulet of Entropy "Main Board" PCB
  • 1 Amulet of Entropy "Display Board" PCB
  • 1 Raspberry Pi RP2040-Zero Microcontroller Module
  • 1 GY-521 6-Axis Accelerometer Gyroscope Module
  • 1 MH-CD42 LiPo Battery Management Module
  • 1 GC9A01 1.28 inch Round IPS LCD 240x240
  • 8 SK6812MINI-E Reverse-Mount RGB LEDs
  • 1 Photo Resistor GL10528 7mm Package
  • 1 Temperature Sensor TMP36GRTZ ("T6G") SOT-23 Package
  • 3 2N3904 NPN Transistors SMD SOT-23 Package
  • 2 Tantalum Capacitors 10UF ("106") SMD-3216 Package
  • 1 Ceramic Capacitor 100NF SMD-1206 Package
  • 2 Resistors 4.7K ("472") SMD-1206 Package
  • 2 Resistors 10K ("103") SMD-1206 Package
  • 1 Resistor 1.5M ("155") SMD-1206 Package
  • 1 Resistor 10R ("100") SMD-1206 Package
  • 4 Tactile Switches Right Angle SMD
  • 1 Slide Switch SPDT SMD
  • 1 JST-PH 2 pin 2.0mm Right-Angle Battery Connector
  • 1 Male Header Pins 1x40 (2.54mm)
  • 1 2x20 SMD Male Header 2.54mm Pitch
  • 3 2x20 Female Headers 2.54mm Pitch
  • 4 Magic Silicate Crystals
  • 1 Black Leather Lanyard Cord 1m x 3mm
  • 1 Stainless Steel Split Ring
  • 1 Two-Sided Adhesive Disc 30mm

FOUR AoE ENTROPY SOURCES

  1. Motion: GY-521 Module using I2C SDA on pin 14 and I2C SCL on pin 15 (tutorial)
  2. Light: GL10528 Photo Resistor using ADC on pin 27 (datasheet)
  3. Semiconductor Avalanche Noise: Random Number Generator using ADC on pin 28 (tutorial)
  4. Thermal Noise: TMP36GRTZ Temperature Sensor using ADC on pin 29 (datasheet)

Raspberry Pi RP2040

RP2040.png

Prior to Soldering

Complete the IDE setup and initial test of the RP2040-Zero module prior to soldering anything to the module.

The RP2040-Zero (Manufacturer Wiki) is a high-performance pico-like MCU module based on the Raspberry Pi RP2040 chip. The microcontroller unit (MCU) features a dual-core ARM Cortex M0+ processor, flexible clock running up to 133 MHz, 264KB of SRAM, and 2MB of on-board Flash memory.

The RP2040-Zero can be connected to a PC using a USB-C cable. When first powered up, the module's onboard LED should light up in green, red, and then blue.

Arduino IDE Configuration

Install the Arduino IDE software and setup the board support package for RP2040 as outlined here.

Within the IDE select: Board > Generic RP2040

LED Rainbow Demo

Use Tools > Manage Libraries to search for and install the "Adafruit NeoPixel" Library.

Unplug the MCU, and hold down the BOOT button while plugging it back in. This will force the MCU module into programming mode.

Download the attached RP2040_RGB_LED.ino sketch. Compile and upload the sketch.

The uploaded code with smoothly cycle through rainbow colors on the MCU module's onboard RGB LED.

The process of holding the BOOT button down while power cycling the module should not need to be performed again, but remember this technique if you ever run into problems uploading code to the RP2040.

Downloads

Main Board Assembly: SMD Components

Proc Assm A - SMD.png

Start assembling the Amulet of Entropy with the "Main Board" PCB. It's the one that says PCBWay on the back, which makes this the perfect time to thank PCBWay for helping to sponsor this project. Xie xie!

PCBWay is currently offering ten prototype PCBs turned in 24 hours for only $5.

Let's apply all of the SMD (surface mounted device) components to the PCB in this step.

We suggest soldering the components in the following order:

FOUR Right Angle Tactile Switches

These are nice components to start with because the pads nicely wick up solder. The sensation of solder wicking up (under and around) each component lead is very satisfying. That will hopefully build the confidence for good SMD hand work. Orient each switch so that the push button (little black square) is facing outward from the edge of the board. The tiny alignment pegs on under the switches will drop into the corresponding hole in the PCB.

SPDT Slide Switch (SW1)

Switches the power source between USB and Battery. When no battery is attached, switching to battery mode, simply turns the AoE off. When switched into USB mode, the USB power plug will operate the AoE and also charge the LiPo battery.

An SPDT (Single Pole Double Throw) switch has one input terminal and two output terminals. The single input can be switched between each of the two outputs. Check out the AoE Main Board schematic and the specification for the MH-CD42 LiPo battery management module to discover that we are using the switch in a confusing way here. The 5V pin of the MCU module is the SINGLE POLE side of the switch, but it is an input in one state and an output in the other state. In "USB" MODE, the 5V pin of the MCU module is switched to the input of the MH-CD42, allowing 5V from the USB plug to charge the battery. In "BAT" MODE, the 5V pin of the MCU module is switched to the output from the MH-CD42, allowing 5V from the battery circuit to power the MCU module (and the entire AoE therefrom).

10uF Tantalum Capacitor (C1)

A yellowish capacitor marked with "106" on the top. That means 10 followed by 6 zeros (10,000,000) picofarads, which equals 10,000 nanofarads or 10 microfarads. We mark capacitors in picofarads (10 to the power of minus 12) because a farad is FREAKING HUGE.

Tantalum capacitors are polarized, meaning they must be correctly oriented or bad things will happen. The PCB silkscreen for C1 shows a white box that is closed at the positive side and open at the negative side. The capacitor has a thick line adjacent to its anode (positive) terminal. Match these up by putting the anode marking (thick line on the capacitor) into the closed side of the white box.

100 nF Ceramic Capacitor (C2)

This capacitor is not marked, but it is the only brownish-tan unmarked SMD component. Ceramic capacitors are not polarized, so it can be soldered in either direction.

TWO 4.7 KOhm Resistors Marked "472" (R3, R6)

ONE 1.5 MOhm Resistor Marked "155" (R4)

TWO 10 KOhm Resistors Marked "103" (R2, R5)

All five of these resistors can be soldered in either direction. However, they are not interchangeable, so be sure to match the values up to the correct PCB locations.

THREE 2N3904 NPN Transistors (Q1, Q2, Q3)

These transistors have two pins on one side and one pin on the other side. Be sure to orient the device matching the pins to the pads on the PCB. The pads looks small, but they are soldered exactly like the capacitors and resistors above. Work at the edge of each device terminal (where it meets the PCB) - allowing solder to flow and wick up into the surface between the metal terminal and the gold PCB pad.

TMP36GRTZ Temperature Sensor

This device is marked "T6G". It looks very similar to the transistors, but it has three pins on one side and two pins on the other. Again, be sure to orient the device so the pins match the pads on the PCB.

Main Board Assembly: Connect the MCU

Proc ASSM B - MCU.png

Mount Headers to the MCU Module

Break off two nine pin sections from the 1x40 male header.

Insert the nine pin header sections into the long sides of the RP2040 module. Put the short pins of the headers through the module with the header's plastic insulator on the side of the module that is opposite from the USB connector.

Solder the headers into place onto the RP2040 as shown in image A above.

Mount MCU Module to Main Board PCB "THE SMOOTH WAY"

Since you may wish to wear the AoE as a badge, you probably do not want the back of the PCB to be "prickly" with component and header posts. There is an excellent trick to prevent the prickliness. It basically involves cutting the through hole leads flush against the back of the board BEFORE soldering, and then making a nice smooth "hill" of solder over the flush-cut pin. Follow these detailed steps:

  • With the module in place, flip the board over.
  • Flush-cut all of the pins as close to the board as possible.
  • While holding the module in, solder two opposite corners as shown in image B.
  • Solder the remaining pins as shown in image C.
  • Be sure the solder flows down into each hole around its cut pin.
  • Use enough solder to leave a smooth "hill" over each pin.

Power up the MCU

The rainbow cycling LED code should still run.

Additional Hardware Verification Code

Download the attached AoE_Initial_MainBoard_Test.ino sketch. Compile and upload the sketch.

The sketch uses the RP2040-Zero's on-board LED to report on some initial hardware tests.

First, the LED is illuminated blue for one second and then off for one second.

Next, the code reads the temperature sensor. If the temperature value read passes a sanity check, the LED is illuminated green for five seconds. Otherwise, it is illuminated red for five seconds.

After that, the code cycles forever checking the state of the the four pushbuttons. If a button is held down, the LED is blinked blue 1, 2, 3, or 4 times to show which of the four buttons is being pressed.

Main Board Assembly: Through Hole Components

Proc Assm C - TH.png

Mount the remaining through hole components (listed below) to the AoE Main Board.

Continue to use "THE SMOOTH WAY" to prevent the back of the board from becoming scratchy.

The following order is suggested to simplify assembly:

  • JST-PH 2-pin Battery Connector
  • GY-521 Motion Processing Unit (MPU)
  • MH-CD42 LiPo Battery Manager
  • Three 2x20 Female Headers
  • GL10528 Photo Resistor

Use six pins from the 1x40 Male Header to mount the MH-CD42 LiPo Battery Manager.

Before mounting the photo resistor, form its leads as shown. This will expose the sensor surface to the outside of the PCB to improve the sensing of ambient illumination.

Display Board Assembly: SMD

Disp Assm A - SMD.png

Continue assembling the Amulet of Entropy with the "Display Board" PCB. It's the one with the four gold dragons on the front.

The following order is suggested to simplify assembly:

EIGHT SK6812MINI-E Reverse-Mount RGB LEDs

The LEDs mount to the back of the PCB (opposite the side with the dragons). The lens of each LED (where the light comes out) faces down into the PCB so that the LED light is emitted out from the side with the dragons. Each LED must be oriented such that the solder terminal with the angled corner cut is closest to the white corner marking on the PCB silkscreen.

10 uF Tantalum Capacitor (C1)

Tantalum capacitors are polarized and must be oriented in the correct direction. The PCB silkscreen for C1 shows a white box that is closed at the positive side and open at the negative side. The capacitor has a thick line adjacent to its anode (positive) terminal. Match these up by putting the anode marking (thick line on the capacitor) into the closed side of the white box.

10 Ohm Resistor (R1)

The ten ohm resistor is marked "100" (10 followed by 0 zeros). It is placed at the location marked R1. As usual, resistors can be oriented either way. They are not polarized.

2x20 Pin SMD Male Header 2.54mm Pitch

This connector needs to be cut into FOUR 2x5 pin sections. The best way to cut it is to use the tip of small flush cutters (wire cutters) at the notched edge of the header's plastic insulation strip. Wear your safety glasses! When soldering the four header sections, align the terminals on their PCB pads as close to centered as possible. That will simplify plugging the two PCBs together.

Display Board Assembly: LCD Panel

Disp Assm B - flex con.png

The display panel is a 1.28 inch Round IPS TFT Liquid Crystal Display with 240x240 pixels based on the GC9A01 interface and driver chip (datasheet). Be extremely careful when handling the LCD panel. It is fairly tough for a small piece of glass, but it is still a small piece of glass.

Connecting the Display Panel

Start by peeling either side of the backing off of the 30mm Two-Sided Adhesive Disc and attach the disk in the center of the circle on the dragon side of the Display Board PCB. Leave the other side of backing on for now.

Place the connector "tail" of the circular LCD panel module through the slot in Display Board starting from the dragon side. Orient the circular LCD panel such that the glass surface is facing out and metallic surface is facing in against the PCB.

Fold the circular display and the flex cable into place observing how the display rests within its gold circle and how the 12 traces on the flex cable line up to the 12 traces on the PCB. Keep these two alignment factors in mind while performing the next step.

Peel the remaining backing from the 30mm Two-Sided Adhesive Disc and affix the circular LCD panel into place while ensuring that the flex cable traces and PCB traces remain aligned.

Being extremely careful not to place too much force on the PCB with the LCD facing down, hold the flex cable into place and solder along the flex cable trace lines down onto the PCB, allowing solder to wick again and under the flex cable connection. If any solder bridges are created between traces, run the iron along the traces to gather up some of the solder. Add some gel flux if necessary. Here is a nice video of how the process should look and feel. Note the generous use of flux.

Complete Amulet of Entropy

Complete Badge.png

With both boards of the AoE completely assembled, they can be plugged together. Be sure to align the male headers into both rows at the respective ends of the female headers.

The headers allow for the boards to be separated and reseated whenever necessary. They also form an inner space for holding an optional rechargeable battery pack.

Demo Code

Use Tools > Manage Libraries to search for and install the GFX Library for Arduino by "Moon On Our Nation"

Download the attached hb80_demo.ino sketch. Compile and upload the sketch.

After a quick test of the LCD panel, the sketch will continuously update the display with random values from the entropy sources. Also, holding down any of the four pushbuttons will turn the nearest RGB LED from green to purple.

Optional Rechargeable Battery

A 3.7V Lithium Battery can be connected to the two-pin JST header inside the AoE.

The space between the two PCBs can support a battery pack up to about 5x7cm (or 2x2.7 inches).

That can generally fit a battery pack of around 2000-4000 mAh.

For example, a LiPo battery pack like this one should work well. However, the polarity of the connector will probably have to be reversed to match the red wire to the "+" marking next to the JST connector on the AoE. This can be done using a small screwdriver or SIM card tool to release the pins from the battery's JST connector and then inserting them back in reverse to match the PCB marking.

Unfortunately, LiPo battery packs come wired in either polarity. The ones from Adafruit and SparkFun tend to be the same polarity as found on the AoE, while the battery packs found on Amazon and eBay are more often the opposite polarity and will need to be "corrected". Life is like a box of chocolates. Just be sure to double check your battery pack before plugging it in to the AoE - or any other system for that matter.

Finishing Touches

The included stainless steel split ring can be inserted through the hole at the top of the Main Board PCB and then closed with pliers. Once the ring is closed, the black leather cord can be strung through it and the ends of the cord can be tied together to form a lanyard.

The included silicate crystals can be affixed atop the four RGB LEDs in the arrow heads. Using hot glue for this forms a "light pipe" that nicely conducts light from the LED into the bottom of the corresponding crystal.

Natural materials like leather and crystals are sometimes thought to conduct or focus magical properties. Your entropy may vary.

Downloads

Amulet of Entropy Software

Careys Code.png

Carey Parker, the Firewall Dragon himself, has written some excellent software that really rocks the AoE hardware. He has shared it all on his github repository.

Next Level Soldering

HOW FLUX WORKS: What is that GOOEY liquid Louis pours on the boards?

HackerBox 0080 includes some soldering tools that will hopefully improve our soldering game.

The solder that we use in electronics is flux core solder. This means that there is flux inside the solder itself. That flux is what gives off smoke while you are soldering. Unfortunately, once that flux is burned off, it is all gone and sometimes we still need more flux. Sometimes you just want to drown a component or connection in flux while soldering. MOAR FLUX. The included syringe of flux gel will make all of these dreams come true. Enjoy!

(We do suggest cleaning the flux residue off of the finished work afterwards. Just use a little isopropyl alcohol.)

Cross action tweezers are useful for holding small parts while soldering. Just try not to allow the applied spring tension from the tweezers to "pop" the part out and send it flying across the room. Yes, I speak from experience.

HC SVNT DRACONES

outro.png

We hope you are enjoying this month's HackerBox adventure into electronics, computer technology, and hacker culture. Reach out and share your success in the comments below or other social media. Also, remember that you can email support@hackerboxes.com anytime if you have a question or need some help.

What's Next? Join the party and live the HackLife! Get a cool box of hackable gear delivered right to your mailbox each month and enjoy a generous member discount. Surf over to HackerBoxes.com right now and sign up for your monthly HackerBox subscription.