HackerBox 0063: Samadhi

Introduction: HackerBox 0063: Samadhi

Greetings to HackerBox Hackers around the world!

HackerBox 0063 features two different SAMD ARM Core Development Boards. The SAMD21-powered Adafruit QT Py and the SAMD51-powered Mini SAM M4 can both be programmed with either CircuitPython or using the Arduino IDE. Explore the ESP8266 Wemos D1 Mini to run code directly on its Tensilica RISC core or configure the ESP8266 as a communication peripheral to provide WiFi connectivity for another microcontroller. Also, study remote wireless keystroke injection attacks and experiment with virtual machine technology.

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

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.

Supplies

This Instructable contains information for getting started with HackerBox 0063. The full box contents are listed on the product page for HackerBox 0063 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 with a $15 discount, you can subscribe at HackerBoxes.com and join the revolution!

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 Deluxe Starter Workshop for a set of basic tools and a wide array of introductory activities and experiments.

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.

Step 1: Samadhi

Pondering a theme related to our two SAMD microcontrollers for this box...

The Mini SAM M4 Dev Board features the ATSAMD51G19
The Adafruit QT Py features the ATSAMD21E18

We can consider what SAM stands for:

  • SAM
  • Smart ARM MCU
  • Smart Advanced RISC Machine MCU
  • Smart Advanced RISC Machine Microcontroller Unit
  • Smart Advanced Reduced Instruction Set Computing Machine Microcontroller Unit

OK, well that's a mouthful - probably best to just leave it at SAM, or for a bit of thematic poetry, we could imagine that SAM is short for SAMADHI.

Derived from the root sam-a-dha, meaning "to collect" or "bring together", samadhi is often translated as "concentration" or "unification of mind". Samadhi is a state of profound and utterly absorptive contemplation of the Absolute that is undisturbed by desire, anger, or any other ego-generated thought or emotion. It is a state of joyful calm, or even of rapture and beatitude, in which one maintains full mental alertness and acuity.

Nice.

Step 2: Mini SAM M4 Development Board

The Mini SAM M4 Development Board is based on the Microchip SAMD51G 32-Bit ARM Cortex-M4F MCU running at 48Mhz. It was designed by Ben Shockley who was inspired by the classic 1980s "spaceman" LEGO minifigure.

The board features a microUSB port interface for programming and power. Its header pins are smaller than usual (0.050 inch instead of the usual 0.1 inch) and breakout six analog pins (including a true analog output) and several digital pins including some dedicated I2C, SPI, and UART connections.

There are two LED indicators. The “Built-In” LED is located on the reverse side of the board and shines through the spaceship on the front of the board when illuminated. The second is an APA102 RGB LED.

There are two buttons. One is tied to RESET and the other is user programmable.

A 2MB Quad-SPI flash memory chip provides plenty of space for CircuitPython as well as user code. Mini SAM comes pre-loaded with CircuitPython

Ben Shockley's Mini-SAM Repository

Circuit Python for the Mini SAM M4

Enabling SAMD Support in the Arduino IDE

Step 3: Mini SAM Breadboard Backpack

The Mini SAM M4 Development Board features header pins that are smaller than usual. The headers are 0.050 inch pin pitch, which is half of the usual 0.1 inch pitch that we're all used to. In other words, they are twice as dense. While these smaller headers help make the Mini SAM super tiny and cute, the denser pitch is not compatible with solderless breadboards or jumper wires. Until, that is, we slap a Breadboard Backpack onto Mini SAM's space suit!

This cool PCB was also originally designed by Ben Shockley who was kind enough to help us run a batch for this HackerBox. Thank you Ben!

Adding the included headers to the Backpack PCB is fairly self-explanatory, just make sure the board is not upside down. The 0.1 inch headers (the bigger ones) go on the side of the board where the silkscreen word "MINI" is on SAM's lower abdomen. We can call this the bottom of the Backpack PCB since the 0.1 inch headers will face down while using a solderless breadboard.

The smaller headers go on the side of the board where the silkscreen word "MINI" is closer to SAM's neck. We can call this the top of the Backpack PCB. The smaller headers can be soldered with the female headers on SAM's back and the male headers on the top of the Backpack PCB (as shown in the photo). Or they can go the other way around, whichever you prefer. SAM doesn't mind at all. You can even do some one way and some the other way as long as the connecting pairs are opposite. Go nuts!

