Introduction: HackerBox 0122: Ouroboros

Welcome to HackerBox 0122. Explore eternal recurrence with the enigmatic ouroboros. Configure two ESP32 based development boards. Assemble the first development board into the exclusive HackerBox OVcam platform leveraging an OV7670 camera module. Configure the OVcam to stream images over Wi-Fi to a browser based graphical interface. Assemble the second development board into the exclusive HackerBox ESP ECG platform. Explore the platform hardware with a simple Wi-Fi channel scanning project before connecting electrocardiogram sensor electrodes to truly visualize the beating heart of the matter.

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 0122. The full box contents are listed on the product page for HackerBox 0122 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. Subscription members save at least $15 every month and automatically receive each new HackerBox shipped immediately off the production line.

A soldering iron, solder, and basic assembly 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 tools and supplies along with 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.

Step 1: WeMos LOLIN32 Lite

Both hardware platforms presented here leverage the WeMos LOLIN32 Lite Development Board. Based upon the ESP32 microcontroller, these development boards support Wi-Fi and Bluetooth communications, featuring an integrated 2.4GHz antenna. The LOLIN32 boards also feature 4MB of flash storage, a TYPE-C USB port, and lithium battery support with a maximum charge current of 500mA.

Prior to soldering or otherwise connecting anything to either one of the ESP32 modules, set up the software toolchain and take each of the ESP32 boards for a quick test run.

If necessary, install the Arduino IDE.

Within the IDE, use the Boards Manager to search for ESP32 (by Espressif Systems). For compatibility with certain portions of code used in these projects, install version 2.0.17 of the ESP32 board package.

Select that board package and hit install.

Connect one of the ESP32 modules to your PC using a USB-C cable.

The user LEDs will not illuminate, but the battery charging status LED may flicker very faintly.

Select: Tools > Board > ESP32 > WEMOS LOLIN32 Lite

Select: Tools > Port > will usually include something like "wchusbserial"

In some very limited cases, you may need to install a WCH USB driver for the CH340C USB chip using on the development board.

Open the sketch File > Examples > Basics > Blink

Compile and upload the sketch to the Dev Board

If everything is in order, the sketch will cause the blue LED just next to the pin labeled 22 to begin blinking.

Both of the ESP32 Dev Boards and can tested in this fashion - prior to soldering.

Step 2: Assemble the HackerBox OVcam

Pay extra special attention to which components go onto which side of the OVcam PCB.

The top side of the PCB says HACKERBOX in our trademark font. The bottom side of the PCB has a footprint outline for the ESP32 module labeled LOLIN32.

Start by soldering the following two items onto the top side of the PCB:

  1. Right Angle 2x9 pin Female Header (opening to PCB edge)
  2. Right Angle Tactile Pushbutton

Continue by soldering the following three items onto the bottom side the PCB:

  1. First 4.7K Resistor (can be oriented in either direction)
  2. Second 4.7K Resistor (can be oriented in either direction)
  3. ESP32 WeMos LOLIN32 Lite (orient the USB port to PCB edge)

Connect the OV7670 Camera Module

As shown in the image above, the OV7670 Camera Module is plugged onto the 2x9 header such that the module extends up from the top side of the OVcam. Again, the top side of the PCB shows the HACKERBOX logo.

After assembly, the OVcam may be mounted on a tripod using the supplied Camera Lock Nut

Program the ESP32...

Grab this ESP32 + OV7670 project from bitluni.

Keep all 11 files inside the same project folder.

Use the Arduino IDE Library Manager to install the Adafruit ST7735 and ST7789 Library (including all dependencies).

