HackerBox Core Workshop

by HackerBoxes in Circuits > Microcontrollers

4680 Views, 16 Favorites, 0 Comments

HackerBox Core Workshop

Core Workshop.png

The HackerBox Core Workshop is designed to provide preparation for more advanced electronics projects such as the monthly HackerBox subscription boxes. The workshop features hands-on experiments with five different microcontroller platforms. These platforms were selected to leverage a range of development tools and various programming languages. Configure and program the ESP82666, ATmega328P, ESP32, SAMD21, and ARM STM32. 

Prototype an Arduino on breadboard platform from a bare microcontroller chip. Assemble the Wi-Fi Nugget soldering project to explore IoT and wireless network security. Experiment with various application areas including graphics, wireless communications, human-machine interface, security, and AI. Expand your electronics toolset with supplies and components selected to support many future hardware projects.

HackerBoxes is the monthly subscription box for enthusiasts of electronics and computer technology - Hardware Hackers - The Dreamers of Dreams.

Supplies

This Instructable contains information for working with the HackerBox Core Workshop. Full workshop contents are listed on the product page where the Core Workshop is also available for purchase.

A soldering iron, solder, and basic soldering tools are generally needed to work on HackerBoxers. A computer for running software tools is also required. Have a look at the HackerBox Basics Workshop and the HackerBox Soldering Workshop for tools and a wide array of introductory activities that may be considered helpful prerequisites to the Core Workshop.

You will definitely also need 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.

Dual Core ESP32 With Wi-Fi and Bluetooth

ESP32.png

The ESP32 is a dual core 32-bit System-On-Chip. It has Wi-Fi, Bluetooth, and 512KB of RAM built-in. The clock frequency can go up to 240MHz. The ESP32 incorporates a wide variety of peripherals including: capacitive touch, ADCs, DACs, UART, SPI, and I2C.

Test out the ESP32 module before soldering the pins to the module. Random Nerds have an excellent tutorial for setting up the Arduino IDE to program ESP32 modules. Note that once the IDE is set up for it, the ESP32 board can be used a lot like an Arduino UNO or NANO. One important difference is that the ESP32 is 3.3V instead of 5V, so always keep that it mind.

Once you get the hang of programming the ESP32 module, the Random Nerds page linked above lists a variety of demo projects for the ESP32 including IoT, Web Servers, Bluetooth, Alexa Integration, MicroPython, and may others. There are a ton of great ESP32 projects out there, just search around.

Video: Sniffing WiFi with ESP32 into Wireshark

Connect the Full-Color TFT Display

ILI9341 TFT LCD to ESP32 - Full HOW TO for display, SD card and Touch. Using TFT_eSPI driver

The TFT LCD Full-Color Display measures 2.8 inches diagonal and features 320x240 pixels. It is based on the ILI9341 controller chip equipped with a Serial Peripheral Interface (SPI) that can be connected to the ESP32 (or most any other microcontroller as well).

The TFT module and MCU can be connected together on the solderless breadboard or they can be wired directly using the female-to-female DuPont jumpers.

Note that the version of the TFT module included does feature an SD card slot than can we wired for access by the microcontroller. However, it does not include a touch screen overlay.

The video attached here is from an XTronical project page which demonstrates use of the TFT_eSPI library.

The display can also be controlled using the Adafruit 9341 Library.


ESP8266 D1 Mini

Wemos D1 Mini.png

The D1 Mini Module is based on the ESP8266 SOC. The ESP8266 SOC includes a microcontroller core, Wi-Fi circuitry, and an integrated TCP/IP protocol stack. The ESP8266 is capable of running code directly on its MCU core, or the ESP8266 can act as a communication peripheral to provide WiFi functionality to another microcontroller.

ESP8266 with the Arduino IDE

The D1 Mini Module can be programmed through the Arduino IDE. To set up the ESP8266 support within the Arduino IDE, follow Steps 1-5 of this tutorial.

In the IDE, select Tools > Board > ESP8266 Boards > LOLIN WEMOS D1 R2 & mini

Under Tools > Port select the COM port that appears when the D1 Mini is plugged in

Blink an LED