Step 4: Adafruit QT Py

The Adafruit QT Py is a tiny development board based on the powerful ATSAMD21E18 chip. That SAMD features a 32-bit Cortex M0+ 32 bit processor core running at 48MHz. While using very little power, the QT Py offers amazing processing performance and ease of use. The QT Py features the same size, form-factor, and pin-out as Seeed Xiao module. Given its tiny size, we can easily pop one into any small project.

QT Py features:

  • ATSAMD21E18 32-bit Cortex M0+
  • 48 MHz 32 bit processor
  • 256KB Flash
  • 32 KB RAM
  • USB Type C connector
  • STEMMA QT plug-n-play connector
  • Native USB supported by every OS
  • RGB NeoPixel LED
  • 11 GPIO Pins
  • Works with Arduino IDE or CircuitPython

GO HERE for the usual amazing array of online documentation from Adafruit.

Step 5: Wemos D1 Mini ESP8266

The Wemos D1 Mini Module features the ESP8266 SOC. The ESP8266 SOC includes a microcontroller core, WiFi 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. For example, we can connect a SAMD board and an ESP8266 module to add WiFi connectivity to the SAMD.

ESP8266 and Arduino IDE

The Wemos D1 Mini Module can be programmed using Arduino tools that you probably already have.

To add ESP8266 support within the Arduino IDE, follow Steps 1-5 of this tutorial.

Then, under Tools>Board, select "WEMOS D1 R2 & mini"

And open an example sketch:

File > Example > ESP8266 > Blink

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

As usual, 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. Cool beans!

Step 6: BadUSB MalDuino W - Remote WiFi Keyboard

WifiDuck and its evolution into MalDuino W are examples of BadUSB devices. They can emulate a USB keyboard just like the original USB Rubber Ducky with the added feature of being controlled remotely over WiFi. Once assembled, you can simply plug one into a system, connect to its Wi-Fi network, and manage all scripts from within the web interface. Such devices use the Ducky Script language that Hak5 introduced for use with the USB Rubber Ducky.

WiFiDuck uses an ATmega32U4 connected to an ESP8266

MalDuino W uses an ARM Cortex-M0 connected to an ESP8266

Use this knowledge for good and not evil: BadUSB devices work because the keyboard on a computer is generally a trusted device. You plug it in and it can start typing right away. While a human might not type as fast, an automated BadUSB device can press hundreds of keys per second. Experimenting with BadUSB devices helps us understand the threats of keystroke injection attacks. Such devices can also be used to automate administrative tasks.

Learn to defend against BadUSB attacks.

Step 7: Virtual Machines

What is a virtual machine?

Why do I need one?

How can I set one up for free right now?

VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for enterprise as well as home use. Not only is VirtualBox an extremely feature rich, high performance product for enterprise customers, it is also the only professional solution that is freely available as Open Source Software under the terms of the GNU General Public License (GPL).

Presently, VirtualBox runs on Windows, Linux, Macintosh, and Solaris hosts and supports a large number of guest operating systems. VirtualBox is being actively developed with frequent releases and has an ever growing list of features, supported guest operating systems and platforms it runs on. VirtualBox is a community effort backed by a dedicated company: everyone is encouraged to contribute while Oracle ensures the product always meets professional quality criteria.

Step 8: Trust Your Technolust

We hope you are enjoying this month's HackerBox adventure into electronics and computer technology. 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 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.

4 People Made This Project!

Recommendations

  • Eggs Challenge

    Eggs Challenge
  • Build a Tool Contest

    Build a Tool Contest
  • Remote Control Contest

    Remote Control Contest

33 Comments

0
Alvenchipmunk
Alvenchipmunk

Question 1 year ago on Step 1

Has anyone been able to run the NEOPixel Blink example on their QT_Py? I'm running SAAdafruit CircuitPython 6.3.0 on 2021-06-01; Adafruit QT Py M0 with samd21e18
M. I can't get this to change the internal NEOPixel to flash RED

This is the code per example:

import time
import board
import neopixel

pixels = neopixel.NeoPixel(board.NEOPIXEL, 1)

