A belated look at HackerBox 63: SAMD

Earlier this year, I received HackerBox 63: Samadhi. The instructable for HackerBox 63 has some pretty good information about getting started with the kit. This box revolved around two SAMD ARM Core Development Boards. Plus, it included an ESP8266 Wemos D1 Mini, perfect for adding WiFi capabilities for other microcontrollers. This post will briefly go over the contents of the HackerBox and share the code I used to do basic testing of the boards.

Adafruit QT-PY

Adafruit QT-PY

The Adafruit QT-PY features an ATSAMD21E18 chip on a tiny circuit board. Adafruit has a pretty dang good learn guide about the QT-PY here. Since this is one of my favorite cosplay boards, I’ve already shared a few posts about the QT-PY. Plus, I will share a post highlighting this board being used to power some My Hero Academia cosplay items for my son soon. So, for now, I’ll say I love this little board and share my version of blink for the QT-PY.

The CircuitPython code below will run blink, including sending High and Low messages through the serial monitor.

import time
import board
import neopixel
 
pixels = neopixel.NeoPixel(board.NEOPIXEL, 1)
 
while True:
    pixels.fill((255, 0, 0))
    print("High")
    time.sleep(0.5)
    print("Low")
    pixels.fill((0, 0, 0))
    time.sleep(0.5)

And here is a video of the QT-PY running that script:

Mini SAM M4 Development Board

Mini SAM M4

Up next is the Mini SAM M4 Development Board featuring the Microchip SAMD51G 32-Bit ARM Cortex-M4F MCU. Ben Shockley created this very cool LEGO-inspired board. I gotta say I really love this little dev board. Even though the tiny .05 inch header pins going along the arms and legs were a pain to soler in, it just looks dang cool! The board also came with a ‘backpack’ which allows it to be mounted to a solderless breadboard.

The board came preloaded with CircuitPython and with its own version of blink. On the underside of the board is an LED that shows through a spaceship-shaped hole in the board. When the button under the left leg is pushed, that LED will light up through the board. This is a pretty nifty way to test the functionality of the LED and the button.

Here is the code that came installed on the board.

import board
import digitalio
import time
import adafruit_dotstar

led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT

button = digitalio.DigitalInOut(board.BUTTON)
button.direction = digitalio.Direction.INPUT
button.pull = digitalio.Pull.UP

dotstar = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
dotstar[0] = (0,0,255)

while True:
    dotstar[0] = (0,32,0)
    if button.value:
        led.value = True
    else:
        led.value = False

As you can see in the code, the button pressed will turn the dostar LED on when the button is pressed. Here is a video showing this code in action.

Blink on the Mini SAM M4 Development Board

Wemos D1 Mini ESP8266 Module

Wemos D1 Mini ESP8266 Module

Up last is the Wemos D1 Mini Module featuring an ESP8266 SOC. This board can run code on its own. But it is probably better utilized to add WiFi capability for other microcontrollers that need to get network access. This device does not support CircuitPython. Plus, it is not natively supported in the Arduino IDE. I already had support added for this board to my IDE. If needed, this site can show how to add the ESP8266 board to the Arduino IDE.

Normally I would include testing serial communication while doing blink on a board. However, the built-in LED is connected to GPIO01, which also happens to be the TX pin for serial communication. That means while the built-in LED is being used, serial communication can’t happen.

Here is the example blink sketch for the ESP8266:

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
  // but actually the LED is on; this is because
  // it is active low on the ESP-01)
  delay(1000);                      // Wait for a second
  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  delay(2000);                      // Wait for two seconds (to demonstrate the active low LED)
}

And here is the board running blink. Nothing too exciting.

Blink on the Wemos D1 Mini ESP8266

Controlling the Mini SAM M4 with a cell phone

To test the hardware out, I thought I would like to use WiFi to turn the LED on the Mini SAM M4 on and off. To do this, I breadboarded the Mini SAM M4 and the Wemos D1 Mini Module on the same half-breadboard. I also added an LED and resistor to the Mini SAM so I could test an external LED simultaneously.