Open and upload the sketch: File > Example > ESP8266 > Blink

Once uploaded, the Blink sketch will flash the blue LED on the D1 Mini

You can experiment with changing both delay calls in the blink sketch to 2000, run the code, and then change them both to 200 and run the code again. Verify that the LED flashes ten times faster with the 200ms delays compared to the 2000ms delays.

Scan Wi-Fi Networks

The best thing about the ESP8266 is Wi-Fi support, so let's try it out. Grab the NetScan8266.ino sketch attached here. Program it into the D1 Mini.

Open Tools > Serial Monitor and set the baud rate to 9600.

The ESP8266 will scan for all 2.4GHz networks and then list out the SSID and RSSI of each one to the serial monitor.

Downloads

Assemble the Wi-Fi Nugget

WiFi Nugget.png

The Wi-Fi Nugget is a cool hacking platform based on the D1 Mini module with an added OLED display, four push buttons, and an RGB WS2812B LED.

The Open Source Hardware Wi-Fi Nugget was designed by skickar and alexlynd. MOAR Nuggets can be purchased from Retia.

Assembly Notes:

Start with the four pushbuttons. They are not polarized and can be oriented in either direction.

Next set the LED. It must be correctly oriented, so find the little white triangle on one corner of he LED itself and the corner marking on the PCB silk screen. Turn the LED so that these line up.

Next solder on the ESP8266 D1 Mini using the header pins. After soldering, trim the pins close the Nugget PCB

ALWAYS WEAR SAFETY GLASSES WHEN CUTTING PINS

The last item to solder is the 1.3 inch OLED Display. Prior to soldering the OLED, it is a good idea to put some electrical tape (or carboard or plastic or whatever) between the display and the D1 mini pins that protrude underneath. This can help prevent things from shorting out and also makes the finished product feel nice and solid.

Shall We Play A Game?

This one has nothing to do with LANs, but games are always fun.

Give the attached arkanug.ino a shot.

Note that arkanug requires first setting up the library ssd1306 (by Alexey Dynda) through the Arduino IDE library manager.

Downloads

Wi-Fi Nugget Projects

HakByte: Create a $15 WarDriving Rig to Log WiFi Data w/ the ESP8266

This video demonstrates the power and versatility of our little ESP8266 SoC as a security tool.

Wi-Fi Nugget Packet Monitor code

Wi-Fi Nugget Quick Start video

Find additional videos and projects on HAK5 YouTube Channel

Search for "WiFi Nugget" on YouTube

CircuitPython - Seeeduino XIAO (SAMD21)

XIAO.png

Seeeduino XIAO Specifications:

  • CPU: ARM Cortex-M0+ CPU(SAMD21G18) running at up to 48MHz
  • Storage: 256KB Flash,32KB SRAM
  • I/O PINs: 14 GPIO PINs,11 analog PINs, 11 digital PINs, 1 DAC output Pin
  • Interface: 1 I2C interface,1 UART interface, 1 SPI interface
  • Support Q-touch function (A0,A1,A6,A7,A8,A9,A10)
  • Power supply and downloading interface: USB Type-C interface
  • LEDs: 1 user LED, 1 power LED, two LEDs for serial port downloading
  • Reset button: two reset button short connect to reset
  • Power Pads: For the battery power supply
  • Software compatibility: Compatible with Arduino IDE
  • Projection cover for protecting the circuit
  • Dimensions: 20x17.5x3.5 mm

Seeeduino XIAO Wiki

Installing CircuitPython on the XIAO

First Steps Video with Hackster.io

Fruit Piano using the XIAO’s Q-Touch Function



STM32F411CEU6 Development Module

STM32F411.png

STM32F411CEU6

ARM 32-bit Cortex-M4 CPU with floating point unit, Adaptive real-time accelerator (ART Accelerator) allowing 0-wait state execution from Flash memory, frequency up to 100 MHz, memory protection unit, 125 DMIPS/1.25 DMIPS/MHz (Dhrystone 2.1), and DSP instructions

Memory

  • 512 Kbytes of Flash memory
  • 128 Kbytes of SRAM
  • SPI Flash (Optional)

