CHAPTER 11

Making and Sharing Electronics

Arduino

As you will see in this chapter, there is a ton of open-source electronics projects to automate and control almost anything you like. One project in particular has made this possible: the Arduino. An Arduino (www.arduino.cc ) is an open-source electronics platform based on easy-to-use microcontroller hardware and open-source software. Think of the Arduino as a lightweight brain enabling you to complete any automation-related task. Originally, it was developed as an electronics prototyping platform for design students in Italy by Massimo Banzi and David Cuartielles. They were frustrated that teaching design students the complicated engineering skills necessary to program a conventional microcontroller left little time to focus on design, their real passion. In addition, conventional commercial microcontrollers were obscenely expensive. The costs and complexities made automating things really challenging for all but well-funded professionals. Banzi and Cuartielles fixed both problems. Both the official Arduino and its open-source copies now cost a shockingly low amount. The Arduino Uno costs less than $10, and the Arduino Nano costs about $1. This makes even complicated electronics projects extremely cost-effective. The Arduino platform consists of a relatively simple board using Atmel’s ATMEGA8 and ATMEGA168 microcontrollers and onboard input-output support. Thus, it is possible for you to drop the costs even further if you use the chips rather than full boards in your own electronics (see the next two sections).

However, for beginners, using the Arduino makes life easy. The Arduino team had the foresight to share its innovation using open-source principles that not only allowed all the rest of us to benefit but also ensured that they now have a worldwide collaborative team consistently helping make their designs even better. There is now a massive family of open-source microcontrollers based on the Arduino. They can all be programmed and used in the same way—you can choose the features you need to realize your project.

Arduinos have been used for hundreds of projects. We saw how they could be used to control drones in Chapter 8, and we will see how they can be used for 3D printers in Chapter 12. The power of the Arduino is in the ease with which, and the speed at which, you can use it to get an interactive project working at a very low price. For example, if you like the idea of making your own musical instruments, as we discussed in Chapter 5, but you want to make your instruments more “space age,” consider fabricating an Arduino-controlled laser harp (Figure 11.1).

Images

Figure 11.1 Arduino laser harp. Instructions by Yaroshka. (CC BY-NC-SA) https://www.instructables.com/id/Arduino-Laser-Harp-1/

Images

Figure 11.2 DIY makers: Wall-E. (CC BY-NC-SA) http://diymakers.es/wall-e/

If you really liked the cartoon movie Wall-E and want to build your own cute little robot, you can follow easy instructions developed by do-it-yourself (DIY) makers in Spain, as shown in Figure 11.2.

Or perhaps you’ve always wanted your own magic mirror to let you know who is the “fairest of them all.” Luckily, an Arduino-powered magic mirror and photo booth have been developed for your building enjoyment (Figure 11.3).

Maybe you really want a Segway but can’t afford the real thing or even a commercial off-brand version. You can make your own Arduino-powered Segway-like device using some old bike parts, motors, a battery, and, of course, an Arduino (Figure 11.4). The bottom line for Arduinos is that you can make anything that involves sensing and acting on the environment much easier than you could with electronic controls in the past.

Images

Figure 11.3 Alinke DIY magic mirror and photo booth, Arduino powered. (CC BY-NC) https://www.instructables.com/id/The-Magic-Mirror/

This is because the Arduino integrated development environment, or IDE for short, makes programming a microcontroller literally child’s play. The IDE is software that consists of a standard programming language compiler and the boot loader that runs on the board. The software side of the Arduino builds on an earlier open-source software language (Wiring) and integrated development environment (Processing). Thus, the Arduino IDE language (syntax and libraries) is almost identical to C++ with some slight simplifications and modifications, and the Processing-based IDE. It is easy to adapt Arduinos to your projects because the Arduino is extremely flexible and its process is relatively easy to learn and use for beginners. Without any previous electronics experience, you should be able to get the basics in an hour (especially with help or a few YouTube videos) and get well into a project of your own in an afternoon.