Several protocols could be used to get the two microcontrollers to communicate with each other. But this is a basic test with only two states: on or off. So I just decided to use a GPIO connection between the two to pass on logic high and logic low.

Before hooking up the circuit, I downloaded a simple webserver to the Wemos D1 Mini ESP8266 Module. To do this, I used the code provided by Rui Santos on Random Nerd Tutorials. The only part of that code that I changed was to set up WiFi with my SSID and password. Before proceeding, I even hooked a couple of LEDs up to D1 and D2 to test the web interface. It worked beautifully.

On the Mini SAM, I basically just added a second switch to the code I used previously in this post. Now instead of the onboard button being used, two digital pins are being used as buttons.

import board
import digitalio
import adafruit_dotstar

led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT

led2 = digitalio.DigitalInOut(board.D5)
led2.direction = digitalio.Direction.OUTPUT

button = digitalio.DigitalInOut(board.D3)
button.direction = digitalio.Direction.INPUT
button.pull = digitalio.Pull.UP

button2 = digitalio.DigitalInOut(board.D4)
button2.direction = digitalio.Direction.INPUT
button2.pull = digitalio.Pull.UP

dotstar = adafruit_dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
dotstar[0] = (0,0,255)

while True:
    dotstar[0] = (0,32,0)
    if button.value:
        led.value = True
    else:
        led.value = False
    if button2.value:
        led2.value = True
    else:
        led2.value = False

I then had to wire the boards together. The connections I had to make:

  • GND on the Mini SAM to GND rail on the breadboard.
  • 3V3 on the Mini SAM to the POS rail on the breadboard.
  • G on the 8266 module to the GND rail on the breadboard.
  • 3V3 on the 8266 module to the POS rail on the breadboard.
  • Pin D3 on the Mini SAM to Pin D1 on the 8266 module.
  • Pin D4 on the Mini SAM to Pin D2 on the 8266 module.
  • Pin D5 on the Mini SAM to a 220-ohm resistor.
    • The other end of the resistor to the Anode of the LED.
    • The cathode of the LED to the GND rail on the breadboard.
  • USB power connection to the Mini SAM.

Here is a look at what I breadboarded to test this out. Please note: I downloaded the appropriate code to each of the microcontrollers before hooking this circuit up. DO NOT apply power to the 8266 through USB after this is hooked up. That would not be good. The way I have this setup, the 8266 gets power from the Mini SAM.

SONY DSC

Below is a fritzing of the circuit I created. Just pretend the generic IC pins match up with the appropriate pins on the Mini SAM M4.

At this point, it is a simple matter of bringing up the 8266 web interface from a network-connected device. In my case, I used the browser on my phone to bring up the interface using the 8266’s IP address. I got the address earlier when setting it up.

Here is a short video demonstrating the web interface on my cell phone to turn the LEDs on and off. When I hit the top button, it turns the little rocket LED on and off. When I hit the second button, it turns the external LED on and off.

I think this was a quick and easy demonstration to see how handy the 8266 can be adding WiFi to microcontroller dev boards that don’t already have WiFi included. As I stated earlier, if I passed actual data between the boards, I probably would have used a protocol such as I2C, SPI, or even UART.

The rest of the kit

HackerBox 63 came with a few additional goodies. Here is what else was included:

  • Reference cards showing the pinout for the Mini SAM M4 on one side and the QT-PY on the other.
  • Wemos D1 Mini Prototype Shield – I didn’t use this; perhaps I will for another project.
  • Micro-to-C USB Adapter.
  • Female DuPont Jumper Wires.
  • Collectible 24K Gold Plated Bitcoin.
  • Crash Override and Hoodie Hacker Stickers.

To me, the best of the rest was the reference cards. These cards are handy as heck when working with microcontrollers. I have a stack of them I keep at my desk to help ensure I’m connecting things into the right pins while working on projects.

Pretty good kit

Overall I’m quite pleased with HackerBox 63. The main benefit of this kit to me was getting the Mini SAM M4 and playing with it. It would be kind of cool to make a Lego-inspired animatronic of some sort powered with the Mini SAM M4.

Leave a Reply