HackerBox 0044: PCB 123

3,469

7

26

Greetings to HackerBox Hackers around the world! HackerBox 0044 brings us PCB Design, AVR Device Programming, Serial RGB LED Applications, Pro ESP32 WiFi OLED Development, and much more. This Instructable contains information for getting started with HackerBox 0044, which can be purchased here while supplies last. If you would like to receive a HackerBox like this right in your mailbox each month, please subscribe at HackerBoxes.com and join the revolution!

HackerBoxes is the monthly subscription box service for enthusiasts of electronics and computer technology - Hardware Hackers - The dreamers of dreams.

HACK THE PLANET

Step 1: Content List for HackerBox 0044

  • Exclusive HackerBox Zipper Toolkit
  • Pro ESP32 with OLED and WiFi
  • Addressable RGB LEDs Round 8mm
  • ATtiny85 Microcontrollers
  • ATtiny85 Development Board
  • Solderless Breadboard 400 Point
  • Exclusive HackerBoxes Prototype Board
  • Bundle of Various Length Jumper Wires
  • Exclusive SIMON SAYS Badge Kit
  • Snowflake 18-in-1 Multitool
  • Tux Linux Decal
  • PentesterLab Decal

Some other things that will be helpful:

  • Soldering iron, solder, and basic soldering tools
  • Computer for running software tools

Most importantly, you will 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.

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 really appreciate your taking a few minutes to read the FAQ.

Step 2: Pro ESP32 With WiFi and OLED

Features:

  • ESP32 Tensilica Dual Core Processor
  • Clocked at 240 MHz
  • 520 SRAM
  • 802.11 b/g/n Wi-Fi Transceiver
  • Bluetooth dual-mode integrated traditional and BLE low-power
  • 4MB (32 M bit) Flash
  • 0.96-inch White OLED Display
  • Lithium battery charging circuit and interface
  • USB to serial bridge chip and MicroUSB port

The ProESP32 can be powered up by plugging it into a USB port. At that point, it will start running the pre-programmed OLED demo.

To (re)program the ESP32, we'll use the Arduino IDE. If you don't already have the IDE installed, get it here.

Next, follow the process for adding ESP32 Board Support into the Arduino IDE.

Next, instal this OLED display library into the Arduino IDE.

A good sketch to start with is the example SD1306SimpleDemo. Open that up and change the parameters passed into the display constructor for the OLED pins used on the module:

SSD1306 display(0x3c, 4, 15);

Also, flick the OLED reset pin (on I/O 16) by adding the following two lines just before the display.init() call in the setup function:

pinMode(16, OUTPUT);
digitalWrite(16, 1);

Program the modified sketch into the ESP and the OLED demo should appear.

Other projects to consider for the Pro ESP32 OLED module include:

Hacker Arsenal WiNX Portable

NTP Clock

ChiliPeppr on ESP32 for Lua

MicroPython on ESP32

Step 3: Serial Addressable RGB LEDs

Serial Addressable LEDs can be chained together and controlled by ONE SINGLE PIN. Simply connect an I/O pin to the first LED's "Data In" port and then connecting that LED's "Data Out" port to the next LED's "Data In" and so forth.

Grab one or both of these libraries to use the APA106 RGB LEDs with the ESP32, the ATtiny85, or any other Microcontroller of your choice:

Adafruit NeoPixel Guide

FastLED

A huge variety of other form factors of these sort of LEDs are available from Adafruit and elsewhere. They are a great option for any indicator or visual entertainment needs.

Step 4: ATtiny85 Microcontroller

ATtiny (also known as TinyAVR) are a subfamily of the popular 8-bit AVR microcontrollers like those used in various Arduino boards such as the UNO and NANO. ATtiny MCUs typically have fewer features, fewer I/O pins, and less memory than other AVR series chips, but they are very tiny and easy to use.

The LED on the Pluggable Development Board is a breakout for the ATtiny devices. It features an ISP header for programming the MCU. Pin 6 (Arduino I/O 1) is wired to an LED. A MicroUSB port is wired to power the module and also support use as a Digispark if the microcontroller is programmed with the micronucleus bootloader.

Step 5: Programming ATtiny With USB ASP

