Swagbadge2021 Newcomers
Contents
Swagbadge for newcomers to electronics
Welcome! 👋
This guide is for everyone who likes the sound of what the swagbadge can do, or have an interest in learning about some hardware and electronics but just doesn't know where to start, or wants to learn as part of a community. We are here for you! This guide is intended to help you learn, through the development of the Swagbadge or Dagbadge. It (will) have lots of pointers out to resources on the internet you can use for further reference and learning.
Contents:
- What is a Swagbadge or a Dagbadge?
- The components on the badge
- Some electronics fundamentals
- Software makes the hardware go
- The Aiko framework
- Applications
- All about SAO - Simple Add Ons
What is a Swagbadge or a Dagbadge?
A swagbadge is the officially branded, fully pre-assembled electronic badge provided to early registrants to LCA 2021. Designed to work alongside the standard paper badge normally provided to participants, it provides a talking point, an access to hardware and electronics, and their corresponding software, and is extensible both now and into the future.
For those who can't get hold of a swagbadge (you registered too late to LCA 2021, you're attending LCA but don't live in Australia, or you're just interested in the process and want to be part of our wider community), there's the dagbadge. This is a list of parts that you acquire yourself (without the LCA branding), designed to be readily obtained from your local or online electronic store. You need to assemble it yourself.
The components on the badge
The swagbadge contains:
- a PCB
- a Lolin32 ESP32 microprocessor
- two OLED screens
- two switches
- two capacitive touch slider controls
- four SAO headers
For the list of parts on a dagbadge, see Dagbadge BOM, but it is essentially the same, but with a breadboard instead of a PCB.
What do all those elements mean?
Imagine that the badge is a creature.
- the Lolin32 ESP32 microprocessor is the brain. It is a tiny computer, designed for embedded/IoT applications, of a type called a ESP32, manufactured to the Lolin32 standard (first built by the WEMOS company but frequently copied). It has:
- Wifi
- Bluetooth
- 4Mb (?) of flash memory
- Low power consumption for long life when battery powered
- Powered by microUSB - USB, but is capable of handling an external battery if you know how to connect it.
- the PCB is a Printed Circuit Board. It is combination skeleton and nervous system. Like a skeleton, it holds the other parts in place. Like the nervous system, it contains circuitry printed on it to let the microprocessor (the brain) communicate with all its senses, and talk to other devices.
- the two OLED screens are like inverse eyes. They are tiny computer screens, supporting black and white text, pixel and lines display, at a resolution of 128x64 (?). We have provided two so you can use them as one super wide screen, or as two separate screens.
- the two switches are underneath the screens on the swagbadge. Push the screen and it pushes the switch. The software can read the hardware to detect which switch is being pressed, and whether it's a single press or a long press.
- the two capacitive touch slider controls are sensors. As you move your finger up and down the lines, the software can read the hardware to find out (roughly) where your finger is on which slider. They're called "capacitive" because that is the mechanism by which the component works: it uses the capacitance in the circuit, affected by your finger, to tell where you're touching. Your smartphone's screen operates via capacitive touch..
- the four SAO headers are Simple Add On headers, which let you extend the capability of your badge with other components and boards using the SAO standard - there'll be a dedicated Swagbadge SAO wiki page soon(tm).
Some electronics fundamentals
- Extra pins on the board.
- Do not immerse in water/tea
- ... I'm sure I had more to add here.
Software makes the hardware go
The hardware on its own is inert. It doesn't do anything without something to read the sensors, or display information on the screen. So what drives the badge?
- Operating system: the Swagbadge uses MicroPython, a special version of the Python programming language designed for use on small internet of things/embedded devices, just like the badge.
- A framework. This is Aiko for MicroPython, written by Andy Gelme of the Open Hardware team. It provides a whole bunch of convenience functions for writing to the screens, or reading the value of switches. It's also designed to make communicating to a badge over a network a lot easier by providing access to the badge's capabilities via sending simple messages to the badge via an MQTT server. We are using a dedicated MQTT server for the badges, based in Australia so it's nice and fast!
- Applications. Written in MicroPython, these are programs to make your badge do things! Several are provided, to demonstrate some capabilities to help you learn how to use the badge and copy as required to make your own code work.
The Aiko Framework
Applications
All about SAOs: Simple Add Ons
The swagbadge came with several SAO protoboards. Our SAO prototyping boards come with standard sized holes in them to make it easier to mount components such as LEDs if you didn't have a custom SAO from Tindie or that you'd built yourself, and they have labelling on them so you can see which holes are for power or ground or are connected to the GPIO pin (this being the pin that controls a component).
Why use a protoboard instead of wiring things directly onto the badge?
- You can remove the board, if you want to reposition your SAO, or swap it for something else
- It's an easier base for adding multiple components
Electronic circuits
Itching to add some blinky lights to a SAO, whip out that soldering iron and get to work? Let's first talk about circuitry.
In order for components to work, they need a power source (in our case, that's a 5 Volt DC feed off the badge, coming through the SAO headers and onto our protoboard), they need a ground (also on the board), and the component(s) sits between the power and the ground. But you can't just plug in any old component into any old power source. Things can go wrong:
- Too much power for a component can fry it and let out the magic smoke.
- Not enough power and your component just won't work. In an attempt to get enough power, it may even fry your badge's power source - if it's powered via USB to your laptop, this may mean doing Bad Things to your USB port or your laptop.
Getting the power requirements right
- work out what the power consumption requirements are for your components
- If it's more than what your power source provides, you'd better get a bigger power source/battery and hook up the power to that, and not to the badge.
- If it's less than what your power source provides, you'll need some resistors to reduce the load going through your components.
It's just maths
Ohm's Law is our guide. V = I x R. Voltage (V) = Current in amps (I) x Resistance in ohms (R).
We know our badge gives you 5V.
You can determine the current requirements of your components by looking at their data sheets. Some will have a maximum current rating (you must stay below this!) and a recommended current rating (what you're aiming to meet).
Quick example:
- Let's say you have an eThingy that has a recommended current rating of 5 milliamps.
- Voltage off the badge is 5V
- We use Ohm's law to calculate the resistance (R = V / I), in our case, V=5, I = 0.05. So R= 5 / 0.05 = 100
- We need to use a 100 ohm resistor.
The resistor always goes between the power source and the component. (don't put it between component and ground: it's too late by then!)
LEDs are special.
LEDs break Ohm's law, so we have to do a bit more to get the values right. For LEDs the important thing is the voltage drop across the LED. This can also be known as the forward voltage.
- It's still R = V / I, but allowing for how we calculate the voltage requirements for a led: R = (battery source voltage - LED voltage drop) / current
Quick example:
- If you have a LED with a voltage drop/forward voltage of 2V, and current requirement of 20mA (milliamps)
- Voltage off the badge is 5V
- R = (5 - 2) / .02 = 150
- We need a 150 ohm resistor.
More about resistors
Resistors come in certain set values. If you can't get the exact value you need, just use the next highest one (don't go lower, or your resistor won't do the job and you'll fry your electronics). You can join them together in series if you have to.
Series vs parallel
Up until now, this tutorial has assumed you've just been powering a single thing. But what if you want to do multiple? More lights are better lights, after all! There's two different ways to connect components together: in series, or in parallel.
- series
- they're chained together, one after the other on a single loop from power, through the components and onto ground.
- parallel
- there's multiple circuits, each one connected separately to the battery