while True:
pixels.fill((255, 0, 0))
time.sleep(0.5)
pixels.fill((0, 0, 0))
time.sleep(0.5)

0
tednunn
tednunn

Tip 1 year ago on Step 8

TIP: If you're interested in programming the RGB LED on the Mini SAM M4, install the Adafruit DotStar library in Arduino IDE. The library provides some examples, including "ItsyBitsyM4Onboard" which flashes as-is to the Mini SAM and cycles the RGB LED colors.

The key information for Mini SAM is:
#define DATAPIN 8
#define CLOCKPIN 6

0
jthiele8
jthiele8

1 year ago

Hi, the link for setting up the Arduino IDE for SAMD boards goes to a page describing how to set up the IDE for Adafruit boards, but not the Mini Sam. Is the Mini Sam functionally equivalent to one of the Adafruit boards and if so, which one?

I did find this page (https://minifigboards.com/pages/arduino-setup) which seems to be extremely similar to the Adafruit page, but with a different URL for the board definitions. Alas, that file does not seem reachable and attempting to access it via a browser triggers a redirect to a corporate page.

Any suggestions on programming the Mini Sam from the Arduino IDE?
Thanks!

20210409_165532.jpg
0
tednunn
tednunn

Reply 1 year ago

On the https://minifigboards.com/pages/arduino-setup page, just right-click on the "Mini SAM Board Definition" link and copy/paste the URL to the Additional Board Manager URLs box (separating from any existing links with a comma).

Capture1.JPG
0
autotech
autotech

Question 1 year ago on Step 6

I have been unable to get a program to load to the mini-sam. Whar board do i select, as there is not a "mini-sam" board to select?

0
Alvenchipmunk
Alvenchipmunk

1 year ago

I can't QT-Py to run simple program NEO-Pixel after loading the additional files required and the new example program by Kattni on ADAFruit. Can someone help me? Maybe even direct me to a forum to get help? I'm trying to folow ADAFruit example using CiruitPython and running the sample code loaded with the MU Editor.

0
Alvenchipmunk
Alvenchipmunk

Reply 1 year ago

Blink example for boards with ONLY a NeoPixel LED (e.g. without a built-in red LED).Includes QT Py and various Trinkeys.Requires two libraries from the Adafruit CircuitPython Library Bundle. Download the bundlefrom circuitpython.org/libraries and copy the following files to your CIRCUITPY/lib folder:* neopixel.mpy* adafruit_pypixelbuf.mpyOnce the libraries are copied, save this file as code.py to your CIRCUITPY drive to run it.import timeimport boardimport neopixelpixels = neopixel.NeoPixel(board.NEOPIXEL, 1)while True: pixels.fill((255, 0, 0)) time.sleep(0.5) pixels.fill((0, 0, 0)) time.sleep(0.5)

0
Alvenchipmunk
Alvenchipmunk

Reply 1 year ago

I ran REPL from the Mu Editor Serial I got the desired results. Does this mean my QT-Py is working just fine but the sample code example for NEOPixel is not working?

>>> import board

>>> dir (board)

['A0', 'A1', 'A10', 'A2', 'A3', 'A6', 'A7', 'A8', 'A9', 'D0', 'D1', 'D10', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'I2C', 'MISO', 'MOSI', 'NEOPIXEL', 'NEOPIXEL_POWER', 'RX', 'SCK', 'SCL', 'SDA', 'SPI', 'TX', 'UART']

>>>

0
stephen.peters
stephen.peters

Question 1 year ago

Hello there. I won't get to this fine now for a while, I do like to dream. Any hip project suggestions for us? Particularly ones with step by step instructions for us n00bz?

0
CrittersWeb
CrittersWeb

Answer 1 year ago

I agree. It's good that Hackerboxes at least puts links in their instuctables, but sometimes the information behind the links is far too dense and foreign. It would be nice if they included at least one Hackerboxes centered example case for all the hardware they provide. Even when they link to information sources, I still don't know what to do with it or how to get started. There's a lot of Hackerboxes hardware I haven't tried yet because I didn't have time to figure out the resources they link to.

0
netelder
netelder

Reply 1 year ago

FWIW, when I get a box that is too advanced for me, I work with it a bit and then put it aside for a few months. Usually I learn enough from later boxes (and other work) to take another go at the advanced box. It's *very* satisfying to see that I have grown enough to enjoy something that stumped me just a few months earlier!

0
cosromx
cosromx

Reply 1 year ago

And that why I unsubscribed

0
HackerBoxes
HackerBoxes

Reply 1 year ago

Each HackerBox should have aspects that speak to a range of different ability levels, but the range is not infinite. Our goal is to meet a good number of members where they are and stretch them a bit beyond that - with different stretches each month. We don't want to entirely overwhelm someone who is a (hard working) beginner and we don't want to totally bore a seasoned wizard with spoon-fed everything. Yes, aspects of a box that will entertain someone with a lot of experience might be mostly unattainable for a beginner, but that beginner might enjoy digging deep on some other aspect of that same box, which might bore the more experienced user. Or the beginner might stick it out, ask for help, and see what they can pull off. Every aspect of every box will never speak the same meaning for every member. That would be impossible. White belts and black belts can train in the same room, but they are working on different skills. That said, if even the more basic aspects are frustrating you and you do not wish to ask for help or struggle, there are a lot of other fun offerings out there that might fit your level and needs. For example, plenty of DIY electronics products are self-contained and provide more explicit hand-holding. Shop around. Check out all the different options from Adafruit. Every product is not for every consumer for all times, so figure out what works for you where you are right now, get to work, and have fun! You're always welcome to return to HackerBoxes when you're ready. We aren't going anywhere. However, if the most encouraging words you have for a (self described) n00b looking for new ideas are to simply discourage them, then you should definitely go somewhere. :)

0
stephen.peters
stephen.peters

Reply 1 year ago

Something I'm hoping to figure out is how to organize all the little bits that have been showing up. Somethings are good in a separate box, but other things are more general use that it would be good to lay hands on. I may need to get a tackle-box like thing, put a number on each compartment indexed to a web page that says, "compartment 6 has this gizmo and here's a link what the heck it does".

0
stephen.peters
stephen.peters

Reply 1 year ago

Personally I do well with clear instructions, the Adafruit snow globe which I learned about through Hackerboxes was a neat project to do: https://tikimojo.com/2021/02/i-made-a-thing/

I'm currently collecting the parts to build a raspberry pi controlled sprinkler system - really, just a way to press a button on a web page to turn a valve on and off :-)

Could certainly do the same task with Aurdino, but I think for me the rPi is a shorter throw, and also given how things involving computers tend to fail, I think I'll need to have it also run a web cam so we can see if the sprinkler actually turned off. Don't want the sprinkler to run for two weeks if something goes wrong :-)