The Arduino board is a lot like your brain. It is extremely powerful and useful, but for it to act on the environment, it needs peripherals. No matter how great your brain is, without your sensors (i.e., eyes, ears, nose, etc.) and your actuators (i.e., hands and legs, etc.), your brain would not be that fun to play with. In the same way, the Arduino can sense the environment by receiving input from a long list of sensors (e.g., acceleration, chemical, pressure, electric current and potential, humidity, light, magnetic fields, temperature, vibration, etc.). Then, based on rules you set in the IDE, the Arduino can affect its surroundings by controlling a similarly long list of outputs (e.g., lights, heaters, motors, robot hands, and other actuators). The Arduino can act as a standalone minicomputer running robots or drones or be connected to your laptop via a USB port so that you can program it or collect information on the fly. Enormous libraries of prewritten and free software covering almost any kind of sensor or actuator that you could imagine or buy can be downloaded for free (arduino.cc/en/Reference/Libraries). Arduino software is truly cross-platform and runs not only on free and open-source GNU/Linux operating systems but also on Windows and Mac platforms.

Images

Figure 11.4 Stoppi71, Arduino segway. (CC BY-NC-SA) https://www.instructables.com/id/Arduino-Segway/

To get started, I recommend Lady Ada’s tutorials (www.ladyada.net/learn/arduino). She is the founder of Adafruit (an open-source electronics firm) and maintains an excellent tutorial library, which should be useful for getting anyone started. Besides the online tutorials, there are many good books about how to use Arduinos (Banzi, 2011; Margolis, 2011; Monk, 2012).

The Arduinos, by themselves with a few sensors and actuators, are pretty handy, but they start to gain real powers with plug-and-play expansions called shields. Shields are an extremely important feature made possible by the standard way that connectors are exposed on the larger Arduino boards (Uno and bigger), allowing the board to be connected to other boards for specific tasks. Some shields communicate with the Arduino board directly over various pins, but many shields are individually addressable via an inter-integrated circuit (I²C) serial bus, allowing many shields to be stacked and used in parallel.

For a list of the more than 300 Arduino shields available and over 500 more in the queue as of this writing, see the Arduino shield list (shieldlist.org) maintained by Jonathan Oxer. For example, the SparkFun Musical Instrument Shield is an easy way to add Musical Instrument Digital Interface (MIDI) sound to your next Arduino project. You simply connect a speaker, stereo, or pair of headphones to the 18-inch stereo jack on the shield and pass the proper serial commands to the integrated circuit (IC), and you’ll be enjoying music. The shield contains two large tone banks including various piano, woodwind, brass, synthesizer, sound effects, and percussion sounds. The shield is also capable of playing several tones simultaneously (up to a maximum polyphony of 31 sounds). You can download the example code to add music to any project and work on your composition skills in addition to your electronics skills. Chapter 13 will discuss other shields used by scientists.

Finding and Sharing Open-Source Electronics

Arduino is just one single family of microcontrollers—there are many, many more! Open-source electronics is one of the most mature subfields of open hardware. You can find almost any circuit you want in open-source circles. There are several repositories that you can use to download open-source electronics, such as the Open Circuits Institute (opencircuitinstitute.org), Open Electronics (www.open-electronics.org), Open Hardware Repository (ohwr.org), and Open Circuits Wiki (www.opencircuits.com/Projects), as well as Hackster (www.hackster.io), Codemade (www.codemade.io), and Hackaday (hackaday.com). All these websites allow both users and developers to discover and share open-source projects. There are also commercial offerings. Kitspace (kitspace.org) is a place to share ready-to-order electronics designs. In addition, there are several open-source electronics companies, including Sparkfun (www.sparkfun.com), Adafruit (www.adafruit.com), Tiny Circuits (tinycircuits.com), and Seeed Studio (www.seeedstudio.com).

Finally, you do not even need to rely on new electronic components to populate these open-source designs. Although the Arduino is largely plug and play, to build your own circuits, you will need to solder (www.instructables.com/id/How-to-solder). Learning to solder through-hole components and butt connections is an essential skill. You use a soldering iron that heats up solder and then allows you to melt and solidify the solder to make a permanent electrical connection between your components. This skill can be learned in a few minutes, but you will get better with more practice. After you know your way around a soldering iron, you can also disassemble broken electronic devices for the parts and then use them to make new creations. This is not only good for the environment but also can save you a lot of money.

Open-Source Software for Electronics Design

If you really get into open-source electronics, you may wish to make your own completely new electronics boards or build new capacities into other people’s designs. To do this, the “gold standard” in open-source software is the suite for electronic design automation (EDA) called KiCad (www.kicad-pcb.org). KiCad handles schematic capture with a schematic editor that lets you create a design without any limits or paywalls that force you to pay money to unlock features. KiCad provides an official library for schematic symbols, and the built-in schematic symbol editor helps you to rapidly make and add your own designs.