Clock and Power Supply

  • 3.3V-5V power input, 3.3V LDO maximum output current 100mA
  • USB-C interface power with backflow protection diode
  • 25MHz 9PF high speed crystal oscillator
  • 32.768K 6PF low speed crystal oscillator

Interface and Key

  • USART x 3, I2C x 3, SPI x 5,USBFS x 1
  • ADC x 1(10),I2S x 5,CRC x 1,TIM x 8
  • 20 Pin 2.54mm pitch I/O interface x 2
  • 4 Pin 2.54mm pitch SW debug interface
  • USB-C interface

CircuitPython Configuration

Official CircuitPython documentation.

Arduino IDE Configuration

This repository adds support for STM32 MCUs in Arduino IDE

select

Tools > Board: STM32 Boards (selected from submenu) > Generic STM32F4 series

and then

Tools > select submenu of Board part number > BlackPill F411CE

ATmega328P

ATmega328 pinout.png

The ATmega328P (manufacturer specs and datasheets) is extremely well know for being the widely-used MCU at the heart of the Arduino UNO and the Arduino Nano.

It is a high-performance Microchip picoPower 8-bit AVR RISC-based microcontroller. It combines 32 KB ISP Flash memory with read-while-write capabilities, 1024B EEPROM, 2 KB SRAM, 23 general purpose I/O lines, 32 general purpose working registers, three flexible timer/counters with compare modes, internal and external interrupts, serial programmable USART, a byte-oriented Two-Wire serial interface, SPI serial port, a 6-channel 10-bit A/D converter (8-channels in TQFP and QFN/MLF packages), programmable watchdog timer with internal oscillator, and five software selectable power saving modes. The device operates between 1.8-5.5 volts.

Once configured as a Arduino, the I/O pins can be referenced within your Arduino sketches by the pin identifiers in the dotted-line boxes of the image above. Pinout graphic from Maker Portal.

DIY Arduino on a Breadboard

BB Arduino Start.png

Insert the MCU onto a solderless breadboard taking note of the semi-circular "pin 1" indicator at one end of the IC. The hole numbers on the breadboard do not mater and can be ignored. What maters are the relative connections to the pins of the MCU as well as the two ground and two 5V power rails.

The other components are the 16MHz crystal along with its two 22pF ceramic capacitors. These three components are not polarized and can be inserted into the breadboard in either orientation. The crystal, and its capacitors, are connected to the XTAL1 and XTAL2 pins of the MCU.

The 10K resistor (stripes: brown, black, orange) connected between pin 1 (RESET) of the MCU and 5V can also be inserted in either direction. This PULL-UP resistors keeps the MCU out of its reset state. Since the RESET pin is active low, the MCU goes into reset when the pin is grounded. Pulling the pin to high (5V) makes sure the MCU is not ever in its reset state and instead is always running.

The black and red wires going to the MCU (two of each) are power and ground to supply the MCU with 5V. Note two important things about the power rails: They are not yet powered in this configuration (nothing to attached to them to supply power). And also the two grounds are connected together and the two 5V rails are connected together. Make sure you make these connections.

Burn the Arduino Bootloader Using USBasp

BB Arduino USBASP.png

Starting code execution on a computing machine is often referred to as "booting" the computer. In this context, "boot" is short for "bootstrap" or "bootstrap loader" and derives from the phrase "to pull oneself up by one's bootstraps".

Referring specifically to an Arduino (as well as many embedded MCU or microprocessor systems), the bootloader is a chunk of code that is stored in a specific memory space on the Arduino board. The bootloader runs first when the system starts up and can usually do at least two things. First, it can start execution of a program previously burned into another area of the machine's memory. Second, it can receive a new program image (usually over USB/serial port from a PC) and them store that program into the machine's memory for running (usually now and in the future).

Prior to burning a bootloader into an MCU, it is usually good for nothing and doesn't even know how to listen to its serial port for a new program. So let's make sure we put an Arduino bootloader onto our ATmega328P chip which sort of turns it from "just a chip" into an Arduino.

Wire up the USBasp