When a new, stock ATtiny85 chip (like the two 8pin DIP chips in this box) is purchased from Mouser or DigiKey, it is completely blank. The chips do not have micronucleus or any other bootloader on on them. They need to be programmed. For example using an ISP (in-circuit programmer).

USBasp is a USB in-circuit programmer for Atmel AVR controllers. It simply consists of an ATMega88 or an ATMega8 and a couple of passive components. The programmer uses a firmware-only USB driver, no special USB controller is needed.

Insert the ATtiny85 into the Plugable Development Board (mind the pin one indicator) and wire the board up the USBasp as shown here.

Add ATtiny support to the Arduino IDE (see details at High-LowTech):

Under preferences, add an entry to the list of board manager URLs for:

https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

Under Tools->Boards->Board Mangers, add the board manager package from ATtiny by David A. Mellis.

This will add ATtiny boards to the board list supporting settings for"

Board: ATtiny25/45/85
Processor: ATtiny85
Clock: Internal 1 MHz

[IMPORTANT NOTE: Never set the clock to EXTERNAL unless the chip actually has an external clock source.]

Load the code example for "blink"

Change LED_BUILTIN to 1 in three places in that sketch and upload it to the ATtiny85 using USBasp.

The LED on the Pluggable Development Board should now blink.

Step 6: Programming ATtiny With Arduino

Any Arduino (UNO, NANO, or otherwise) can be used as an ISP (in circuit programmer) to program other Arduinos or even blank, stock AVR microcontrollers. Details for ArduinoISP can be found in the Arduino online docs under "Use Arduino as ISP".

Step 7: Programming ATtiny With ESP32

Just like an AVR-Based Arduino, an ESP32 module (such as the Pro ESP OLED) can be used as as an ArduinoISP. This modified version of ArduinoISP is available for use on an ESP32, which can be wired as shown here.

Step 8: Creating Printed Circuit Boards

A printed circuit board (PCB) mechanically supports and electrically connects electronic components or electrical components using conductive tracks, pads and other features etched from one or more sheet layers of copper laminated onto and/or between sheet layers of a non-conductive substrate. Components are generally soldered onto the PCB to both electrically connect and mechanically fasten them to it. (Wikipedia)

Screen captures were saved while creating the SIMON SAYS PCB included in this box. They are broken out into the following videos:

SIMON SAYS PCB (Part 1)

SIMON SAYS PCB (Part 2)

These videos feature a PCB created in EAGLE. Keep an eye out for a similar example video using KiCAD in the future.

Even more detailed resources:

Hackaday's Series on Creating a PCB in Everything

Inside a Huge PCB Factory

Contextual Electronics PCB Tutorial Series

Example PCB Manufactures: PCBWay, OSH Park, JLCPCB, etc...

Step 9: Assemble SIMON SAYS Badge Kit

Kit Contents:

  • Exclusive SIMON SAYS PCB
  • Exclusive SIMON SAYS Overlay Decal
  • ATtiny85 Microcontroller
  • 8pin DIP Socket
  • Tactile Momentary Buttons
  • APA106 Addressable RGB LEDs
  • Piezo Buzzer
  • Right Angle Slide Switch
  • CR2032 Coin Cell Clips
  • CR2032 Coin Cells

Assembly Steps:

  • DO NOT POPULATE THE BUZZER YET **
  • Solder Coin Cell Clips - tinning all six pads
  • Remaining components are populated on the front of the PCB
  • Position Overly Decal onto PCB with red in upper left nearest Chip
  • Puncture LED and Buzzer holes through decal from rear of PCB with a wire
  • Note that the flat edge of the RGB LEDs face the Chip
  • Solder Switch, LEDs, DIP Socket (without Chip), and buttons into place

** The buzzer is not populated yet because it shares the RESET pin of the Chip, so it not connected until later in the programming/assembly process.

Step 10: Program SIMON SAYS Badge Kit

Burn the attached "HBSimonBadge.ino" sketch into an ATtiny85 chip using the Pluggable Development Board.

In oder to use the NeoPixel library, we need to bump the internal clock rate from 1MHz to 8MHz under Tools->Clock. Remember to never set the clock to external unless an actual external clock is present.

Whenever you make a change to the clock rate you have to perform a "Burn Bootloader" operation under tools, so do that now too.