You can make simple one-layer printed circuit boards (PCBs) with ease, but KiCad also makes professional PCB layouts with up to 32 copper layers. It also has a push and shove router that is capable of routing differential pairs and interactively tuning trace lengths. KiCad provides Gerber output, which is an open ASCII vector format for PCB designs. Gerber is the de facto standard used by PCB industry software to describe the PCB images: copper layers, solder mask, legend, drill data, and so on. You may need Gerber output if you decide to have a professional make your board after you have finished the design (explained in the next section).

Finally, KiCad includes a 3D viewer so you can inspect your design in an interactive canvas. This is important because, in a 2D view, you cannot rotate and pan around to inspect details (or hide and show features) that may ruin the functionality of your board. KiCad runs on Windows, Linux, and Mac operating systems and is licensed under GNU GPLv3, which means you are free to use it in any way you like as long as you share back to the community.

Another useful piece of open-source software for helping share your electronics projects with others is Fritzing (fritzing.org). Fritzing is an open-source hardware initiative that makes electronics easily accessible for almost anyone. I often use it to provide wiring diagrams to show people how to make a physical prototype if they have the board and the components. Besides the software, Fritzing has a robust community website and commercial services in the spirit of Processing and Arduino, which fosters a creative ecosystem. In the Fritzing community, you can document your prototypes, share them with others, get materials to teach electronics in your classroom, and even lay out and manufacture professional PCBs.

Ordering Boards

There are many businesses that provide PCB designers with services to make their electronics projects a reality. If you are just starting out and want either a prototype or a few PCBs, then you should look at the smaller manufacturers that cater to hobbyists and the open-hardware community. In the United States, one of the popular services in the open-hardware community is OSH Park (oshpark.com) for prototyping, hobby design, and light production. The company uses purple solder mask over bare copper (SMOBC) and an electroless nickel immersion gold (ENIG) finish, which works for lead-free reflow processes and is Restriction of Hazardous Substances Directive (RoHS) compliant. What this means is that OSH Park produces high-quality bare PCPs in purple! The boards are made in the United States and ship free anywhere in less than 12 days. OSH Park’s costs are pretty straightforward, based on the number of layers and the number of square inches you need.

You may also want to consider working directly with an open-hardware company such as Seeed Studio (www.seeedstudio.com/fusion.html), which is a hardware innovation platform tailored for makers. The company offers the Seeed Fusion Service, which provides one-stop prototyping services for PCB manufacture and assembly, as well as other customized electronic and mechanical services such as CNC milling, 3D printing, and PCB layout services. The company provides a handy online price calculator, where you can make your selections for the type of board you want and get an immediate quote with a 100 percent quality guarantee.

If you have done your design in Fritzing and you need the PCB, parts for it, or stencils, Fritzing Fab, run by AISLER (aisler.net/partners/fritzing), is an easy option. This is a full-service shop that can get your PCB to you in seven business days worldwide. Other options are outfits such as JLCPCB (jlcpcb.com), which is the JiaLiChuang Company (Hong Kong) and the largest PCB prototype enterprise in China. JLCPCB specializes in quick PCB prototyping and small-batch PCB production. The company has decent quality and extremely low prices (e.g., only $2 for a one- to two-layer 100- × 100-millimeter PCB). Similarly, if you want guaranteed 100 percent error-free boards, Advanced Circuits (www.4pcb.com) is one of the largest outfits in the world.

PCB Making

You may want to do everything yourself, or perhaps you have been making so many PCB designs that even the best deals from the PCB fabricators in the preceding section are burning a hole in your wallet. Luckily, the open-source community provides several options for making your own PCBs.

Old School

The easiest way to make your own board is to breadboard it or use a conductive-ink pen to draw traces on a simple circuit. You can climb the ladder of sophistication a little higher by directly drawing the whole PCB layout on copper board using a black permanent marker (e.g., a Sharpie). First, draw your circuit using pencil, and when you are happy with it, trace it with a marker. Then, etch the unmarked copper away with a copper etching chemical such as ferric chloride or hydrogen peroxide. For more complex circuits, it is better if you use design software (as discussed earlier), print out the layout on glossy photo paper, and transfer it to the copper board using an iron. Then, the same etching process and possibly drilling through-holes will enable you to make a good PCB. Instructables (www.instructables.com/id/How-To-Make-A-PCB-PCB-Making-Guide or www.instructables.com/id/How-to-make-PCB-at-Home) has several useful tutorials that can walk you through the process.

Using a 3DP+ Mill