0
DIY_Maker_Dad
DIY_Maker_Dad

1 year ago

I've been unable to get the second file for the Malduino to load to the QT Py. I've tried on both Linux and MacOS with no success. Any one else having similar issues or have tips on how to get it loaded?

0
jrbski
jrbski

Reply 1 year ago

What is happening when you try to load the second file? I have had some issues with the drive conflicting with Acronis backup software... the Acronis drivers kept trying to connect to the 'D;\' drive. The fix was to stop Acronis, or change the drive letter, and I was then able to copy the UF2 file successfully. Once the QTPy shows up as a second keynboard, you know it was successful. As noted below, the LED on the QT Py is a different pin, so you can't tell its working from that.

I recompiled the source, and have the LED working, but the ESP interface is not (yet).

0
DIY_Maker_Dad
DIY_Maker_Dad

Reply 1 year ago

When I try to load the second UF2, I get an error message "error opening directory MalW, permission denied." I get a similar error message trying with both MacOS and a Linux OS.

I've updated the user permissions to make sure the user can access the com port as a member of the dialout group in Linux and has sudo rights.

I've tried copying the file both through the GUI file manager and through a terminal. Each time I get the same error message.

0
jrbski
jrbski

Reply 1 year ago

Unfortunately I haven’t used Linux/OS X for circuit python hardware to date, but it sounds like the issue is related to the ‘virtual’ usb drive you need to copy the second UF2 into. I would expect the ‘Malw’ drive to show up in file manager as a usb drive would, or under /media. That is the drive u should need access to write to, and u shouldn’t need to use the com port. I would expect a ‘sudo cp’ to /media would ensure the second UF2 file would be copied assuming the usb MalW ‘drive’ mounts properly.