The sketch comes up in a flash "attractor mode" until one of the button is held down for a second or two, then one single LED will blink indicating that the SIMON Memory Game has begun. Try to copy the pattern as it gets longer and longer. Once the piezo buzzer functionality is added in the next step, the game becomes even more engaging.

Step 11: Using ATtiny85 Pin One As I/O for Buzzer

Only once the simon sketch is correctly programmed and appears to be properly functioning do we disable the RESET pin allowing it to be used as an I/O pin for the Buzzer.

We only get to do this once and then the chip cannot be reprogrammed again, so be careful!

To disable the RESET pin, use avrdude with fuse parameters set for ATtiny85 default but with 8X clock divider OFF and RESET Disable ON.

Details for this (including a link to a nice fuse calculator) can be found here.

In our example, we went to a terminal or command window and entered:

avrdude -c arduino -p attiny85 -U lfuse:w:0xe2:m -U hfuse:w:0x5f:m -U efuse:w:0xff:m

Once avrdude reports success, but the ATtiny85 back into the SIMON and make sure everything still works. If so, you can now solder the Piezo Buzzer onto the board with the POS+ marking oriented away from the chip. Prepare to enjoy low-fi-audio delights while you play!

The detailed link above also explains how to "unbrick" the chip so that is can actually be programmed again after the REST pin is disabled. However, this is a bit of pain (requiring connecting up of a "high voltage programmer") so we recommend just making sure the ATtiny85 is programmed as you wish before disabling the RESET pin at soldering in the buzzer.

If you notice any glitchy problems with the MCU, make sure the socket seating is solid (bend the pins in/out a bit to add tension if necessary). If that doesn't do the trick, you can tack a 0.1uF ceramic cap between the chip's power and ground pads on the back of the PCB. We have not found the capacitor to be necessary, but having it there is technically considered good practice. On that note, you can also place a larger capacitor between VCC and GND as a board-level power smoothing measure.

Step 12: PentesterLab

Check out PentesterLab... Thanks for the stickers, guys!

A penetration test, colloquially known as a "pen test" or "pentest", is an authorized simulated cyberattack on a computer system, performed to evaluate the security of the system. The test is performed to identify both weaknesses (aka vulnerabilities) and strengths, enabling a full risk assessment to be completed. (Wikipedia)

The National Cyber Security Center, describes penetration testing as, "A method for gaining assurance in the security of an IT system by attempting to breach some or all of that system's security, using the same tools and techniques as an adversary might."

Step 13: Hacklife++;

We hope you have enjoyed this month's HackerBox adventure into electronics and computer technology. Reach out and share your success in the comments below or on the HackerBoxes Facebook Group. Also, remember that you can email support@hackerboxes.com anytime if you have a question or need some help.

What's Next? Join the revolution. Live the HackLife. Get a cool box of hackable gear delivered right to your mailbox each month. Surf over to HackerBoxes.com and sign up for your monthly HackerBox subscription.