The open-source 3D printers (3DPs) that we discuss in Chapter 12 are extremely versatile and can be converted into moving-stage printers or substrate-moving robots (Zhang et al., 2016; Pearce, 2017). This feature is useful for electronics manufacturing. After converting a Delta RepRap into a stage printer, a copper-coated PCB blank can be attached to it. Then, a fixed tool is secured in place by a structure made of rectangular extruded aluminum that replaces one of the vertical boards on the delta robot. Tool heads such as a mill spindle can be secured to the mount by a magnetic mount consisting of three rare earth magnets. A mill spindle holder with a 200- to 400-W direct current (DC) spindle motor that turns at 12,000 rpm when supplied with 48 V of power can be used to print out reasonable PCBs (Anzalone et al., 2015). PCBs designed in KiCAD (as discussed earlier) can be converted to G-code using the open-source pcb2gcode (sourceforge.net/projects/pcb2gcode/). Figure 11.5 shows digital micrographs of traces milled in PCBs produced by a commercial PCB mill (left) and the convertible 3D printing platform (right). Clearly, the 3D printer operating as a mill shows more chattering than a CNC machine meant only for milling, but it is still more than adequate for the vast majority of hobby-level PCB milling projects.

Images

Figure 11.5 Digital micrographs of traces milled in PCBs produced by a commercial PCB mill (left) and the convertible 3D printing platform (right). (CC BY-SA) https://www.appropedia.org/File:Os-pcb.png

Dedicated Open-Source Mill

If you are interested in making even more sophisticated PCBs (or if you are going to do a lot of them), you can build an open-source mill meant specifically for PCBs. There are several open-source PCB mill designs on Open Builds (openbuilds.com) and in open-hardware/electronics repositories. An Open Source Ecology–designed distributed 3D (D3D) robotics system can also be converted into a dedicated PCB mill (Oberloier and Pearce, 2018), as shown in Figure 11.6. You can compensate for any motion inaccuracies of the open-source mill with the Open Circuit Institute’s open-source Copper Carve, which enable the machine to achieve a motion resolution of 10 microns (less than the thickness of a human hair). This should be more than adequate for the vast majority of circuit designs. The open-source mill is at least five times less expensive than all commercial alternatives. Thus, if you plan to make more than 20 boards, the open-source mill pays for its material costs.

Images

Figure 11.6 Belt-driven open-source circuit mill developed around low-cost 3D-printer components (Oberloier and Pearce, 2018). (GNU FDL) https://www.appropedia.org/File:OScircuitmill.png

Open-Source Security

One of the counterintuitive benefits of embracing open source is that it can make you, your family, and your company more secure. It is perhaps easiest to see this with the hysteria surrounding the recent rash of hardware hacks. Hardware hacks are particularly scary because they trump any software security safeguards. For example, they can render all accounts on a server password-less. Fortunately, we can benefit from what the software industry has learned from decades of seemingly tireless and prolific software hackers: Using open-source techniques can make a system more secure (Hoepman and Jacobs, 2007). How can this be?

Imagine that you are a James Bond–like 007 agent holding classified documents. Would you feel more secure locking them in a safe whose manufacturer keeps the workings of the locks secret or locking them in a safe whose design is published openly so that everyone (including thieves) can judge its quality—thus enabling you to rely exclusively on technical complexity for protection?

The first approach might be perfectly secure—you simply don’t know. But why would you trust any manufacturer that could be compromised now or in the future? If the information is really important, it is insane to trust it to the “black box.” In contrast, the open system is almost certain to be secure, especially if enough time has passed for it to be tested by multiple companies, governments, and individuals. Thus, counterintuitively, security is one of the core benefits of open-source technology development (Lynch, 2015).

While open source is not inherently more secure, it allows you to verify security yourself (or pay someone who is more qualified to do so for you). With closed-source programs, you must trust, without verification, that a program works properly. To quote former President Reagan: “Trust—but verify.” This is a far better way to approach security, whether online or not. The bottom line is that open source allows you, the user, to make more informed choices about the security of a system. With closed-source software, you simply have trust alone.

This concept of “trust but verify” also holds true for electronic devices. Most electronics customers have no idea what is in their products, and even technically sophisticated companies like Amazon may not know exactly what is in the hardware that runs their servers because they use proprietary products that are made by other companies. This can be really scary. Recently, in an incident reported by Robertson and Riley in Bloomberg (2018), Chinese spies used a tiny microchip, not much bigger than a grain of rice, to infiltrate hardware made by SuperMicro (the Microsoft of the hardware world). These chips enabled outside infiltrators to access the core server functions of some of America’s leading companies and government operations, including Department of Defense data centers, CIA drone operations, and the onboard networks of Navy warships. Operatives from the People’s Liberation Army or similar groups could have reverse-engineered or made identical or disguised modules (in this case, the chips looked like signal-conditioning couplers, a common motherboard component, rather than the spy devices they were).