Make sure that your Espressif Systems ESP32 Board Package is version 2.0.x (we're using 2.0.17)

Open the project's .ino sketch file.

Edit line 11 to:

const int SIOD = 19; //SDA (was 21)

Edit lines 34 and 35 with your Wi-Fi credentials (must be a 2.4GHz network)

Switch over to the project file tab for XClk.cpp

After line 17 (timer_conf.timer_num = LEDC_TIMER_0;),

Paste in the additional line:

timer_conf.clk_cfg = LEDC_USE_APB_CLK;

Hit the arrow button to compile the project and upload it to the ESP32.

Open Tools > Serial Monitor (at 115200 board) to see the assigned IP address.

Paste that IP address into a browser to view the camera image.

WHY MUST THE ESP32 BOARD PACKAGE BE ROLLED BACK?

Part of the migration from 2.x to 3.x involved a change in the LED Control (LEDC) API to support the Peripheral Manager. LEDC is use in the bitluni project to generate an XCLOCK signal supplied to the camera module. It should be fairly straight forward to update the LEDC functionality to work with the latest ESP32 board package. Should you wish to take on that mission, please share your results with the rest of us.

Step 3: Extending the HackerBox OVcam

ADDITIONAL HARDWARE FEATURES

The pushbutton closes between GPIO26 and 3V3 as shown. To read the IO pin properly, configure the internal pulldown resistor.

The EXT header pins may be used for connection to the ESP32 as shown.

The EXT pins are laid out to correspond directly with the display module shown in the image. A fairly common module is available with the following specifications:

  1. TFT LCD Color Display Module
  2. 1.8 Inch
  3. 128x160 pixels
  4. ST7735 Controller Chip
  5. 8 pin SPI Interface
  6. Match the pin ordering as shown

FIRMWARE CONFIGURATION

To use the previous .ino sketch file with the optional display, edit the sketch like so:

Scroll down to the function displayRGB565(...)

Notice the two nested for loops.

Remove all six lines of those for loops.

Replace those with the following 13 lines:

for(int x = 0; x < xres; x++)
{
for(int y = 0; y < yres; y++)
{
i = (y * xres + x) << 1;
tft.pushColor((frame[i] | (frame[i+1] << 8)));
}
// camera is 160x120 but tft is 160x128, so pad out the last 8 tft pixels
for(int y = 0; y < 8; y++)
{
tft.pushColor(0);
}
}

Compile and upload to the ESP32.

If you'd like to flip the display around, edit the setup() function of the sketch

After the line " tft.initR(INITR_BLACKTAB);"

Paste in the additional new line:

tft.setRotation(2);

Step 4: Assemble the HackerBox ESP ECG

Components of the ESP ECG platform stack together in a manner that necessitates assembly in three phases and in the very specific order presented here:

Phase One

Solder the Right Angle Tactile Pushbutton onto the front side of the ESP ECG PCB (the side with the HACKERBOXES logo).

After soldering, trim the leads relatively flush to the other side of the PCB. This is important to prevent contacting the AD8232 ECG Sensor Module that will be mounted to the opposite side.

Phase Two

Position the ESP32 module onto the back side of the ESP ECG PCB. Locate the ESP32 into the outline labeled LOLIN32 and oriented such that its USB port is immediately over the USB marking on the footprint.

Solder the ESP32 module into place.

Break the header pins for the AD8232 ECG Sensor Module into a row of six pins and a row of three pins.

Solder the two sets of pins onto the back side of the module (opposite the components).

Position the AD8232 ECG Sensor Module into its footprint markings next to the ESP32 module.

Solder the AD8232 ECG Sensor Module onto the ESP ECG PCB.

After soldering both modules, trim all of the pins relatively flush to the other side of the PCB. This is important to prevent contacting the MSP2401 display module that will be mounted to the opposite side.

Phase Three

Remove the 2.4 inch MSP2401 display module from its plastic case.

Solder the provided four pin male header onto the back of the display module.

Insert the display module into the front side of the ESP ECG PCB (same side as the button from Phase One).

Prior to soldering the pins of the display module to the ESP ECG PCB, adjust the spacing as shown in the image: There should be 4mm between the ESP ECG PCB (thick green line in the image) and the PCB of the display module (thick purple line in the image). This spacing is achieved by leaving a 1-1.5mm gap (as shown) between the plastic insulators of the display module pins and the ESP ECG PCB (thick green line in the image).

Step 5: Program the ESP32

Demonstrating a Graphical Display

Use the Arduino IDE Library Manager to search for and install the Adafruit ILI9341 Library (including all dependencies).

Open the sketch: File > Examples > Adafruit ILI9341 > graphicstest.ino

replace the pin definitions at lines 22 and 23 with these seven lines:

#define TFT_DC 26
#define TFT_CS 5
#define TFT_MOSI 23
#define TFT_CLK 18
#define TFT_RST 22
#define TFT_MISO 19
#define TFT_BL 25

Just below that, comment out the line "Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);"

and then uncomment the entry two lines down showing:

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

Lastly, add these two new lines inside the setup() function:

pinMode(TFT_BL, OUTPUT);

digitalWrite(TFT_BL, HIGH); // Backlight ON

Hit the arrow button to compile the sketch and push it to the ESP32.

A Second Demonstration: The Wi-Fi Signal Scanner

Grab the attached Wi_Fi_Signal_Scanner.ino sketch. Compile and upload to the HackerBox ESP ECG. The code is very closely baed on this project from TeknoTrek.

Step 6: The Heart of the Matter

An electrocardiogram (ECG or EKG) is the display of a heart's electrical activity through repeated cardiac cycles. An ECG is a graph of voltage versus time of the electrical activity of the heart measured using electrodes placed on the skin. These electrodes detect the small electrical changes that are a consequence of cardiac muscle depolarization followed by repolarization during each heartbeat of the cardiac cycle. (Wikipedia)

AD8232 Based ECG Measurement

The AD8232 (datasheet) is an integrated signal conditioning block for ECG and other biopotential measurement applications. It is designed to extract, amplify, and filter small biopotential signals in the presence of noisy conditions, such as those created by motion or remote electrode placement. This design allows for an ultralow power analog-to-digital converter (ADC) or an embedded microcontroller to acquire the output signal.

A common AD8232 module can be purchased from Sparkfun where you can also find this rather detailed hookup tutorial. This Last Minute Engineers tutorial is also worth a look.

HackerBox ECG LCD Firmware

Grab the attached ECG_LCD.ino sketch.

Compile and upload the sketch to the HackerBox ESP ECG platform.

The sketch starts by displaying a simulated ECG waveform until the pushbutton is pressed.

After the button is detected, the sketch goes into live sampling mode.

Take note of the tips for getting a good ECG reading in both of the tutorials linked above.

NOTICES

This platform is an educational demonstration, NOT a medical device. It is not intended to diagnose or treat any conditions.

It is generally advised that an electronic device connected in any way to the human body be powered by an isolated low-voltage battery and not by the A.C. power grid.

Step 7: Ouroboros

The ouroboros is an ancient symbol depicting a snake or dragon eating its own tail. The ouroboros entered Western tradition via ancient Egyptian iconography and the Greek magical tradition. It was adopted as a symbol in Gnosticism and Hermeticism and, most notably, in alchemy.

(Wikipedia)

Step 8: Recursion: See Recursion

We hope you are enjoying this month's HackerBox adventures into electronics, computer technology, and hacker culture. We aim to curate a challenging and rewarding experience of learning through experimentation and exploration. Thank you for joining us on this journey.

Reach out and share your success in the comments below. Email support@hackerboxes.com anytime with questions or whenever you need some help.

Hungry for more? Surf over to HackerBoxes.com and join us as a monthly HackerBox subscription member. You'll get a cool box of hackable gear delivered right to your mailbox every month and you'll enjoy a generous member discount.

Please consider sharing this free Instructable with others who may be interested in learning about these subjects. Word of mouth advertising is the greatest compliment that we can receive. We sincerely appreciate your support.