Share

    Recommendations

    • Stone Concrete and Cement Contest

      Stone Concrete and Cement Contest
    • Sew Tough Challenge

      Sew Tough Challenge
    • Games Contest

      Games Contest

    26 Discussions

    0
    None
    jer502

    1 day ago

    I'm trying to program the ATtiny and using a USBasp Programmer. When I try to upload the blink sketch I get this error.

    Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "ATtiny25/45/85, ATtiny85, Internal 1 MHz"
    Build options changed, rebuilding all
    Sketch uses 678 bytes (8%) of program storage space. Maximum is 8192 bytes.
    Global variables use 9 bytes (1%) of dynamic memory, leaving 503 bytes for local variables. Maximum is 512 bytes.
    avrdude: Warning: cannot open USB device: Function not implemented
    avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'
    avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'
    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.

    What did I screw-up/miss?
    3 replies
    0
    None
    HackerBoxesjer502

    Reply 1 day ago

    Is your wiring like shown in Step 5? Unfortunately the USBasp and the Pluggable ATtiny board do not just plug together straight-across (nor using a ribbon cable).

    0
    None
    jer502HackerBoxes

    Reply 7 hours ago

    The pinout for the USBasp is slightly different(I think). The ground pins are 3, 8 or 10 not 4 like in the picture. They are numbered left to right going down each row and not clockwise like on a chip. The chart I found. https://www.google.com/url?sa=i&rct=j&q=&esrc=s&so...

    Everything else matched up. Made the change and still got the error. I did some internet research and most seems to point to installing this : https://zadig.akeo.ie/
    and install this driver: libusbK

    https://rlogiacco.wordpress.com/2016/09/01/usbasp-...

    Is this safe? Has anyone used this? Thanks!

    0
    None
    jer502HackerBoxes

    Reply 1 day ago

    My programmer was/is slightly different but I followed wiring from the picture. Might the pins be different? I am getting power to both boards. I did notice one of the pins on the ATtiny board was also pushed out the back some and might need to check my soldering on the header pins.

    IMG_2275.JPGIMG_2276.JPGIMG_2277.JPGIMG_2274.JPG
    0
    None
    LED Freak 101

    2 days ago

    Newbie here, I am confused, where/what line number do I put, "SSD1306 display(0x3c, 4, 15);"? I see several places that say display etc for the ESP32.

    5 replies
    0
    None

    Yes, ESP32 Dev Module.
    For the OLED constructor, open the example sketch SD1306SimpleDemo.
    Find these two lines:

    // Initialize the OLED display using Wire library
    SSD1306Wire display(0x3c, D3, D5);

    CHANGE (not insert) the parameters that get passed in to match the pin assignments in our board:
    (0x3c, 4, 15)

    0
    None
    HackerBoxesHackerBoxes

    Reply 1 day ago

    BTW, look at the image of the "Pro ESP32 With WiFi and OLED" that has all the pin assignments labeled. Note the little red arrows on pins 4 and 15 along with the dark blue tags. These show how the ESP32 is wired internally to the OLED driver (I2C data SDA and clock SCL) via pins 4 and 15. That is where the values for the display constructor call come from: The documentation from the board manufacturer. FYI, constructor prototype:

    SSD1306Wire(uint8_t _address, uint8_t _sda, uint8_t _scl, OLEDDISPLAY_GEOMETRY g = GEOMETRY_128_64)

    (We don't pass in the geometry because our display uses the default 128x64)

    Whenever possible, try to figure out why things we are doing in code are related to the hardware, then it (hopefully) gets a little easier to make things work when you buy them on your own and they come with little or no information.

    0
    None
    LED Freak 101 HackerBoxes

    Reply 1 day ago

    I actually did notice that but it was still confusing to me where in the IDE it was to be written. In fact most of this is confusing to me. lol

    0
    None
    LED Freak 101 HackerBoxes

    Reply 1 day ago

    Okay so I did that but I get the error message, images.h: No such file or directory.

    1
    None
    evg2000

    3 days ago

    Any update on when the 3rd video will be available? thx

    2 replies
    0
    None
    HackerBoxesevg2000

    Reply 1 day ago

    There were some problems and lost files while editing the board layout video. We have recovered the original files and the video should get (re)edited and uploaded as soon as we can get back to it. In the meantime, check out some of the other linked tutorials on Eagle PCB layout. Thank you for your patience!

    1
    None
    evg2000evg2000

    Reply 1 day ago

    thanks for the update, looking forward to the conclusion as i was trying to follow along with the video.

    0
    None
    HowardW29

    1 day ago on Step 2

    Is anyone else having trouble getting the ESP32 board to show up on USB? I start the Arduino IDE, then plug in the micro USB cable on which I have connected the ESP32 board into my laptop, and then check the port configuration in the Arduino IDE and it is grayed out, as though nothing is connected.

    I'm using Linux on a Dell Latitude, and I've never experienced this issue before with any of the previous three Hacker Boxes projects I've tried. When I run 'dmesg' after plugging the cable and board into the machine, I see this:

    [ 92.831256] usb 2-2: new full-speed USB device number 2 using xhci_hcd
    [ 93.010283] usb 2-2: New USB device found, idVendor=10c4, idProduct=ea60
    [ 93.010285] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    [ 93.010286] usb 2-2: Product: CP2102 USB to UART Bridge Controller
    [ 93.010287] usb 2-2: Manufacturer: Silicon Labs
    [ 93.010288] usb 2-2: SerialNumber: 0001
    [ 93.545782] usbcore: registered new interface driver usbserial
    [ 93.545791] usbcore: registered new interface driver usbserial_generic
    [ 93.545799] usbserial: USB Serial support registered for generic
    [ 93.547332] usbcore: registered new interface driver cp210x
    [ 93.547348] usbserial: USB Serial support registered for cp210x
    [ 93.547379] cp210x 2-2:1.0: cp210x converter detected
    [ 93.548863] usb 2-2: cp210x converter now attached to ttyUSB0
    [ 93.634666] usb 2-2: usbfs: interface 0 claimed by cp210x while 'brltty' sets config #1
    [ 93.635296] cp210x ttyUSB0: cp210x converter now disconnected from ttyUSB0
    [ 93.635307] cp210x 2-2:1.0: device disconnected
    [ 98.572577] input: BRLTTY 5.5 Linux Screen Driver Keyboard as /devices/virtual/input/input22

    Something is going on, but it looks like the board is disconnecting prematurely or connecting to a device that the Arduino IDE is not expecting.

    1 reply
    0
    None
    HowardW29HowardW29

    Reply 1 day ago

    I found the problem on this. I think it is unique to SuSE. The braille tty driver somehow conflicts with the USB hardward on the ESP32 and snatches the device away from it when the ESP32 connects. I removed the brltty driver, and now I get the board connected :), but still don't seem to be getting any program action :(.

    0
    None
    evg2000

    2 days ago

    I had trouble using the reset pin. After trying many different things this is what I figured out:
    1. In arduino IDE set "show verbose output during: upload"
    2. Upload a sketch to the attiny using the programmer you will be using to set the fuses.
    3. Once it's done, copy the output and copy it into your favorite text editor. The line you care about is after "Global variables..."
    4. Remove the -v parameter and the -Uflash...
    5. Add "-U lfuse:w:0xe2:m -U hfuse:w:0x5f:m -U efuse:w:0xff:m" as shown in the original instructions.
    Here is what mine looks like:

    From Arduino output
    "C:\Users\charles\arduino-nightly-windows\arduino-nightly\hardware\tools\avr/bin/avrdude -CC:\Users\charles\arduino-nightly-windows\arduino-nightly\hardware\tools\avr/etc/avrdude.conf -v -pattiny85 -carduino -PCOM4 -b19200 -Uflash:w:C:\Users\charles\AppData\Local\Temp\arduino_build_388887/sketch_jul13a.ino.hex:i"

    What I ended up running:
    "C:\Users\charles\arduino-nightly-windows\arduino-nightly\hardware\tools\avr/bin/avrdude -CC:\Users\charles\arduino-nightly-windows\arduino-nightly\hardware\tools\avr/etc/avrdude.conf -pattiny85 -carduino -PCOM4 -b19200 -U lfuse:w:0xe2:m -U hfuse:w:0x5f:m -U efuse:w:0xff:m"

    I believe this should work for Mac or PC.

    Hopefully that helps.






    0
    None
    RichW36

    8 days ago

    In order to use the NeoPixel library, we need to bump the internal clock rate from 1MHz to 8MHz under Tools->Clock. Remember to never set the clock to external unless an actual external clock is present.. Well I am using a Arduino Uno to program the chip. I think I was able to burn the bootloader. But when it comes to the other sketch. There is no option to change the clock rate as stated above. So i am kinda lost at this point.

    2 replies
    0
    None
    HackerBoxesRichW36

    Reply 7 days ago

    Remember that programming the UNO (with arduinoISP) and programming the attiny85 target through the uno are two unrelated things with totally different IDE settings. When programming the UNO, there will be no setting under tools for the ATYTiny85, but then when you change the target to ATTiny85, there will be options specific to that "board" (not the UNO).

    0
    None
    kiltedkenHackerBoxes

    Reply 6 days ago

    Also, if you're using the UNO, you should, and I needed to, have a 1uF or 10uF capacitor between the ground and the reset pin, and mind the polarity of the capacitor. Once I did that, I was able to program.

    0
    None
    evg2000

    7 days ago

    I'm also getting 4 blue LEDs whether I have the chip plugged in or not. And yes it's programmed.
    Also, any idea when part 3 of the PCB tutorial will be posted?
    thanks