Having the source available helps customers much more than hackers, because most customers do not have the resources to reverse-engineer the electronics they buy. Without the device’s source, or design, it’s difficult to determine whether or not hardware has been hacked. This is where open hardware and distributed manufacturing (where you can actually inspect the core source and make sure you are getting it) add to security.

Open-source hardware and distributed manufacturing could have prevented the Chinese hack that rightfully terrified the security world. Organizations that require tight security, such as military groups, could then check the product’s code and bring production in-house, if necessary. In the end, no one really wants to be spied on. With open hardware, all users can increase the security of their devices. Not long ago, you had to be an expert to make even a simple breadboard design. Now, as shown earlier, with open-source mills for boards and electronics repositories, small companies and even individuals can make reasonably sophisticated electronic devices. While most builders are still using black-box chips on their devices, this is also changing as open-source chips gain traction (Waite, 2010). Creating electronics that are open source all the way down to the chip is certainly possible—and the more besieged we are by hardware hacks, perhaps it is even inevitable. Companies, governments, and other organizations that care about cyber security should strongly consider moving toward open source—perhaps first by establishing purchasing policies for software and hardware that make the code accessible so that they can test for security weaknesses. If you are worried about hackers or identify theft even a little bit, open hardware provides some support, and in general, making your own electronics costs significantly less than buying black-box electronics. Although challenges certainly remain for the security of open-source products (Wen, 2017), the open-hardware model can help enhance cyber security—from the Pentagon to your living room.

References

Anzalone G, Wijnen B, Pearce JM. 2015. Multi-material additive and subtractive prosumer digital fabrication with a free and open-source convertible delta RepRap 3-D printer. Rapid Prototyping Journal 21(5):506 –519, doi: http://dx.doi.org/10.1108/RPJ-09-2014-0113

Banzi M. 2011. Getting Started with Arduino, 2nd ed. Make: Santa Rosa, CA.

Hall C. 2018. Survey shows Linux the top operating system for internet of things devices. IT Pro. https://www.itprotoday.com/iot/survey-shows-linux-top-operating-system-internet-things-devices

Hoepman JH, Jacobs B. 2007. Increased security through open source. Communications of the ACM 50, no. 1: 79-83.

Kerner SM. 2018. Linux Foundation on track for best year ever as open source dominates. ServerWatch. https://www.serverwatch.com/server-news/linux-foundation-on-track-for-best-year-ever-as-open-source-dominates.html

Lynch J. 2015. Why is open source software more secure? InfoWorld. https://www.infoworld.com/article/2985242/why-is-open-source-software-more-secure.html

Margolis M. 2011. Arduino Cookbook. O’Reilly Media, Sebastopol, CA.

Monk S. 2012. Programming Arduino: Getting Started with Sketches. McGraw-Hill, New York.

Oberloier S, Pearce JM. 2018. Belt-driven open source circuit mill using low-cost 3-D printer components. Inventions 3(3):64. https://doi.org/10.3390/inventions3030064

Pearce JM. 2017. Impacts of open source hardware in science and engineering. National Academy of Engineering: The Bridge 47(3):24–31.

Robertson J, Riley M. 2018. China used a tiny chip in a hack that infiltrated U.S. companies. Bloomberg. https://www.bloomberg.com/news/features/2018-10-04/the-big-hack-how-china-used-a-tiny-chip-to-infiltrate-america-s-top-companies

Vaughan-Nichols SJ. 2018. Supercomputers: All Linux, all the time. ZDNet. https://www.zdnet.com/article/supercomputers-all-linux-all-the-time/

Waite E. 2010. Using open source designs to create more specialized chips. Wired. https://www.wired.com/story/using-open-source-designs-to-create-more-specialized-chips/

Wen S. 2017. Software security in open source development: A systematic literature review. In 21st Conference of Open Innovations Association (FRUCT). IEEE, Conference Location: Helsinki, Finland; pp. 364–373. https://doi.org/10.23919/FRUCT.2017.825020

Zhang C, Wijnen B, Pearce JM. 2016. Open-source 3-D platform for low-cost scientific instrument ecosystem. Journal of Laboratory Automation 21(4):517–525.