The USBasp is an in-circuit serial programming adapter that support installing bootloaders and firmware on common AVR microcontrollers, such as those used in Arduino-compatible boards. Note that the USBasp comes with a grey ribbon cable and a ten-to-six pin adapter PCB, neither of which is really needed for this activity. Instead, we can simply use SIX male-female DuPont jumper wires to connect the USBasp to our breadboard as shown above.

Use the Arduino IDE

Select:

Tools > Board > Arduino/Genuino Uno

Tools > Programmer > USBasp

And finally, select:

Tools > Burn Bootloader

Add USB Serial Interface

BB Arduino FT232.png

Once the ATmega328 chip has a bootloader, the firmware can be reprogrammed through the serial port just like on a typical Arduino module. We do however need an interface between the MCU serial port (UART RX and TX pins) and the USB port on the PC. For this USB-serial interfacing, the FT232BL USB serial adapter module is wired up to the breadboard using four female-to-male DuPont jumper wires as shown in the diagram above.

Note 1: The USBasp has now been removed from the breadboard.

Note 2: A momentary pushbutton has been added between the reset pin and the GND rail.

Let's call this button the "reset button". When it is pressed, the reset pin of the MCU is shorted to GND which puts the chip into reset (not running). When the button is released, the 10K pullup resistor will pull the reset pin of the MCU back up to 5V which will take the chip out of reset (letting it run - or boot up).

IDE Programming via FT232BL

In the IDE under Tools > Port, select the COM port that appears when you plug the FT232BL module into the PC and disappears when you unplug the module.

Hold down the reset button before hitting the program icon in the IDE. When the IDE shows that it is starting the actual upload, wait a couple of seconds and release the reset button. If the programming attempt fails, the reset-release timing may take a bit of experimentation. For a brief period after coming out of reset (a little over a second), the bootloader will wait to see if new code comes through the serial port for it to receive and program into the MCU. If that doesn't happen, it will go ahead and boot the code already stored in the MCU from the last programming event.

Auto Reset (Advanced Option)

Wouldn't it be nice to not worry about the reset button when programming the chip? You may notice that some MCU modules have sequence and timing requirements for button presses when programming the MCU, while some MCU modules seem to do the programming automatically without button presses. This isn't just random nor is it magic. A small circuit is added on some modules that uses one or more of the serial handshake signals from the PC to reset (and sometimes set bootstrapping pins on) the MCU whenever a code download is performed over the serial-USB interface.

For the ATmega328 chip, the auto reset circuit is quite simple. We just need a 0.1uF (100nF) capacitor. One side of the capacitor is connected to the RESET pin of the MCU. The 10K pullup resistor on the RESET pin must be left in place. The reset button can be removed, but you might as well keep it in place if its already there.

The other side of the capacitor is connected to the CTS (clear to send) or DTR (detect terminal ready) output from the USB-serial adapter module.

How does the auto reset circuit work? CTS and DTR are configured to both go low whenever a serial code download is coming from the PC. Either of these being coupled to the RESET pin of the MCU will drive the MCU into reset (remember the RESET pin is active low). Then, the capacitor charges back up to VCC (through the 10K pullup resistor) causing the RESET pin to see 5V again (after a very small delay). This releases the MCU from reset and lets the bootloader start just as the PC starts sending the new code image to be flashed.

Hack Life Academy

outro.png

An academy is an institution of higher learning, research, or honorary membership. The term traces back to Plato's school of philosophy, founded approximately 385 BC at Akademia, a sanctuary of Athena, the goddess of wisdom and skill. The word derives from the Athenian hero, Akademos. In the 17th century, British, Italian, and French scholars used the term "academia" to describe institutions of higher learning. The term has come to mean the cultural accumulation of knowledge, its development, and transmission across generations. It also refers to the keepers, educators, and practitioners of such knowledge.

In the academic spirit of accumulating skill and wisdom, we welcome you to subscribe to HackerBoxes. Join us every month for new discoveries in electronics, computation, communications, and information security. Visit HackerBoxes.com to sign up for your monthly HackerBox subscription. In the meantime, wear your HackerBox achievement patch with pride and share your successes and questions in the comments below. Please email support@hackerboxes.com anytime you have a question or need some assistance.