Professional Documents
Culture Documents
DIYode Issue 2 August 2017
DIYode Issue 2 August 2017
124
PAGES!
SPECIAL BUMPER
AUGUST ISSUE
INTRUDER
ALERT!
BUILD YOUR
Issue 002
Aug 2017
AUS: $9.95 inc. GST
ISSN: 2207-8045
02
OWN ALARM
9 772207 804002
SYSTEM
58
86
91
24
EDUCATION:
■ FUNDAMENTALS
Securing Success with Soldering 24
■ SECRET CODE
Introducing Variables & Logic 46
■ THE CLASSROOM
AC/DC Rocks On 66
■ MICRO-EXPLORERS
Introducing the ESP8266 118
14 PROJECTS:
■ T WEET THE WORLD
Arduino-Powered Twitter Feed 34
■ SUPER SIZE ME
Van De Graaff Generator 58
■ PART 1: ALARMDUINO
Build a Powerful Alarm System 78
■ RPi GUI INTERFACE
Introducing Interactive Controls 94
■ MODEM RESTARTER
Automatic System with ESP8266 111
118 70
■ E DITOR'S LETTER
DIYODE Magazine Takes Flight 04
■ NEW & REVIEWED
Micro:bit, Arduino Box & more... 08
■ MOONSHOTS
Natural Server Cooling 22
■ GOING PRO
Obelisk Systems & the StarLAB 104
■ SUBMISSIONS
Community Contributions 120
■ THE ADVENTURES OF
CIRCUIT MODD 122
diyodemag.com Issue 002 August 2017 7
NEW & REVIEWED
Grab it Now:
BBC
micro:bit
The BBC micro is one of the quintessential parts of modern PC
history. It was devised as a learning program for schools in the UK
during the early 80s. The key premise of this was to teach students
the fundamentals of computers and how they worked. While the
BBC micro has well passed its useful time, the ARM processor core
that drove it, now forms the basis for modern systems such as the ABOVE ▲
Raspberry Pi, Microsoft Surface, iPads and your Nintendo DS. micro:bit board within the :MOVE mini buggy kit.
Fast forward 35 years and you have a world where everything is This was quite clever in my opinion; he was intrigued straight away.
connected to everything. The phone in your pocket is capable of With a functional unit we elected to plug it in via the USB cable and
millions of calculations per second, all to show you videos of funny start some code.
cats on YouTube. While the original BBC never took off in Australia
the next generation has just landed. It's been in UK schools for one SOFTWARE
year, and we now have Australian distributors.
The coding environment is block-driven and is very similar to
HARDWARE Scratch. We pottered for a few minutes and worked out how to
create the Hello World app. The unit is platform-independent and
On the surface, the micro:bit is quite small. We expected an creates a .hex file which is downloaded to your computer. We had
Arduino-sized unit, but it is even smaller at 43mm x 52mm there are to drag and drop the file from its download location to the micro:bit
no outward connectors or header pins, just a micro USB and battery which had shown up as a drive on the machine. The unit reboots
interface. The front of the unit has two small micro switches, a 25- itself and executes the program.
LED matrix, and a series of five large holes in the bottom that act
as interface pins. This forms part of a greater 23-pin interface. The The software is straightforward to navigate and offers one of the
holes are designed to easily accommodate banana plugs or alligator best board simulations I have ever used. You can program and
clips. test in real-time without the need for a unit to even be connected.
We gave the control over to Master 9 who undertook the paper,
The unit itself is based on the 16MHz ARM Cortex-M0 32-bit scissors, rock tutorial. It required us both to work through a couple
processor with 256k Flash and 16k RAM. The unit supports of small issues, but most were understanding what code blocks
Bluetooth LE, accelerometer, magnetometer (compass) and USB were, and where and how we needed to replace them. Code blocks
connectivity. Going beyond the basic 5-hole interface and using the are all represented in different colours, and it does not take long
23-pin connector gives the user access up to 3 PWM outputs, 6-17 to understand what belongs where. Within a few minutes, he had
GPIO, 6 analogue inputs, serial I/O, SPI, and I2C. All powered by 2 completed it and uploaded it to the unit, madly shaking it to play
AAA batteries. paper, scissors, rock.
OPENING THE BOX He was engaged now and feeling accomplished. We set him a few
tasks such as making the LEDs come on with the buttons. Within
The box is quite small and well packed. It contains the micro:bit, just 30 minutes he was able to create code that could read when
battery holder, 2 x AAA batteries, USB micro cable and a quick start the unit was tilted and to display varying icons based upon the
guide. Setup was quite fun. This was done with a 9-year-old and inputs. His 7-year-old sister also wanted in, so we handed the
involved shaking the unit and playing some mini games to set up. teaching duties over to the 9-year-old and in under 10 minutes
he was able to guide her through Hello World, button inputs and When we first saw this we thought it was cute but was not likely to
outputs, and how to upload to the unit. With further exploration she be as purposeful as the Arduino system. It's not, but it's also not the
discovered she was able to increment a variable based only when same thing. For the purpose it was designed for the micro:bit is one
the unit was tilted left, and then display the information by pressing of the best learning and teaching devices we have used. It doesn't
a particular button. take long to realise that even using the JavaScript block editor, you
have a very powerful tool at your disposal. Highly recommended
The software is based online but once loaded can be reloaded from the DIYODE team! Want to see more projects based on the
offline (according to their documentation). There are various micro:bit? Let us know. ■
versions of programming languages to use. We only used the
JavaScript block interface; it is easily switchable to a JavaScript Want it now? Grab it online from:
code interface. There is also a Python-based editor for those who https://tronixlabs.com.au/bbc-micro-bit-australia/
wish to dive even deeper into the abilities of the unit.
They also offer an iPad app that allows you to connect to the unit
via Bluetooth and upload/flash your micro:bit. It opens a version of
the JavaScript block editor in Safari. It uses a touch interface and
although effective, it can be a little frustrating at times.
TEACHING RESOURCES
The micro:bit website has one of the best teaching libraries we have
seen, with resources provided for both students and teachers.
The 9-year-old could easily follow the
instructions to create some of the games.
CONCLUSION
Threadboard provides a universal mounting for your Arduino or At the time of writing, some packages are being put together, so you
Raspberry Pi, as well as a whole bunch of accessories. By firmly should be able to find them at some of your favourite retailers very
securing your hardware to the baseplate, you’re far less likely to soon. ■
unintentionally pull out a jumper, short out a power supply, or do any
number of soul-crushing, smoke-releasing, hair-pulling things that Want it now? Grab it online from:
can take your prototype from perfection to paperweight in the blink http://threadboard.com
of an eye.
TO ENTER
Head to diyode.io/002nfgh and
tell us in 50-words or less what
you could make with a new Dremel
Maker Kit! Entries close
1st September 2017!
Sanding wood, polishing metals and cutting Thanks to the 290 Engraver and You’ll make all your projects a flaming
plastic is a breeze with the Dremel 3000 accessories, you can personalise all your success with this open flame torch. Ideal
Series Rotary Tool. Complete with a 130W future projects! This easy-to-hold appliance for joining wire and heating heat-sensitive
motor, integrated hang hook and EZ Twist can be used on a wide variety of materials, materials, the 2000 VersaTip’s large tank
nose cap for fast accessory changes, this and features a reciprocating action for capacity also ensures optimal and extended
DIY tool ensures your kit is ready to tackle optimal control, ensuring you can carve your use.
any project. initials onto almost anything and everything!
NEW & REVIEWED
Spotlight on:
ALTRONICS’
ARDUINO MEGABOX
Giving ‘Duinos a Home
The folks over at Altronics are doing some pretty amazing things LCD, as well as two 2A relays! With some clever insight, they haven’t
in the maker space. Their new Arduino Megabox takes DIY device taken any flexibility away from you though - everything is broken
building to a whole new level, providing a method to create a out to headers, so there’s no restriction on how they’re assigned to
finished product with your Arduino prototype. your Arduino (meaning you can omit them if you don’t need them).
Everything provides built-in resistors so you can connect straight
Just as many of us will remember when building DIY kits in years from 5V without worrying about current-limiting yourself. There’s a
gone by, the case was often the part that was most difficult to get handy 210-hole prototyping area for soldering various connections
looking good. With Arduino projects, this problem certainly hasn’t too, making this a VERY versatile box.
gone away. The team at Altronics have carefully considered what to
include in this case, to provide versatile and functional options. Like These cases are in the final stages of development at the time of
any product such as this, it won’t suit EVERY project perfectly, but writing this, so will vary slightly from the unit we had, but for the
it’ll certainly provide a solid option for many. better. The tactile switches will upgrade to DPDT, more terminal
access through the case, and some other improvements are
To start off, it will fit an Arduino UNO or Mega, which plugs straight coming as well. ■
into the custom-developed board. It cleverly provides breakouts
while still retaining header access, and additional access to connect Coming soon to Altronics:
a shield (Ethernet, WiFi, prototype, whatever you like). The case then http://altronics.com.au
includes four illuminated tactile switches, a rotary encoder, a 2 x 16 K9670 $75
Getting Testy:
Mooshimeter
It’s not every day something new comes along in test equipment. relationship of current draw to input voltage as a battery discharges,
OK, so maybe it almost is... but rarely does something stand out to test for output changes as a power supply heats up... do we need to
us like the Mooshimeter. Mooshimeter has actually been around for go on? You might be able to tell, Mooshimeter had us at hello!
a few years, and has now been tried and tested.
Dual-channel measurement is a powerful and useful feature! With
It’s a fairly unassuming piece of test equipment on its own, but CATIII 600V protection, it’s suitable for all sorts of environments.
pair it with your smartphone or tablet, and you unlock a world of Mooshimeter doesn’t just take care of the here and now though...
potential. Using a simple Bluetooth connection, Mooshimeter takes it can be used as a powerful data logger. Simply insert your
advantage of your iOS or Android device for data display. Having a favourite microSD card up to 32GB and you’re ready to go. The
huge touchscreen to control everything then makes things really accuracy is respectable and while it may not compare to some
easy! The addition of it being wireless (with a range of up to 45m) top-shelf equipment, it’s still going to provide accurate data in most
means you can safely leave it in your test environment, while applications. It does all that while still providing all the awesome
measuring from a safer location. This is especially useful in high flexibility we just noted. ■
voltage environments or confined spaces.
Want it now? Grab it online from:
It might look a little like a toy, but looks can be deceiving. It’s made https://core-electronics.com.au/mooshimeter.html
from high grade Polycarbonate plastic, and inside is a 24-bit ADC, CE04630 $215
which provides high resolution data. What’s more, it’s actually a
dual-channel multimeter. This means you can test, say, voltage and
resistance, or voltage and current, at the same time! Doesn’t get you
excited? Let’s think about what that actually means... monitor the
Retro
Electro ▲ From a basic vintage
toy piano to an electronic,
LIAM LACEY
polyphonic, super
Head of Development, Modal Electronics, UK awesome synthesiser. ►
http://liamtmlacey.com
@liamtmlacey
Liam took a kids toy piano and turned samples were eventually released as a commercial sample library,
it into a powerful music machine. One co-developed by Ali and Impact Soundworks.
thing’s for sure - this isn’t a toy anymore!
THEN... In 2015 I undertook a second toy piano project, this time at
a music technology hackathon in Berlin called MIDI HACK. Here, I
converted the piano into a simple USB-MIDI controller. From this 24-
Have you ever seen a used mechanical toy that’s been entirely hour project I was awarded a prize from one of the event sponsors,
gutted and redeveloped into a powerful synthesiser? With a sleek and this spurred me on to think about how I could extend the project
laser-cut top-panel, handmade velocity sensors, and a host of into something more advanced.
customisations, it looks truly amazing; and while the black keys
might just be paint, that’s where the pretending stops. In my day job I work for Modal Electronics (UK), who make hardware
synthesisers, so the work I do with them ultimately inspired me
We’ve seen plenty of retro computers, Game Boys and other vintage to see if I could incorporate the same kind of ideas, but within an
hardware converted into new things, but this is quite a unique existing vintage toy piano.
idea because you’ve taken a kids toy piano and converted it using
modern electronics. Did you find the toy or was it something you ULTIMATELY... The main thing that pushed me to physically start the
had growing up? project was the announcement of the Element14 Music Tech Design
Challenge. After submitting a project proposal I became 1 of 15
This particular toy piano was one I purchased off eBay a couple of sponsored challengers, which gave me the perfect opportunity and
years ago; however, I did have one when I was growing up, which platform for turning the project into a reality.
was probably the root of my fascination with vintage toy pianos.
Some of the old electric toys we’ve seen used basic electronics,
Ah, the old “childhood memory” throwback! As a kid, many of us many of which were monophonic. Was the original toy polyphonic or
dreamed of being superheros or rockstars while playing with toys, did you have to modify it to make it work that way?
but what made you look at this piano and ask yourself, “how could
this be more awesome?” The existing toy had a full polyphonic keyboard mechanism, but it
was purely mechanical. Each key had its own “hammer” and metal
The main inspiration for this project came from a couple of existing sound rod, so that when a key is pressed its hammer will strike
toy piano projects I worked on. its rod to create an independent sound/note. However, as I was
turning this acoustic musical instrument into a purely digital one, I
FIRST... In 2012 my brother Ali and I embarked on an experimental needed to remove the hammers and sound rods (as these were now
toy piano project, where we recorded and sampled a vintage toy redundant), and replace them with sensors for reading individual
piano in many conventional and unconventional ways. The audio key interaction data in the digital domain. ››
ensure velocity sensitivity. The way this works is that an initial key
press opens one switch and starts a timer. Then, when the key is
fully pressed, a second switch is closed, which stops the timer.
This creates a velocity value based on the time value. This solution,
however, didn’t work very well either, as the piano keys are light and
flimsy and I wasn’t able to find a switch or mechanism that would
stay “closed” just by the weight of an unpressed key.
The original piano worked with metal rods. Fortunately, in the process of trying to develop the above “dual-
switch” solution, I discovered Velostat, which turned out to be a
›› So it worked rather like a real piano (but with rods instead great sensor solution for the key mechanism. I used Velostat by
of strings) - that’s quite cool. But converting from mechanical attaching small squares of it to the underside of each key, which
to electronic is rarely as easy as it seems. You added velocity “hovered” above two contact points of a circuit, attached to an
sensitivity using velostat material. How difficult was it to create Arduino. This ensures that when a key is pressed, the Velostat
these sensors and integrate them into the project? completes/closes the circuit, sending a “press” reading for creating
note-on messages. Then, when the key is released, it breaks
Possibly the most challenging part of the whole project was the the circuit and sends a “release” reading for creating note-off
development of the key mechanism. Allowing the existing toy piano messages. However, as Velostat creates a variable analogue/
keys to generate note messages in the digital domain was difficult resistance value - depending on how much pressure is being
because there was next to no existing examples of it being done. applied to it - this allowed me to just use this reading to create a
velocity value for each key press, rather than having to use a second
For the key mechanism, I undertook a couple of design iterations switch and a timer. Using Velostat also allowed me to implement
before I settled on using Velostat-based sensors. For the previous polyphonic pressure sensitivity into the keyboard, meaning that
USB-MIDI toy piano project, I’d used piezo sensors, where a strip after a key is initially pressed, a varying amount of pressure can
of piezo sensors were placed inside the piano’s enclosure, so that be applied to it, to create an extra level of expression from the
the hammers of the keys would strike them and create a key press keyboard.
and velocity measurement. They were very easy to add to the piano;
however, in practice they didn’t create consistent results (due to Creating the Velostat sensors and integrating them into the project
the hammers not always striking the sensors properly), and they was fairly easy. Velostat can be cut into any shape or size, which
couldn’t detect key release interactions. was very handy for this project as there wasn’t much space under
each key to attach sensors. I had considered using FSRs (which
The second iteration involved designing a “dual-switch” mechanism are very similar to Velostat), but I couldn’t find any that were small
for each key, which is how most commercial keyboard mechanisms enough to fit under the keys. So instead, I simply attached the
What’s
wooden keys striking the bottom of the key-release input functionality.
enclosure. I didn’t need to attach any wires
Polyphonic?
▼ BELOW
to the sensors because the pressing of the Each stage of prototyping took
keys caused the sensors to join contact on its own form.
points of the circuit. Therefore, I didn’t have
the struggle of trying to attach wires to this “Polyphonic” essentially means
flexible material, which was great. something can produce more than
one note at a time (such as a piano
That’s a pretty awesome conversion. or an electric guitar). In contrast,
Velostat is so versatile for this application, “monophonic” is something that
definitely a great choice. We are equally can only produce a single note at
impressed by your previous use of piezo a time (such as a human voice or a
for velocity sensing - that was some great frequency generator).
thinking outside the square (even if it
wasn’t 100% reliable, as you noted). Making In many ways even an orbital
the synth work as a standalone system sander can be considered a sort
is clearly a lot more work than simply of monophonic instrument. The
making a MIDI-integrated synth (where “tone” of the sander changes with
the external MIDI synth does all the heavy the speed of the sander, but it can’t
lifting). Was making it work as a standalone emit “two tones” at once. Of course
unit, an important aspect to you in terms a sander isn’t considered a musical
of functionality, or was is more of an instrument, but there are plenty of
exploratory drive (e.g. so you can say that bands out there using sanders, angle
you did it)? grinders, and other non-traditional
items to create amazing music!
I had already completed a MIDI toy piano
project in the past, so with this ››
RIGHT ►
Liam explored
different options to
replace the Piano lid.
Ultimately, laser-cut
acrylic was the best
choice to support this
detailed layout.
CAD panel design
co-developed by Anna
Blamire-Brown.
›› project I mainly just wanted to expand on what I had already random amounts of pitch offsets to each note. This said, I haven’t
done and develop something more complex and interesting. The seen many (if any) commercial synths provide a control for setting
main technical requirement of the Element14 Music Tech Design the amount of this kind of behaviour.
Challenge was to use a BeagleBone Black single-board computer.
While it could easily handle doing MIDI processing, I thought it The most unique thing about the Vintage Toy Synth is its form factor
would be good to use the full potential of the board and develop and design. Playing an instrument is about so much more than just
a more powerful system. I’m always keen to learn new skills, and the sound you create. The way you play it, the physical feedback,
developing a Linux-based audio synthesiser was something I had and the general feel and aesthetics of the instrument also play a
never done before so I thought it would be of great benefit to my big role in the overall experience. All these elements help to nurture
professional career. inspiration, and can even affect your perception of the sound
created. Vintage wooden toy pianos have such a uniquely enjoyable
So it was definitely part “so you can say you did” then! It’s so great feel and aesthetic, with their clunky wooden keys and their charming
that you took the bounds of the Element14 challenge and pushed miniature form, and I believe this can make a big difference as to
within them. How does this synth compare to commercial units? Is what a musician can get out of an instrument like this.
there something unique here (other than the fact that you built it,
and it’s amazing)? There’s definitely something about playing music with different
hardware. Playing drums with a mouse isn’t nearly the same as
The voice engine of the synth is very similar to most subtractive- beating cow-skin with sticks - so we hear what you’re saying!
synthesis-based commercial synths. It has multiple oscillators with Looking at the piano now, your acrylic panel is very slick. Did it take
standard analogue-style wave shapes; a filter with frequency cutoff any trial and error to get the laser-cutting / laser-engraving right?
and resonance controls; 2 ADSR envelopes (one for amplitude and Or were you happy with the first output?
one for the filter); an LFO for modulation; modulations routings;
digital distortion; and keyboard setup controls. It took two attempts to make a laser-cut panel that I was happy
with. For this project I wanted to retain as much of the original toy
However, there are a few uncommon features of the synth's voice piano’s enclosure and physical character as possible; in fact, I had
engine. It has a State Variable Filter, rather than a simple Lowpass originally planned to attach the controls to the piano’s existing
Filter which is more common on commercial synths; the scale of wooden panel. However, after realising that the panel was too thick
notes on the keyboard can be changed (e.g. major, minor, blues) and brittle to work with, I started thinking about creating a new
instead of just being statically chromatic; and the keyboard can custom panel for it.
send MIDI polyphonic aftertouch messages for applying per-note
expression. However, the most unique feature is the ‘Vintage My first custom panel was laser-cut out of 3mm birch plywood, and
Amount’ parameter, which allows the synth to model/emulate old the plan was to paint it and label all the controls myself. I chose to
or even broken analogue synthesiser voices. I implemented this use plywood due to it being a similar material to that of the rest of
by doing what most “virtual analogue” synths do, which is to add the piano’s enclosure. As this was the first time I’d built something
Replacing the old timber lid with the new laser-cut panel. With this much wiring, it's always going
to end up resembling a snake pit.
with plywood I wasn’t aware of its susceptibility to warping. I Another big unexpected challenge was settling on a voice engine
soon found out though, because after applying paint, it ended up design, that would run on the BeagleBone Black without any
considerably warping, to the point that it was actually unusable. processing issues or overloads. I ended up having to scale back my
original voice engine design quite a lot, as it was too CPU-intensive
So, I got a second and final panel laser-cut, this time out of 3mm for the BBB. So I had to spend a lot of time testing different parts
black acrylic. Acrylic isn’t susceptible to warping, and by using of Maximilian - the C++ synthesis library I used - and redesigning
gloss-black acrylic I didn’t even need to paint it! Using acrylic the voice engine from the ground up, based on the performance of
also enabled me to get the control labels laser-engraved, which Maximilian and the BBB.
produced a professional-looking frosted white text, rather than
painting on labels by hand. Overall I was very happy with the final As I mentioned previously, the production of the synth’s panel was
panel - it looked a lot better than I imagined it would. also an unexpected challenge, due to issues with the first laser-
cut panel; however, I also originally planned to use second-hand
We’re huge fans of timber, any sort of timber, but that gloss acrylic “vintage” knob caps, but they proved to be difficult to find within my
is something amazing. It makes it look even less like a toy, and size and budget constraints.
more like a grand piano. Well... one with loads of knobs coming out
of it! Maybe a full-scale model is on the cards - we could put it in For someone claiming hobby-level electronics, you’ve done
our Super Size Me section of the mag? We’re joking of course. What extremely well to integrate the skills you have into physical
unexpected challenges did you face with this project? hardware. It’s certainly not the most elegant wiring job we’ve seen,
but it clearly works! You’ve received two awards via the Element14
The biggest unexpected challenge I faced was the development of Community Awards. Did you set out to enter these or was it
the panel electronics. The panel circuit required a lot of soldering, something you had been developing already?
but when it comes to electronics I’m very much at a hobbyist level,
so my soldering wasn’t always good enough. This resulted in me I had the idea for this project not long after completing my original
needing to replace quite a lot of the pots before I had a fully working USB-MIDI toy piano project in 2015; however, it wasn’t until the
panel. Also I wasn’t aware how much pot jitter and interference I Element14 Music Tech Design Challenge was announced that I
would get from having so many pots within a single circuit; so I had actually decided to attempt it. Therefore, I specifically started this
to play around a lot in software to help prevent this. project to attempt to win the Music Tech Design Challenge, but ››
›› the “Project of the Year” award from the Element14 Community They are particular useful for beginners as there are loads of official
Awards 2016 was just due to having the project documented on and unofficial tutorials, which help teach the fundamentals of audio
their website. synthesis in a practical way.
A bonus award - even better! If you had your time over, or if you On the other hand if you’re interested in building analogue
were creating a v2.0 of this project, what might you change? synthesisers, which obviously involve a lot more electronics, one of
the best resources is the “Music From Outer Space” website, from
There are a number of things I would change if I was to do this which the highly-recommended “Make: Analog Synthesisers” book
project again: was born.
• I’d try using a more powerful Linux- Thanks for the resources
based microprocessor than the Liam, we’re sure our
BBB, such as the Raspberry Pi 3, readers will appreciate
to create a more powerful and them. What are you
complex synthesis engine. The working on now, and is
main reason I used a BBB there anything else you’d like
was due to it being one of to share?
the Design Challenges
requirements; but it was Aside from my work at
also a really good option Modal Electronics, my
for what I needed to do. main project at the
moment is helping out
• I’d experiment with Moldover with one of
using other synthesis his projects. Moldover
libraries for developing is a San Fransisco-based
the synthesis engine. musician and musical
I chose to use Maximilian as it looked easy to use and provided instrument maker, also known as “The Godfather of Controllerism”.
me with all the synthesis components I needed. But as it is still I’m currently helping him develop the firmware for a new version
quite new compared to other synthesis libraries out there (e.g. of his augmented-microphone controller called the MC1. I’ve been
Pure Data, Csound, STK), I might have been able to get better following his work for many years now, so it’s a very exciting project
performance out of another library, allowing me to run a more to be working on. I’ve also been slowly working on some DIY guitar
complex synthesis engine on an embedded Linux platform. pedals, but I’ve got a long list of music-related projects that I’m
hoping to work on when I have the time or opportunity.
• I’d redesign the panel circuit to help prevent pot jitter and
interference, and I’d build it as a custom PCB, rather than as a Microphone controllers? Guitar pedals?
maze of hand-soldered wires! We can’t wait to see what you come up with! ■
• I’d implement built-in patch saving and load, rather than needing GOT SOMETHING TO SAY?
to use an external computer to do this. For more images or to discuss this feature, visit:
https://diyode.io/002ybqt
Sounds like v2.0 of the toy piano would be a sight to behold if you
ever do take it on. You clearly had significant knowledge about
synthesisers before tackling this project. For someone who doesn’t
have that background knowledge but would like to be able to put
their electronics interests to use in synthesisers and digital audio,
are there any resources or tips for where to start learning about Reading & Resources:
them?
► MUSIC FROM OUTER SPACE
The best resource is the “Computer Music Tutorial” book by Curtis http://musicfromouterspace.com
Roads, which is considered as a reference “bible” in the field of ► MAX
digital audio and related subjects. Another resource I thoroughly https://cycling74.com/products/max/
recommended, especially if you are not a coder, is Max, or its free ► PURE DATA
alternative Pure Data. These software applications are graphical https://puredata.info
programming languages and environments for developing audio
applications (as well as other multimedia applications) fairly easily.
Natural
Server
Cooling
Like many offices, at DIYODE we have a server room.
But like all server rooms, it requires cooling - and lots
of it! So... is there a better way? - by Rob Bell
I walked into the office early one morning, and it was freezing cold.
It was about 5°C outside, so that’s not really surprising. If you live in
a location where you can ski on lakes in winter, this may be balmy
weather for you. But here in beach-loving, sun-baking asphelt-
melting Sydney, that’s pretty cold to us.
As I walked past the server room to make coffee, I noticed the inside
temperature was still sitting at 20°C (and yes, the air conditioner
still has to work constantly to keep it there). It got me thinking... why
are we using air conditioning to cool the room, when it’s near-arctic
outside? In the same morning routine, the air conditioner in the
main office gets switched on so everyone isn’t at their computers
dressed for the snow. So
why can’t we leverage
this heat by-product
into something useful?
Even if we’re using 100%
renewable energy to
power everything, it still
seems like something of
a waste.
The primary issue with server hardware (and virtually all electronics) A quick look at ventilation fans for high volume air transfer, proves
is heat. As we know, all electronic circuits produce some amount how much this is true. We looked at a 400mm unit, which is capable
of heat (even if it’s imperceptible in a simple circuit). In most of moving 128m3 of air per minute. That might sound like a fair
circumstances, the heat is insignificant when considering the amount, but the second you add ducting (or even a simple pipe
room it’s inside, and it can easily dissipate. In an environment like bend for that matter), the volume capability drops rapidly. It also
a server room, however, we have an extremely high concentration requires a 1500W motor to begin with. If you need a larger fan than
of electronics in a relatively small space. For that matter, my “very this, you’re rapidly matching or surpassing the power consumption
standard” media centre at home (standard cheap graphics card, of a suitable air conditioner. We’ve also used a few of these large
single Intel i7 processor) quickly shuts down after a few hours of ventiation fans at times, and they are really noisy!
being placed inside an entertainment unit, yet we rarely think too
much about keeping a standard computer cool. The mathematics required to provide specific answers to this
question is a little beyond the scope of our thinking here.
Servers often have high velocity, noisy fans to keep the air moving Consideration needs to be given to the amount of heat being
through their critical parts. Facebook is one of the world’s largest generated by the servers, the size of the server room itself,
data centre operators (not surprising now that they boast over two the temperature differential between outdoors and the target
billion users). They’ve worked hard to keep all those cat videos temperature, the volume of air you can transfer (i.e. the size and
and photos of your lunch flowing through the internet; but more capacity of fans extracting the heat), humidity, barometric pressure,
importantly, have taken great steps to increase efficiency within friction/pressure incurred in the ducting, and the list goes on.
their data centres. For this reason, they don’t use front panels on But we’re confident an engineer familiar with air conditioning or
their servers, to increase the amount of air that can get through thermodynamics could tackle this with little issue.
them. Air flow through the server is critical, but if the room starts
heating up that air will extract less and less heat from the servers, Now, in experimental scenarios we’ve run our server rack in the
due to the lack of a temperature differential. main office, which is huge. The sheer volume of air in the office
allows the temperature to be maintained at a sensible level. But
So if it’s all about the air flow, all we need to do is pump the cold enterprise-grade server equipment is extremely noisy, so this isn’t a
air into the server room (or suck the hot air out), and all will be right feasible solution either. Sure, you can put noise-reducing insulation
with the world - yes? Sadly, it’s not quite that simple. around the server rack to reduce the noise, but then we’re back to
the original problem of air flow.
THE COLD HARD REALITY
This article isn’t designed to deliver a solution; it’s moreso a thought
In theory, with the ability to move an unlimited volume of air experiment, and will probably forever remain as one. Although,
rapidly through a server room, you could keep everything within as we know, sometimes brilliant ideas arise from seemingly
tolerance until the outside temperature is just 1°C below your target unresolvable problems... ■
temperature, only then requiring air conditioning to take over. But
fans use power too... and big fans especially, use a lot of power. GOT SOMETHING TO SAY?
There is, therefore, an efficiency point where moving huge volumes To discuss this topic, visit:
of air requires more energy than an airconditioner, which artificially https://diyode.io/002yvxj
improves the temperature differential.
SECURING
SUCCESS WITH
SOLID SOLDERING
Quality soldering can make the difference
between a successful project, and hours of
frustrating fault-finding. This instalment of
FUNdamentals should help you ensure smooth
results for your next project. - by Daniel Koch
As someone who has been involved in electronics for many years, What this means is that not all solders are equal. Plumbers’ silver
I have had a great many kits and scratch projects presented to solder, for example, is meant for high-strength, high-pressure
me with a plea for help in finding out why it won’t work. Without situations, and so contains silver. This makes it very hard and makes
exaggeration, around 80 per cent of faulty circuits are due to poor the alloy’s melting point very high; high enough to need a hot gas
soldering. Most often, it’s a result of dry joints, but sometimes flame to melt it. Of course, both of these factors make it unsuitable
there’s debris inclusion or even attempts to solder incompatible for use in electronics. What is needed instead, is a solder with good
metals. While sometimes hard to spot, these issues are easily resistance to oxidisation that stays somewhat flexible, and has a low
avoided with a little extra knowledge. So, if you are just starting out melting point. Traditionally, this has been an alloy of 60% lead and
on your electronics journey, or if you’ve ever had a frustration with a 40% tin, referred to as 60/40 solder.
circuit, this information may be exactly what you need.
HOW IS SOLDER USED?
WHAT IS SOLDER?
Before you even turn on your soldering iron, there are several
factors to think about. Solder in electronics is not intended to be
1
an adhesive. Instead, it is there to reliably create a current path for
electricity to flow along.
Elements in their natural, pure state, which are already balanced, Flux does two jobs:
are said to be inert. Atoms of materials that have too many electrons
are called negative ions, and too few electrons leading to a positive • It cleans the surfaces, which, by reacting with light oxidisation and
charge from the excess of unhappy protons, results in a positive cleaning away contaminants, results in a bright surface; and
ion. It is the opposite ions that seek each other out, so that they can • It excludes oxygen from the joint.
hold hands and be happy! However, this isn’t always easy. Many
pure metals don’t have anything around them to bond with, so they However, just as all solders are not equal, neither are all fluxes.
snatch ions from the air. Oxygen is great at taking up this offer, Many people have seen plumbers’ or metal workers’ flux, which is a
hence oxidisation, which is the term for corrosion from free oxygen thin liquid that is applied separately before soldering copper pipes
atoms. For this reason, metals are blended to become as neutral or galvanised metal. This should never be used near electronics.
as possible, and the result is an alloy. However, it is sometimes not
possible to produce an inert alloy, when other factors in the end use It is a corrosive product, unsuitable for use near components, and
of the alloy are considered. Other materials may be used too – such needs to be cleaned after soldering to prevent corrosion, which is
as carbon – which when alloyed to iron, produces steel. often impossible to do on a circuit board. ››
2 4
Rosin Core
Extruded
Solder Wire
1mm
3 5
›› Electronics solder contains cores of something called rosin. Rosin The aim is to introduce enough heat to heat the joint quickly and
is a blend of chemicals specifically formulated for use as a flux melt the solder, while not putting in so much that things get cooked.
around electronics. It is important to always check that the solder
you are using is rosin-cored [2]. Here is another critical point: insufficient heat means that the
heat gets drawn away from the joint faster than it is put in. In
The next point to consider again relates to the fact that solder is not this scenario, the joint never reaches temperature or takes a long
glue. Always try to make a mechanical connection before soldering. time to do so; however, in the meantime the component is being
With wires, this may mean twisting them together [3]. heat-damaged. So ideally, you need to strike a balance between a
temperature and power that will heat the joint quickly and then be
With components on a circuit board, this means bending the legs at removed, yet without introducing too much heat. Unfortunately, this
a 45-degree angle once they’re inserted through the circuit board, is often a matter of experimentation. Remember, metals are good at
so they cannot move easily. [4] conducting heat as well as electricity
In the case of integrated circuits, it is often sufficient to bend one Adding the actual solder to the joint is the real art, and often another
leg at each end, diagonally opposite, to hold the chip in place. reason that people come unstuck. The correct procedure is to add a
little solder to your iron’s tip – just enough to allow a better surface
Once a mechanically sound, clean connection is ready, you can heat area to conduct heat. Wipe the soldering iron on the wet sponge,
up your soldering iron. The choice of equipment here is critical. then hold the solder against the two surfaces to be soldered (not
A 120W sheet metal worker’s soldering iron will dump so much against the iron tip), and allow the joint to heat up. When it reaches
heat that the circuit board will be destroyed. A 25W circuit board temperature, the joint will melt the solder, allowing it to flow into the
iron will never heat a 4-gauge car audio power cable. For reasons relevant places. [5]
such as these, one of the best pieces of equipment you can own
for electronics is a soldering station, which allows a variable Then, withdraw the iron and solder at the same time, and wipe the
temperature setting. iron clean. What you should see now is a smooth, shiny surface that
appears to be seamlessly joined to the circuit board surface and
component leg, or to both wires. If there are cracks, a dull surface, Whatever you choose, remember that most solder has lead in it
or a volcano-like crater at the top or a line around the bottom, the (note: the wisps of vapour you often see from a soldering operation
joint is likely not making a good connection [6]. In which case, is actually the rosin).
reheat, remove the solder, and try again.
All that remains now, is to trim the component legs off your board.
SOME HELPFUL TOOLS This is best done with a pair of small side cutters that have a flush
cutting surface (not a bevelled one). You should trim closely to the
There are some things that make soldering much easier. The first solder but not cut into the solder.
is a solder sucker. These are available in both spring plunger and
squeeze bulb form. Simply reheat the joint, position the desolder This information will hopefully help you succeed in your soldering. I
tool near the joint and trigger. The solder should largely be removed. could wax lyrical about it, but for now I’ll await your feedback, which
may well result in more information being provided down the track.
The second helpful tool is a set of helping hands. These are a metal I certainly intend to visit the topic of lead-free solder soon, as it is
frame with clips to hold the circuit board or pair of wires, allowing vastly different to work with. In the meantime however, the points
both your hands to be used for holding and carefully applying the here should get you well on your way. With a bit of practise, you’ll be
iron and solder. creating sound, solid, shiny solder joints in no time! ■
The final piece of equipment is a fan or fume extractor. This can be GOT SOMETHING TO SAY?
as simple as a fan directed so as to suck air away from your face, to To discuss your soldering techniques, visit:
help ensure you avoid breathing in the toxic lead soldering fumes, https://diyode.io/002xxkr
or it can be as complex as a carbon-filtered desktop fume extractor.
6
Component leg bent at 45°
Solder bonded to leg but not pad Solder bonded to pad but not leg Solder properly bonded
Solder Pad
Circuit Board
Resistor
MAKEBLOCK MBOT
BLUETOOTH® ROBOT KIT
mBot is an easy-to-assemble robot kit packed with sensors
to avoid obstacles, follow lines, play soccer, and more.
Control using the included remote or from your Smartphone
or Tablet using the MakeBlock app. The intermediate user
can program using simple drag-and-drop programming
$
199
blocks, and the advanced user can program with the
Arduino® IDE (Same processor as the Arduino® UNO).
There’s heaps of online resources for teaching and learning
about robotics, programming and electronics. Kit contains
38 parts, remote control and a detailed user manual. KR-9200
FROM
$
39 95 9
$ 95
9
$ 95 $
34 95
ea
$
29 95 9
$ 95
$79 95
DISPLAY IT ADD STORAGE
Allows you to easily program and operate your Arduino project over Wi-Fi
and allow it to access the Internet. The on-board Linux computer is based
on the Open WRT firmware, giving you access to a multitude of built in 9
$ 95 $
29 95
functions and downloadable software packages. Connect a 3G dongle to
provide connectivity for your Arduino on-the-go, and use it as the basis LIGHT IT UP! COMMUNICATE
RGB LED strip. Daisy chain up to 1000 Bluetooth® V4.0 BLE Module.
for your next IoT project. Wi-Fi, Ethernet, USB and Serial interfaces. Web LEDs run from one pin. 256 brightness Configurable as master or slave.
configuration interface. 77 x 54 x 26mm. XC-4388 levels. 5V. 54mm long. XC-4380 Provides a serial communication
channel. XC-4382
3
$ 95
/m 7
$ 95
8
$ 95 $
13 50
Enhanced
We all know that you tend to get what you pay for. So Paul wasn’t
terribly surprised when his cheap K40 laser cutter/engraver didn’t
quite perform to his liking. But rather than chalk it up to experience
and put up with low quality output, Paul decided to develop a
Lasers
solution.
How long did you have the K40 before you realised it wasn’t really
up to the tasks you were hoping to put it to use on?
Actually from day one when I got the machine. There were no
instructions, and the dongle I mistook for a USB stick with software
that I couldn't find. The eBay seller did give me some links with
Chinese software LaserDRW/Moshidraw. Unfortunately I could
PAUL DE GROOT not cut a decent frame for a project since I had to design it within
Business Architect, Sydney LaserDRW. Next to this I never managed to get the engraving to
www.awesome.tech work at all. First thing I did was to find the K40 community on
@PaulDeGroot Google+, who all said the controller was rubbish and suggested I
replace it with a decent DSP controller (i.e. expensive!).
What if you could take a cheap laser So it seems the community identified that the bones of the units are
cutter/engraver unit, then design a plug-in actually quite good; it’s the controller that’s letting it down. What
replacement so as to increase accuracy and were the problems you were having with the original unit?
improve performance? Paul did...
The software/operation of the machine was causing me grief. The
X-Y axis gantry hardware is pretty sound. The power supply is very
basic with no over-current protection, so you can easily damage it
when changing the stepper electronics. For example the 24V can
only deliver 1A, and anything above that will blow up the rectifier,
Hours of real-world testing was done.
which is simple to fix.
postage, and just for my own use, I wanted has three jumpers that allow you to select Gerbil - we love it! What specs have now
to get it nicely installed, so I decided to the appropriate PWM pins, so the shield is improved as a result of the changes?
design a new PCB shield, which worked very compatible with the standard UNO and my
well. Then other people started to ask for new controller. Standard Grbl allows AMASS (adaptive
one, so I gave the remainder away for free. smoothing algorithm), which means it runs
My next issue was engraving; 8 bits (256 The next hurdle was to find the right at big steps for straight lines, but increases
values over the full power range) did not combination of PWM settings: frequency its step resolution for arcs and curves.
allow many grey levels. So my next logical 50Hz to 50kHz, phase correct, phase and So basically the K40’s motion system has
step was to help people to achieve better frequency correct PWM or fast PWM. I improved just by using Grbl firmware. My
engraving quality. To do this, I created a new tested about 60 combinations, of which only added value to this is the laser resolution.
controller board to replace the Arduino UNO. four worked. The best frequency for the CO2 I allow 10bits engraving, which allows
tube was about 160Hz, and I made sure that precision engraving over a tiny range of
We hate ugly tarballs in our hardware too. the PWM has a base PWM train signal, so as the laser power (2mA range is divided in
Have you upgraded steppers and other to keep the gas excited and energised at all 256 grey levels while the laser range is 0 to
hardware, or simply the controller? times during the engraving. This prevents 20mA).
the latency in igniting the laser operation,
It’s a complete solution based on the and extends the lifespan of the tubes (not Wow - 256 grey levels is amazingly fine for
ATmega328PB (different AVR from the UNO), being switched fully on and off); all big a cheap laser cutter - that’s awesome! If
with a shield plus StepSticks stepper driver laser manufacturers use this this energising you had your time over, or were creating a
boards. The old Chinese M2Nano controller trick. Furthermore, the zero position of V2.0 of this project, is there anything you
is in the bin... the machine had to be changed from top/ would change?
left to bottom/left to be compatible with
Sounds like a good place for it. Did you have Inkscape and the G-code sender (CNCjs). I have used it for over a year now and it’s
any unexpected hurdles along the way? Additionally, I had to extend the resolution been extremely reliable. So I decided to
of the engraving Inkscape plug-in (from do a Kickstarter but ran into the cost of
The biggest hurdle was to design a new 250dpi to 381dpi) in order to match the the project. My new shield now uses only
controller that would run the open source engraving quality. I also had to rewrite the SMD components, which reduces the cost
Grbl with the laser features. I had to port G-code generation to make it compatible of assembly. That’s the only way to make
the Grbl code, modify it to allow 10bits with Gbrl’s G-code dialect. By the way, I call it economically viable. Also I would like
engraving, and then reassign the function the controller “Gerbil” after Grbl’s firmware. to incorporate the G-code sender into the
pins since the first USB/UART occupies the Americans at the Bay Area Maker Faire Inkscape plug-ins, so people don’t have
10bits PWM port. Fortunately, the 328PB suggested that name when I presented the to use two programs; instead they’ll have
has two USB/UART ports, so I moved the controller in May. You can read more about an integrated toolchain (requested at the
communication to the second USB port so this faire in my blog. Maker Faire by some makers). ››
as to get access to the PWM port. The shield
Testing prototypes. The prototypes saw several iterations. Cutting complex plastics is also possible.
›› THE TWO PROGRAMS ARE: My new batch is hand soldered boards just to test the BOM since
the first batch parts were ordered by PCBWay. Also the Arduino IDE
1. Inkscape to produce laser engraving and cutting G-code files. did not natively support the 328PB but that’s solved now with the
2. A G-code sender to send those files to the controller. latest IDE version.
If the Kickstarter is a huge success I might do this as a stretch goal. Sounds like you've overcome those issues for sure.
Tell us what you're working on now?
That’s great you’ve had feedback from real users at the Maker
Faire, and have actual information in which to base your Kickstarter At the moment I am working purely on the logistics of the
on. What unexpected challenges did you face designing Gerbil? Kickstarter. Creating and testing the BOM. Ordering the SMD
components and testing that it all works. Then I’ll start working with
Lots of people could not get the ATmega328PB to work properly a manufacturer to produce the end-stop conversion brackets, I’ll
because the original full swing on board oscillator of the AVR has flash the boards, test it again, and then pack it up for shipping. After
been replaced with a simpler circuit to make room on the chip die that I’ll shoot a video to explain the project. This has been a very
for the additional registers and functions. So simply replacing an old challenging element for me, as I don’t have any media experience;
AVR from an Arduino UNO with the new AVR does not work. I tried so it feels pretty clumsy.
that many times until I read the avrfreaks forum. The solution was
a better designed external xtal (oscillator) circuit close to the chip Well, at the time of writing your Kickstarter has just launched, and
according to the forum, so that’s what I did. Most of the remainder it’s already off to a cracking start. We wish you the best with it, and
circuits are identical to the UNO except for the USB chip from FTDI. look forward to hearing about all the K40 owners benefiting from
I want to make the USB driver install as easy as possible for my the integration of Gerbil to their units! ■
users who are mostly makers, hobbyists and mums/dads garage
businesses with few IT skills. GOT SOMETHING TO SAY?
To leave your comments or for more images
I ordered ten fully assembled controllers from PCBWay and and link to Kickstarter, visit:
amazingly they all worked on arrival. I sent them to beta testers. https://diyode.io/002fnkv
IT’S CONVENIENT.
Each issue automatically
unlocks on our website, for
hassle-free access to resources,
commenting, and more.
CANCEL ANYTIME.
Unsure you want a full
12-months? Go monthly and
cancel any time!
SUBSCRIBE TODAY:
diyode.io/002subs
Tweet
The
World
Want an easy way to interact with
users, the world and your fans?
Tweet it! Using just an Arduino UNO
and an Ethernet shield, you can
easily add the ability to tweet any
piece of information or data.
- by Oliver Higgins
One of the fundamental things we consider with the projects here Of course, let's consider things for a minute... Twitter may not be
at DIYODE, is how we deliver information to the user. Serial outputs the answer! If you're sending private information or any sort of
and LCDs have their place, but you are not always in a position to information that's potentially sensitive (such as, there's nobody
be looking at the physical unit. This is part of the appeal, and the home right now), it's probably not a good idea to use a public
drive behind the rapid uptake of the Internet of Things, which is the service to do the talking. If you're automating public information
tech buzzword of the decade. Not just in the maker space. So how specifically, or you're tweeting information that's not sensitive at all,
can we deliver information from a remote location, with minimal then it provides a great, reliable platform. Those 317 million active
overheads that the end user will be able to access and use, without users rely on Twitter to be live virtually 100% of the time. For that
requiring any additional knowledge or training? reason, you can rely on it too! ››
›› HOW IT WORKS decreases until it reaches 8, at which point it will send a tweet,
and when it returns to 3, it again tweets the drinks special.
Let’s back up for a minute and look at Twitter’s infrastructure. Finally, we have the third button, which when pushed, sends out
At its simplest Twitter is an XML feed. That’s all, remember RSS a preprogrammed tweet.
(Really Simple Syndication) – or am I just showing my age here?
THE BUILD
The developers at Twitter took this a step further, and opened
the world to microblogging. They took a small story of just 140 PARTS REQUIRED: JAYCAR ALTRONICS
characters, and gave us a way to pull the data we wanted to see 1 x Arduino UNO R3 XC4410 Z6240
out of the stream. Feedback from the users soon resulted in the 1 x Ethernet Shield XC4412 Z6242
introduction of hashtags. The famous # now creates a channel of 3 x Tactile Switches SP0608 S1112
ideas or content, which allows individuals to find the information 3 x 10kΩ Resistors RR0596 R7782
they are interested in, very quickly and consistently.
SOFTWARE REQUIREMENTS:
The Internet of Things (IoT) has sprung up in a huge way over Arduino IDE
the past few years; however, to create a positive community Twitter Library
user experience we need to have a front-end that will allow them
to interact with your device. This can be difficult and very time BUILDING THE CIRCUIT
consuming to build, but by using Twitter, you can easily output
information to anyone who wants it. The initial sketch requires no circuit. Simply connect the Ethernet
shield into the UNO, connect Ethernet and power cables. The
The crew here at DIYODE have felt that we should open a bar. system will attempt to send a single "Hello World!" tweet, then
This place will be pretty exclusive with a limited amount of sit idle until you restart it. It's the simplest way to test that your
room for patrons. Now we understand that you will all want to access via the Twitter API is successful.
come, but you may not want to wait in line to get in. To address
this, we will be instigating an Arduino-powered doorman. The The main sketch has three buttons. Place them one after another
role of this doorman will be to count how many people come in on your breadboard. Connect the 5V and GND rails to the
and out. Abiding by the legal building requirements, of course, Arduino. Connect up the three resistors, which will pull the pin
when the bar is full it will send a tweet to all our followers, to let to GND on the pins when the button are not pressed. Connect
them know. Once some people leave we will then tweet again, the GND and 5V connectors from the breadboard rail to the
to tell our followers that there is now some available space. switches. Finally, connect the switch to the Arduino, pin 2 is the
Almost full? There’s a tweet for that too! Drink specials, $2 Sonic “send tweet” button, while pins 5 and 6 are the count up/down
Screwdrivers! #youknowyouwantit switches.
You’ll need the Arduino and Ethernet shield (you could also use
a WiFi shield with some modification). You’ll also need to have
three switches: the first will be the “in” counter; the second will
be the “out” counter, and the final switch will be used to deliver
a message to the followers, such as drinks specials or other
announcements
THE SETUP
#include <SPI.h>
The first requirement of this project is to setup a Twitter account. #include <Ethernet.h>
If you already have one then great, otherwise go to Twitter and #include <Twitter.h>
follow the prompts to sign up. It's probably worth noting that byte mac[] =
even if you do have an account already, it's often useful to sign { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
up for a new account dedicated to your IoT explorations. It will Twitter twitter(“YOUR CODE FROM STEP TWO”);
keep your twitter account clear of all the clutter you'll likely put char msg[] = “Hello, World!”;
named the bar the “Mosfet Cantina”. Feel free to follow us @ Ethernet.begin(mac);
Over the last few years, Twitter has increased its security and if (twitter.post(msg)) {
so it’s no longer quite as straight-forward to merely put in your int status = twitter.wait(&Serial);
developer program to get our OAUTH token. OAUTH is used to all Serial.println(“OK.”);
Programming Interface (API), without revealing your username Serial.print(“failed : code “);
We will not go into depth here about creating an app from } else {
scratch; instead, we’ll use one already provided by the Arduino Serial.println(“connection failed.”);
community. }
}
CREATING AN ACCOUNT
void loop()
1. If you don’t already have a Twitter account then create one. {
bio.
2. You need to be logged into your Twitter account then go to Hook up the breadboard and put the 5V and GND rails to the
http://arduino-tweet.appspot.com/ to create a secret key. Arduino. Connect the 3 buttons as per the diagram.
3. Connect the Arduino, Ethernet shield and RJ45 cable. Button 1 is our “send” button. This could be used to send a
random tweet to all our followers, but in this case, we’ll simply
4. Make sure the Twitter library is installed on your development be sending a predefined text message. This code is very similar
machine. We have provided it in our resources also. to the code example above, but adds into the loop a part so as to
check the button.
Now let’s test it out with a simple tweet. Make sure you insert
your secret code from step 2 into the “Twitter twitter” line. Button 2 increases the pplCounter Integer; button 3 decreases
it. It returns to the loop and checks the pplCounter button
You should get a tweet sent from your account saying “Hello against certain thresholds. If it is equal to them, then it sends
World!” Be mindful if you try to repeatedly tweet the same out a preprogrammed message: “Sonic Screwdrivers $2
message again, the API will give you an error. You must change #mosfetcantina #nightlife”. It then sets the “msgSent” integer to
the message or wait for a while before resending the same one. 1. As the loop comes back again, it checks to see if the msgSent
is 1 or not. This way we don’t resend the message over and over
Note: When using this, there are some limitations on how again. Once a button is clicked again, the msgSent variable is set
many tweets can be sent and how often. You can send as to 0, and the counter loops again to check if it is required to send
many as you want, but if you fire them off too quickly then another message at this level. ››
the Twitter API will begin to limit you. You may also overload
the Arduino.
Let's Do
Something Different:
›› What if you don't own a bar? What if you don't care how many BUILDING THE CIRCUIT
people are in your building? What if you just want to automate Only a few wires are required, as well as the DHT11 sensor. Load
the whole process? the Twitduino_DHT_0_0_4.ino sketch onto your Arduino (provided
in the resources).
Let's look at a different application, while still using the Twitter
platform. Every 2 minutes, your Arduino will tweet out the current
temperature and humidity. Easy! As noted previously, Twitter
In issue #001, we used the DHT11 Temperature / Humidity tends to automatically disregard duplicate messages that follow
sensor, displaying the output to screen in our Arduino Web too quickly. So if during testing your tweets don't seem to be
Server project (https://diyode.io/001dngx if you'd like to check getting through, this may be why. Of course, keeping an eye
it out). on your serial monitor while you test things out will provide
generous feedback on all that's happening.
What if you could get tweets for the temperature of your home
brew? Or when it gets REALLY cold? The DHT11 can do that. WHERE TO FROM HERE?
THE BUILD If you wanted to expand this project, you could easily add an IR
trip beam or laser sensor to button 2 and 3 on the real door at
ADDITIONAL PARTS REQUIRED: JAYCAR ALTRONICS your home or shop. You could then add in an extra variable to
1 x DHT11 Temp/Humidity Sensor XC4520 Z6320 count in the total traffic and tweet it at the end of the day.
ADDITIONAL SOFTWARE REQUIREMENTS: The current code presents a very hard line in the sand, so that
DHT11 Library when you hit 10, it tweets. Therefore, if you had 11 people and 1
left you return to 10, which automatically fires off another tweet.
The code could do with some fuzzy logic to decide if patron
numbers are on their way up or down, and to build in different
thresholds.
WANT MORE?
To grab the code or leave your comments, head to:
https://diyode.io/002rpbv
$ 95 $ 19.95 NeW!
X 4201 5 Dioptre
X 4200 3 Dioptre
Modular
Aluminium
NeW! 3D Gesture Control
$ 49.95
Z 6308
12V LED Strips For Raspberry Pi®
SaVe $20 Perfect for lighting cabinets and workspaces in
caravans, 4WDs etc. Strips can be daisychained
FlickHAT is a 3D tracking and gesture HAT that lets you control
the Raspberry Pi with a swipe, tap or flick your wrist. Detects
together using an included joiner. Provide a crisp 975 your gestures up to 15cm away in 3D space. Also works as a
lumen output from 2835 size LEDs. 25Wx10Hx500Lmm. tap/touch sensor pad.
89
phone on the go! 5V 1A output, 5600mAH. Includes stand & USB lead.
$ X 3216A
SaVe 20% NeW! Single Colour
LED Strip Lights
Now in blue and yellow! Sold in 5m rolls in
either indoor or IP65 rated waterproof. Great
for adding atmosphere to your entertaining
area. 12V DC input via 2.1mm DC jack.
Create amazing light effects! T 2173
$ 23 Model Part Normally NoW
Magic RGB strip lighting with a huge array of colours and
effects. Sold in 5m rolls. IP65 rated for outdoor use. Great for 30pc Precision Driver Kit Blue 5050 Indoor X 3209A $54.50 $44
adding atmosphere to your entertaining area. 12V DC input. An aluminium driver with rotating ferrule top for easy Blue 5050 Waterproof X 3205A $64.95 $52
Requires X 3219 controller and IR remote to suit $19.95. servicing of high tech devices. Includes 70mm exten-
X 3228 pack of 10 tubing clamps to suit $5.95. sion and 28 x 4mm hex bits. See web for contents.
Yellow 3528 Waterproof X 3207A $50.50 $40
350
FETs, IGBT, regulators, zeners and diodes. Provides
$ SaVe $45 a huge amount of technical data on each part and SaVe
25%
provides pin out info. 2 year warranty.
T 2052 Designed & made in the UK.
$13.65
$ 28
Q 1126
$ 12 Compact 19 Range DMM
Small enough to fit in your pocket, this 19
range meter offers plenty of features for the
enthusiast on the move. Backlit display with
T 4015 data hold & temperature measurement.
Never lose a tiny screw again!
This magnetic workmat keeps those tiny screws and wash-
ers in place when servicing. 25x20cm. Includes marker. Magnetic 3 in 1
LED Work Light
Features a mini flood
T 2169
Micron® Combo Soldering light, top mount spot
torch & SOS beacon.
& Vacuum Desoldering Station $24.50 Requires 3xAAA
Save space on your bench with this top performing 60W soldering iron and 90W vacuum batteries (S 4904 2pk).
desoldering station. Removes a 16 pin through hole IC in 30 seconds! Sucks molten solder
away from components & pads in no time and is easily cleaned. 160° to 480°C adjustable. 17pc Ratchet Driver Tool Kit
$ 20 NEW!
Includes 0.2mm soldering tip and three desoldering tips. This ultra compact ratchet kit is ideal for working in tight
spaces inside equipment. Supplied with phillips, pozi,
$ 19.95 X 0223
torx, flat blade and 1/4” drive sockets.
Powered tools
T 2494
$ 59 $ 33 T 2492 SaVe
SaVe 15% 22%
Midi Blow
High Power Torch SaVe 20% T 2480
35
Blow Torch Perfect for hobbyist
THOUSANDS SOLD!
Super hot 1350°C
use (it shrinks
heatshrink, then gives $
flame! Handheld you a nice crust on
or self standing your creme brulee!). All heat & no flame!
design for tasks such Handheld or self Iroda® Pocket thermo-gun. Great
as heatshrinking, standing design. for removing adhesives & paint.
model making, Easy to refill using 650°C max. Refillable. SaVe 22% tHiS MoNtH
silver soldering! Iroda butane.
Easily refilled. All
aluminium design.
Iroda® Butane
4 Pack
Stock up the workbench
$39.95 $55 $79 $119
with this value pack of
SaVe 20% quality double scrubbed $ 30 $ 42 $ 60 $ 92
butane. Doesn’t clog your
tools like the cheap stuff! T 2595 70W T 2590 80W T 2598 100W T 2630 125W
28
T 2488 T 2451
Produces a powerful jet like flame - up
15
general purpose soldering and occasional repairs. T 2598 and
to 1300°C! • Great for hobbyists
• Adjustable flame • Refillable • One $ $ SaVe 12% T 2630 are great for field techs. Plenty of power and capacity
for bigger soldering tasks. All can be converted into a flameless
click ignition • Diecast case heat gun, hot knife or blow torch with additional tips.
$49.95
SaVe 15%
$ 39 NeW!
30
T 2186
$ Do-It-All Precision Screwdriver Set T 2282
T 2555 Featuring 56 precision tips made from tough molybdenum va-
Magnifier Head Goggles nadium steel. Huge variety of tips with extension bar and clear
storage case. See website for contents.
$ 13.95
- Get a close up view!
Offers 1.5, 2.6 and 5.8x magnification with The Pocket Hero is here!
in-build LED lamp. Requires 2xAAA’s (S 4904 This nifty 12 in 1 pocket sized saviour helps you fix lifes
$4.95 2pk). little problems then folds up to the size of a pack of
gum! Includes belt pouch.
T 2367
T 1090 0.5mm
T 1100 0.8mm $50
Ultra-Quick
39
T 1110 1.0mm
T 1122 1.6mm $ Strippers
These easy
Nifty Multi-Angle T 5036 $19.95 squeeze, spring
$29 $39.95 loaded, auto wire
any 2 for
Bench Vice
Made from diecast alloy.
Double Sided $ 22 $ 15 T 2355 strippers will re-
Parts Case
$ 25 Clamps to your work bench and
provides total 360° freedom Perfect for working in the field! The Nibbler
move insulation on
cable instantly. $22.95
Quality Resin Core Solder 15 compartments on one side, Cut holes in 1mm steel, plastic
Premium grade for leaded soldering. 200gm
when working. Jaws open to
55 mm. Includes soft jaws for plus 10 removable containers on
the other side.
and 1.6mm aluminium. Great for
making one off chassis panels etc.
1.0, 1.6, 2.0, 2.6,
3.2mm2.
$ 18
reels. 60% tin, 40% lead. holding delicate connectors. T 1526
Air Powered
Buggy Kit
45
Forklift
$
Rover
Requires no batteries, electric
motor or any conventional K 1136
Gripper fuel to make it drive. Use the
air pump to fill the bottle, Hydraulic Powered Robot Arm Kit
then let it go and watch it This lever controlled water powered robot arm uses hy-
3 In 1 All-Terrain Robot Kit fly! Travels up to 50m. No
Great fun for the kids to build and play with! This $32.50 draulic forces to twist, turn and grab! Lifts up to 100gm.
soldering or special tools Fun to assemble and use, this educational kit teaches
single kit can be built (and re-built) three ways!
Lifting capacity ≈100g. Wired remote control.
$ 25 K 1135
required. kids about physics principles and robotic motion.
NEW!
Builder Bitz.
Membrane NEW!
$27.95 Keypad
Great for access
$ 19.95
J 0902 Z 6393
control projects.
NeW! Standard
Adhesive backed.
P 1030
NEW! 69Wx77Hmm. NEW!
$ 13 .95 Z 6341
$7.95 5
$ .95
5
$ ea
J 0900 Ultra mini
Pull Type Solenoids High Torque MG995 Servo
Ideal for any project requiring a pulling actuator. A high speed metal geared servo with 7 Pack of Mini Coloured Breadboards
12V DC operating voltage. Full specs on website. 12kg/cm torque. Weighs 55 grams. 120 55 hole breadboards for instant solderless part connection.
degree rotation (±60°).
Prototyping
NEW! Strip Vero
9
$ .95
$69.95
Board
Easiest way to
build up quick
Z 6544
$27 Z 6394 $ 45 circuit prototypes or
DIY add on boards.
Run 5V circuits
from two AA
NEW! $20 Z 6392 Fingerprint Sensor 160x100mm.
batteries!
$ 12.95 Handy 30m W 2120
Lightweight SG90 Servo
Great for building your own
access control designs! Can store $24.75
Boosts the voltage output of two Figure 8 Reels A great micro servo for lightweight up to 20 prints via 360° recog- 5 for
AA batteries to 5V - suitable for powering
shields, sensors and controllers.
Red with black trace. 7.5A
rated. Great for DC wiring.
robotics applications. 180 degree
rotation (±90°). 3.5-6V operation.
nition. You can even download
prints from the device.
$ 20 H 0712
Prices valid until august 31st 2017 | 1300 797 007 | www.altronics.com.au
Find your nearest reseller at: www.altronics.com.au/resellers
© Altronics 2017. E&OE. Prices stated herein are only valid until date shown or until stocks run out. Prices include GST and exclude freight and insurance. See latest catalogue for freight rates. Please Note: Resellers have to pay the cost of freight and
insurance and therefore the range of stocked products & prices charged by individual resellers may vary from our catalogue. B 0088
FEATURE
DANCING
IN THE
(LED) LIGHT
Ray’s discovery of the Adafruit
NeoPixel light strip was almost by
accident, but a happy accident.
RAY ABRAM
Embedded Software Engineer
from West Auckland, NZ
›› That’s definitely a simple and elegant solution. How many Sounds like something work tackling. Perhaps some Li-ion
preprogrammed routines do you have stored in your PIC? batteries would do the trick, depending on your required runtime of
course. Have you programmed PIC micros before or did you learn
I have nine routines, each of which are selected by holding a button specifically for this project?
in (this skips to the next effect). The nine effects are:
I have done some contract software development for some
• Colour wheel companies over the years, so I have completed some very complex
• Just 1 red LED on moving forwards along the strip projects on PICs. This code was some of the easiest and more
• Just 1 red LED on moving backwards along the strip simple code I've written.
• Just 1 red LED on moving forwards then backwards along the strip
(like a Cylon’s eye from Battlestar Galactica) It’s so great when a plan comes together and all goes smoothly! You
• Crawling forward red LED effect mentioned some timing trickery to get the NeoPixel to accept your
• Crawling backward red LED effect code from the PIC. Can you elaborate on this?
• Crawling forward rainbow LED effect
• Crawling backward rainbow LED effect The protocol shown below is quite specific on its BIT timing. So to
• Fully random LED colour or LED sparkle effect get the PIC to control its port pin accurately, I used an oscilloscope
to show the pin. I just kept adjusting some timing loops in my
That’s quite a selection! We can see a tactile switch on the board - software until my software matched the protocol’s BIT timing. A PIC
is that to cycle through different sequences? running with a 48MHz oscillator is only just able to keep up with the
BIT timing requirements.
Yes, the tactile simply cycles through the routine currently in
operation. That’s fast! Did you face any unexpected challenges with this
project?
Your circuitry is amazingly simple, have you considered expansion
to sync to music from an audio source or microphone? For sure. Firstly, I wanted to calculate the colour for each LED just
before sending it out, but some of the effects took too long and
This could definitely be a future enhancement to the code. The resulted in only the first Neo Pixel working. It took a bit of thinking
original intention of the code was to create a unique LED light stick to determine the code was taking too long to calculate the effect,
for when I was at a Coca-Cola Christmas party in a park. I would so I needed to precalculate the LED colours into RAM and then send
need a large lead acid battery to run it, or a USB backup battery them.
pack outputting 5V.
A PIC18F45K22 and a handful of components. Minimal wiring is required to get NeoPixel running.
Secondly, the point where you connect the NeoPixel “data in” to the
Time Constraints:
PIC’s pin required a 100Ω resistor, which I did not fit at first, and this
resulted in the LEDs doing random things.
Thirdly, you need a large capacitor connected across the NeoPixel The NeoPixel strips require high precision timing. Many
to make them work reliably, which I did not have originally. This popular general purpose MCUs such as a Raspberry Pi or
resulted in more weird effects taking place. Arduino simply cannot handle the speed requirements.
I want to connect a grid of 32x256 NeoPixel LEDs to a PIC (or maybe T1H 1 code, high voltage time 0.8µs ±150ns
a STM32 CPU), so I can scroll messages across the LEDs; but I have T0L 0 code, low voltage time 0.85µs ±150ns
not yet started on this project. It is only at the ideas stage at this T1L 1 code, low voltage time 0.45µs ±150ns
That would be great to see. We hope to check it out once you have Ray used an oscilloscope to adjust timing loops until the
tackled it! Thanks for taking us through your NeoPixel project. ■ software matched the protocol's BIT timing. A PIC running
with a 48MHz oscillator is only JUST able to keep up with the
GOT SOMETHING TO SAY? BIT timing requirements!
For additional media, or to leave your comments, head to:
https://diyode.io/002swvt
VARIABLES
AND CONDITIONAL
STATEMENTS
Last month we introduced the overview of code
through the “Hello World” article. This month we A NOTE ABOUT SPELLING: You’ll notice that in Australia, we
will take a look and explain variables and conditional use British English, which spells “colour” with a “u”. Since
statements. Without these two things, our lives would code was developed with US-English spelling, all code
be boring and automated. They are 2 of the most languages (that we’re aware of) will drop the “u” and spell it
fundamental things in programming for they allow us “color”. This applies to web languages such as HTML / CSS
to do something. We struggled to come up with any / PHP which regularly deal with colour, as well as C, Python,
program that did not contain at least one of each of Java. We may use “colour” in the text, but if it’s in the code,
these. Okay, “Hello World” is one, kind of. we’ll always use “color” to avoid confusion. Unfortunately
- by Oliver Higgins code interpreters don’t yet have artificial intelligence, so will
rarely assume “colour” equals “color”.
Let’s start with variables. This is probably a poor descriptor if you We need to write a program that makes coffee cups. The users have
have not done any programming before. Simply put, a program informed us that in addition to yellow and blue they would like red
needs to do something. It needs to somehow get information from ones. So the program for this is pretty simple:
the outside world and look at it, manipulate it, and then give it back
to the user. It requires somewhere to hold this information. • Start program
• User enters coffee cup colour
If we are to step back a minute and look at the world around us, I • Coffee cup appears
have a coffee cup in front of me. It is canary yellow. (Actually it’s Big
Bird yellow). The only thing I am defining in the context of the coffee This program is quite simple and has one variable being the colour.
cup is its colour. At home, I have a blue one I bought from the same When we program, we need to have a place to define and hold this
shop. It is blue, (Cookie Monster blue, to be precise). Everything else information. We commonly refer to this as a “variable”. A variable is
about these coffee cups is the same. Now it may seem as though I something that we – the user or the program – can change during
am spelling this out, but hear me out. the program’s execution. In the example below, we define the
variable “color” and then ask the user to enter the colour that they
would like.
Declarations:
Let’s take a moment to look at the common variables you will use.
Depending on your chosen language, the declaration and instantiation
will be different. Some languages will figure out what you want by
what data you put in it the first time, where in others you may have to Now depending on your language you will need to declare the
be explicit. variable. In C you must be explicit. That is you must tell.
STRING/CHAR
Arduino
“Hello World” This is the string that we discussed last month. Put int x;
A string is one of the most common variables you will use. This is
how we will give real-world feedback to the users; for example, BEST PRACTICES FOR NAMING YOUR VARIABLES:
“Hello” in the example above. The only limitation on this array is the
available memory on your chosen processor. 1. Declare your variables with data if possible.
INTEGER, LONG AND BYTE 2. Use meaningful names such as Xpos or userName, not XX4
and y3e. A variable name should define its use.
1 or 73 or 42 or 7854 or -598. These are all integers. They are whole
numbers and are often referred to as counting numbers. They are 3. Avoid system keywords such as date, time, equals or data.
used for counters, loops and basic data elements. They occupy 16
bits and are used to store whole numbers from -32768 to 32767. If 4. Don’t reuse variables within the same functions or class.
your numbers exceed this range, then you will need to use a long.
5. Don’t use non-ASCII chars in variable names. It may work
A long is an integer that occupies 32 bits and, as such, can hold fine now, but may crash on other systems.
a much greater number range (please note: I am sticking with the
general rule of ANSI C. Most modern languages are a minimum of 6. Don’t use long names. Seriously you have to retype this...
twice this size for a long).
7. Stick to your naming conventions and case (i.e. don’t use
A byte stores an 8-bit unsigned number, from 0 to 255. This is often UserName, userName, username, USERNAME). Many
used for storing things like colour codes. If your memory is at a languages are case sensitive so this will lead to debugging
premium in your project, you should consider if your number will issues.
exceed this.
8. Declare it before you use it. This may seem simple, but you
would be surprised how often this error happens.
you use the variable. This will ensure that you do not get any stray
A NOTE ABOUT VARIABLES: Don’t waste space. One thing data. Not all compilers clean up after themselves, so they may
we repeatedly see in code is the programmer using strings just allocate a new piece of memory for you when you declare the
when they do not need to. It is much faster and uses less variable. If you read back, the variable before is used, so it is not
memory to use the correct variable type. The best example uncommon to find random numbers. Primarily this happens in C,
I have seen is where somebody declared a string to be and while it will probably not be an issue for you, best practice will
used for “yes” or “no”. While this may have meaning for the ensure it does not happen.
programmer or an end-user, they were using it to compare an
“IF” statement. A 3-letter string will increase the UNO’s global CONDITIONAL STATEMENTS
usage by 14 bytes, and its sketch memory by 4%. In addition
to this memory waste, it will make using the comparison We are all individuals. I’m not.
much slower, as the processes need to evaluate so much
more data. In many cases, a basic integer or even a BYTE will We need to make decisions, and even the simplest program will
suffice. need to evaluate some factors. The “IF” statement is the simplest
form of a conditional statement. Think of it as simply asking the
question; in our early example, we could ask the computer to do
›› Double is a very similar construct to float, but it occupies 64 bits something based on the colour of the cup.
so offers much greater decimal precision.
The English for this would be “if the colour is blue then tell the user,
VARIABLE SCOPE they are awesome.”
So does it matter where you declare a variable? Yeah, it sure does! PSEUDO CODE:
There are two important things you need to be mindful of. Firstly,
you must declare a variable before you use it (kind of). Secondly,
when you declare a variable makes a difference as to how it is If Color = blue then
accessible in the program. Take this example in C/Arduino: Print “You are awesome”
C/Processing/Arduino PYTHON:
int x = 0;
void setup() {
int y = 0; if Color == “Blue”:
x++; print(“You are awesome”)
}
PYTHON:
Note the double equals sign in the “IF” statement. This means, we
are comparing two things not assigning a value, as we did earlier
if Color == “Blue”: with the variables. ■
print(“You are awesome”)
else: NEXT MONTH: ARRAYS AND MORE
print(“You could be more awesome had you chosen
blue”) GOT SOMETHING TO SAY?
To discuss this edition of Secret Code, visit:
https://diyode.io/002brtm
Understanding Binary
To better understand how variables work, you need to The modern systems will use an 8-bit base 2 system, to store its
understand some basic binary function. Digital systems (Micros/ information. This 8-bit number is referred to as a byte.
PCs, etc.) store their information in a binary format. It is
expressed in 0s and 1s. This is base 2 math. As humans, we use 0 1 0 0 0 1 0 0
base 10 math, which is much easier for us to view but very hard 128 64 32 16 8 4 2 1
for a computer to store, express and process. A simple example
would be if we want to store the number 4. 4 in base 10 is simply This will allow you to store 256 numbers (0-255)
4 (base 10 counts to ten, then continues 9-10-11); however,
using base 2, 4 would be expressed as 100. Now you probably want to use numbers much bigger than this,
so you can continue it out to a 2-byte number or 16-bit number.
Each of these numbers presents a single bit. The first number on This will allow you to store a number as big as 65535. This is
the far right-hand side is 1. Now is the bit switched on or off? Is it referred to as an “integer”. It is a whole number (i.e. no decimal
1 or 0? In this case, it is off. We move on to the 2: is it 1 or 0? It’s points or fractions). To make it more useful, it uses a sign bit as a
0, so we move on. Next, we have 4: is it 1 or 0? It’s 1, so we have representation of positive or negative number. This results in the
a 4. Finally, we have 8, which is 0: so the only number is 4. number range of -32768 to 32767.
1 1 0 0
8 4 2 1
VIVID
IMAGINATION
Interactive Light
Installation at
Vivid Sydney
Many minds and hands came
together from CREATE UNSW
to produce an interactive light
installation that responds to the
person standing in front of it.
EXPLODED VIEW:
›› Wow, that’s quite a lot to coordinate; but you clearly pulled it off. We installed an RFID card reader towards the final stages of
Tell us a bit about how the installation works? construction, so that team members could trigger custom patterns
for personal occasions. For example, one person even used the wall
The wings and custom lighting patterns are generated in to propose to his partner!
Grasshopper, and are programmed into the installation using
Arduino code, which was written by our software team for a Teensy We absolutely love how it’s customised to the visitor, so everyone
controller. The software indexes each region of LEDs, which has a slightly different experience! Obviously much of your design
represent the triangular and quadrilateral shapes on the mosaic, process would have focused on materials, given it’s a large
using graphs to determine a particular region’s distance from a physical installation. What factors were considered when selecting
selected centre region. It then turns regions on or off, according hardware?
to a supplied algorithm. Distance is provided for the programmer’s
reference, and can be used to design and implement patterns such We took into account the fact the installation will be outdoors
as light radiating from a centre point, or striated lines travelling in and near a wharf, so we needed to make the installation and its
several directions across the mosaic. interactive components robust and easy to maintain. We chose all of
our components to be rated for outdoor weather (IP64 and above),
Infrared sensors installed vertically in the middle of the installation, from power supplies to LED modules right down to the sensors that
detect if there is a person standing in front of it, at which point the were used.
remaining LEDs fade out and reveal the wing patterns. Depending
on the person’s height, different sensors will be triggered and The electronic hardware for light control was kept minimal as well
certain combinations of triggered sensors will result in the base - normally for LED displays of this scale, people would be looking at
of the wings appearing higher or lower. The installation returns breaking out a laptop or some mini-computer to do video processing
to normal programming once the person leaves the centre of the in order to control the lights; but due to the location we were in, we
installation. had to use something that could be replaced cheaply and easily. ››
www.bosch-ebike.com.au
Wiring was no easy task. Testing a few of the 1550 LEDs installed.
›› The LED modules we used were IP68 UCS1903 lights, which can 3.3V to 5V nicely, and it comes with ethernet ports for the signal
be powered by common 12V power supplies and draw a maximum and ground pins of the LED modules, which helps reduce electrical
of around 0.9W per module. There are approximately 1550 LED noise. Its usability and robustness also makes it very easy to use
modules used for the whole installation, so its maximum power and replace.
consumption is around 1.6kW. To cater for the maximum power
consumption, we used four 400W outdoor power supplies. In terms of sensors, we tested a variety before settling on our final
choice, which was the E18-D80NK. We wanted something that can
The microcontroller we chose to use was a Teensy 3.5 - it had more give a binary reading, to save on additional processing times (as
I/O ports than we needed, a faster clock speed over the 3.2, and opposed to using a sensor that requires analog input, or a fancy
5V-tolerant digital pins, which we wanted for our application. We timing library). We also chose this sensor as it only uses three wires,
decided to manually map out all the locations of the LED modules, which makes the electronic installation easier.
and then group them into eight long strings. This enabled it to
be used in conjunction with the OctoWS2811 shield. While it is 1.6kW - wow! It helps give scale to this massive installation
technically possible to control the UCS1903 LED modules - using though! The PJRC Teensy sounds like it suited the installation well.
the 3.3V output from the Teensy I/O pins directly - it’s typically Obviously you didn’t tackle this whole thing by yourself; how many
recommended to use 5V logic for most of the addressable LEDs on people worked on the project?
the market, as this prevents issues such as signal deterioration.
The OctoWS2811 shield does the level shifting on the I/O pins from We had 18 team members, divided into three subgroups and
they were responsible for structural design, electrical design and
software programming. Construction was a whole team effort,
mostly led by the structural design group. Team members were
free to transfer between groups, or help others depending on their
expertise and prior experience.
For most team members, it was the balance of project work with
jobs, university assignments and other commitments. For the team
leader, it was managing the different schedules and logistics, as it
was her first time leading a huge team. The project was unusually
construction-heavy, and we had several design issues during the
Four 400W power supplies provide the 1.6kW required. build. While most of the issues were solved with improvisation,
much of the work was completed at the last minute.
There’s nothing like a deadline to get things moving! What was the
best part of the overall installation?
1. A
dd sensors on each side, and program the wings to shift
laterally, in addition to upwards and downwards. We did not
consider this option due to the technical complexities involved,
but given more resources, it would be a great addition to It's not all serious at CREATE.
Crystallise’s functionality.
2. D
esign a light source to illuminate the viewer’s face for
photography purposes. Currently, photography of people standing
in front of the installation requires diffused light that is pointed
away from the subject, so as to provide enough light to make
the subject’s face visible. However, we have found creative ways
of photographing people in front of the installation, such as
excluding background light and making the subject appear as a
silhouette in front of the artwork.
WANT MORE?
To discuss this installation, view more images,
or check out detailed tech drawings, head to: Testing during final stages of construction.
https://diyode.io/002zqfc
◄ LEFT
Crystallise in use.
SUPER
SIZE ME!
VAN DE GRAAFF
GENERATOR
Ever wanted to get 40,000 volts to fly through the air?
We’ll show you how to build a Van de Graaff generator
that will do just that! - by Daniel Koch
›› This is called “saturation” and no further charge can be built up. 2 x 160mm x 12mm x 3mm lengths of Aluminium Bar
This is the point where sparks will be at their biggest and brightest. 4 x 20mm Super Magnets
Most Van de Graff generators - ours included - have a smaller 1 x Polyester Cloth
metal sphere attached to the same ground as the lower brush. This (Big enough to cut, hem, and stitch a 120mm x 850mm belt)
allows the charge to flow back to where it came from, neutralising 1 x 100mm x 600mm Perforated Steel Bracket
the charge. This provides both a way or getting the charge to arc
reliably, and a way to discharge the sphere when needed. ELECTRONICS PARTS REQUIRED: JAYCAR ALTRONICS
1 x Arduino UNO R3 XC4410 Z6240
THE BUILD 1 x Electronic Speed Controller MP3209 K6008
1 x Electric Motor
Before we begin, I have massive thank you to send to my father, (Ideally with a 6.35mm shaft) YM2776 -
Lester, who is a fitter and machinist by trade. Like all builds, this 1 x Motor Coupling,
one had several iterations before the current design, and while (Ideally with 17mm outside dia.) YG2602 -
searching for off-the-shelf options, my dad manufactured - at 1 x 6m Black Medium Duty Hook-up Wire WH3041 W2261
short notice and under high pressure - several rollers, shafts, 1 x 1m Red Medium Duty Hook-up Wire WH3040 W2260
and housings so that I could, literally, get the belt rolling on the 6 x Red Eyelet Crimp Lugs PT4514 H2031A
initial prototype. Having said this, the project as it is presented,
is designed to use no specialist parts, so as to be well within THE HARDWARE CONSTRUCTION
reach of most makers. The DIYODE Magazine team are confident
that this would be suitable for an eager school team to build and, The parts list is to build the generator in the same configuration as
with appropriate guidance, within reach of upper primary school the prototype; however, there are other options. To start, search the
students. internet for a list of materials in the “triboelectric series”. These lists
vary, so search them until you come up with some materials that
MATERIALS REQUIRED: you can source. I found leather at a fabric and craft supply store,
2x1 500mm x 100mm x 50mm PVC Rectangular Downpipe polyester cloth from the same outlet, and silicon tape is readily
(For framing) available. However, the best belt material is surgical rubber, which
4 x Mounting Flanges for Downpipe can be hard to find in retail outlets. It can be found online, or your
2 x 125mm “Cotton Reel” Boat Trailer Rollers local brand-name rubber supply store may be able to order it for
2 x Shafts for the Rollers you. The rubber you use should be natural, but much of what’s on
2 x 20mm Electrical Conduit Joiners the market is synthetic. Be sure to avoid black rubber as it contains
1 x Glue-lined 20mm Heatshrink carbon, which will conduct at high voltages.
1 x Leather Sheet (to cover one roller)
1 x Roll Silicon Rescue Tape (Often called “self amalgamating tape”) We built a simple sturdy base to support the entire project. It’s just a
1 x White Plastic Chopping Board thick piece of MDF with pine glued and screwed to the outer edges,
1 x Metal Sheet Bracket to increase the strength of the platform. Your base can be adjusted
2 x Stainless Steel Mixing Bowls to suit your preferences. Once you have made your base you can
2 x Spherical Curtain Finials move on.
1 x 1.5m x 25mm PVC Electrical Conduit
30 x 20mm 6-gauge Chipboard Screws
8 x 35mm 6-gauge Chipboard Screws
Top view of our base board.
3 x 20mm 4-gauge Self-drilling Metal Screws, Button Headed
1 x 300mm x 90mm x 19mm Pine
2 x 100mm x 90mm x 19mm Pine
1 x Plywood or MDF, at least 300mm x 600mm x 19mm
1 x L-shaped Bracket (Suitable to drill and mount your chosen motor)
1 x Stainless Steel Mesh Frying Pan Splatter Guard
1 x 400mm Length of 40mm PVC Drain Pipe
8 x White 300mm Cable Ties
4 x 15mm M3 Screws
4 x M3 Nuts
8 x M3 Flat Washers
6 x M4 10mm Bolts
6 x M4 Flat Washers
6 x M4 Nuts
2 x 80mm x 12mm x 3mm lengths of Aluminium Bar
What you should now have is two pipes laying in front of you on their
Clamping side supports.
wider sides, with four plates of soft plastic mounted in them [2].
Next, lay them level and side by side, and remark the 120mm line
across them. Now, on one of the pipes, find the horizontal centre of
this line - top and bottom. Drill a 3mm pilot hole dead centre. Turn
over the pipe that will have the drive shaft through it, and mark the
same 120mm lines, top and bottom. At the centre, drill a 30mm or so
clearance hole. At the top, this will allow drilling of the second pilot
hole while at the bottom it will allow the drive shaft to pass though.
Next stand the two pipes in a flat surface. Have someone hold them
securely together while you drill through the pilot hole into the
bearing plastic of the second side. This will ensure a level shaft [3].
The greater the separation between upper and lower rollers, and
3
between ground and sphere, the more effective the Van de Graaff
generator. However, there comes a point where any gains will be
purely academic. Our PVC downpipe was cut to 1350mm, which
was half the available length. This material can be cut with a hand
saw, taking care to keep the ends square. Next, prime and glue
the mounting flanges into the ends of the pipe. Then, measure and Bearing plate with
pilot hole
mark a line across the 100mm surface, 120mm from the top and
bottom of each pipe. This will be the centre point of each roller. Bearing plate to be
Pilot hole
drilled
Now measure and mark a square to be cut out around this centre Clearance hole
point to provide clearance for the roller. Using a sharp knife, cut the (30mm)
square out of the downpipe by scoring along the lines several times,
Then drill a starting hole in the centre. Use pliers to peel and pry the Non-drive side PVC Drive shaft side PVC
downpipe frame downpipe frame
plastic, which should break along the score lines.
Rollers and shafts need a bearing of some sort. We used the soft,
low-friction plastic of a chopping board from a department store for
this. Measure, mark, and cut a piece to go inside the downpipe, then Now you are ready to drill a clearance hole for the roller shafts.
mark and pilot drill the screw holes. Next, slide the bearing plate into The top roller free rolls, while the bottom one is driven. For this,
the downpipe from the end, and attach with 20mm 6g chipboard we used a 150mm roller spindle for the top, and a 235mm spindle
screws. Start all four screws until they grip, then drive them home. for the bottom, which we purchased from the same retailer as the
rollers. Both are glued with liquid nails - the top one centred, and
the bottom one with just enough on one side to engage the bearing,
2
so as to leave a long enough shaft to pass through the downpipe, to
engage the motor. Cut the conduit joiners in half and place one half
on each side of each roller [4]. ››
80mm
4 Conduit Joiner
Half-Used as
Downpipe
Wall
Bearing
Flute
Outline of piece of Spacer
cutting board
Cut-out line
Drive Shaft
Passing
Screw holes
Through
120mm
Roller Glued
to Shaft
Here comes the tricky part. Manufacturing the belt is challenging for Unscrew the non-driven side of the frame, remove it, and loop the
someone with no sewing skills so seek help if you’re unsure - even a belt over the rollers. Reassemble the frame, probably with help as
clothing tailor in a shopping centre could probably do this for you in the tensioned rollers will need to be guided into their bearing plates.
a few minutes [5]. Spin the lower roller’s drive shaft by hand, to make sure if rolls
freely. If it does, all is well. If it doesn’t, check nothing is impeding
the free movement of the rollers. If they don’t spin freely you risk
5
burning out your motor, or shredding the rollers.
SIDE VIEW CROSS SECTION
Measure the flat section of the rollers between the ramps, and
6 1 1
double this number. Then measure the distance between the rollers. 2 2
Our total length was 1040mm from the outside of each roller. Fabric
6
does not come wide enough to go this entire distance, so two
halves of the belt will be made and sewn together. However, the 7
fabric stretches a lot, and our final belt was 800mm long, giving a 5
total length when opened out, of 1600mm. Our fabric was 1470mm
4
wide; however, if you purchase 2m, you can make a belt with just 2 2
one join. 8
3 3
Carefully mark a piece of fabric long enough to complete the
loop around the rollers, and wide enough to be doubled over and
1M 3 Nut
hemmed. For our prototype, this was 120mm. Start with a long 2F lat M3 Washer
3M 3 x 15mm Bolt
length for the belt, and cut out bits until you have the right tension. 4 Eyelet
Ours went from 2080mm to 1600mm. Start by hemming each side 58 0 x 12 x 3mm Aluminium
61 60 x 12 x 3mm Aluminium
of your strip, then fold the edges in to the middle. Stitch them down 72 x Layers of Mesh
the length of the belt according to the diagram. Now stitch the ends 8M ounting Screw
›› Now the bracket at the top of the mixing bowls can be added. This its grub screw. Pass the wire down the inside the 20mm conduit,
was made from a 100mm x 600mm length of perforated general and attach an eyelet to the other end. Now use the grub screw to
purpose mending bracket, from a major hardware store (in the same mount the finial to the end of the conduit, bulking up the diameter
section where you find corner and shelf brackets). Measure the with tape if required. This forms the grounding rod used to draw an
distance to the outside of the flanged mounting brackets at the top arc or to discharge the sphere.
of the downpipe frame, taking care to make sure the top roller spins
freely. We used six M4 mounting screws to mount ours through the The eyelets on the wires from the discharge rod, the grounding
existing holes in the bracket and flanges. This secures the top of the sphere, and the lower brush are now anchored together with a
frame and provides a magnetic mounting point for the bowls. 20mm chipboard screw on the base board. The grounding sphere
sits on the ground when the generator is in use, allowing electron
High quality stainless steel is not terribly magnetic. Even 20mm transfer to occur.
supermagnets did not stick well to our bowls, so we stuck ours
with strong double-sided tape, covered over with gaffer tape. This FINISHING TOUCHES
formed a strong but removable mounting for the bowl to sit on top
of the frame. The final step is to add spaces that keep the belt centred on the
rollers. These are 95mm lengths of 40mm PVC drain pipe, secured
Mount the brushes into the PVC downpipe, using a 20mm self- with cable ties near the rollers. These are critical for the belt to be
tapping screw in each straight. You may need to trim the brushes, held centre. In the “where to next” section, there are ideas for more
but this allows an amount of adjustment so that the brushes can be complicated but effective ways of belt centring.
made to sit just above the belt. Take a length of black hook-up wire,
making sure it’s long enough to go from the top brush to the bottom That completes your Van de Graaff generator! Check over the photos
of the sphere, and crimp an eyelet to each end; one is attached and diagrams provided, and get testing! You really don't need to
under one of the nuts and washers already on the brush assembly. follow our construction method too closely if you don't want to.
The other gets attached to the bowls with a self-drilling metal screw. The important aspects are using the right materials, and using
Cover this screw with gaffer or insulating tape. The top of your conductive or non-conductive materials - as appropriate.
generator should now be nearly complete.
WHERE TO NEXT?
At the base of the unit, the other brush is secured the same way. It
must be under the roller, and using an eyelet, a length of hook-up Those who possess or have access to machining equipment and
wire is attached and reaches all the way to the far end of the base source material, will benefit from custom-made parts. Rollers with
board. a convex crown could be custom made, as well as shafts and shaft
couplings. Motor connection could also be geared or belt-driven if
DRIVETRAIN / ELECTRONICS CONSTRUCTION you are familiar with such processes. This would be more reliable
and effective, but is out of reach of many makers.
The last step in generator construction is to mount the motor and
connect it to the belt drive shaft. Slide a 50mm piece of 20mm Further, a surgical rubber belt or tubing would possibly add
diameter glue-lined heatshrink over the drive shaft. Then screw effectiveness to the unit, although we were unable to source and
down the motor bracket in the position described in the construction test this in time (genuine rubber is quite expensive too).
paragraph above, and slide the heatshrink to cover the shaft
coupling and the shaft. Shrink it down, rotating to keep the fit even. Adjusting the position of the brushes may yield different results,
When cold, this creates a strong, yet flexible bond. You can now and it is worth noting that commercially-produced Van de Graaff
screw down the motor bracket. Solder connecting wires of red and generators have the sphere mounted over the top roller and brush
black hook-up wire from the motor to the speed controller, and from assembly. This is more effective, but harder to achieve unless you
the controller to the power supply. We used a 7.2Ah sealed lead acid possess the metal working skills required to cut the high-carbon
battery; however, a strong enough plug-in supply would work. The steel and clean the edges.
exact details here will depend on your motor choice.
Construction could also take the form of acrylic frame sides of
All that is left now, is the grounding rod and grounding connection. a single thickness, rather than the rectangular tube of the PVC
At a major hardware supply store, we found a pair of spherical downpipe; however, for structural integrity, front and back panels
steel curtain finials around 50mm in diameter. Remove the screw would need to be added.
from one, detach the tubular frame, and wrap the stripped end of a
500mm length of black hook-up wire around the screw; then firmly The ultimate way of achieving belt centring is with shafts mounted
screw it in. The other end of this wire gets an eyelet. Repeat this to ball bearings in adjustable housings. These are hard to source
procedure on the other finial; however, this time, use the remaining and use if you are not familiar with them, but anyone working
length of black hook-up wire, and retain the tubular connector and around machinery will know them. They are a housing that allows
WANT MORE?
To ask questions, leave comments,
and for plenty more images:
https://diyode.io/002vhvg
THE CLASSROOM
AC/DC
ROCKS ON
Not the band, but perhaps the band’s electric
style, is more than simply their name. Where does
the name come from? In their own words – “High
Voltage Rock and Roll – I like it both ways!”.
- by Daniel Koch and Bob Harper
Before you can tackle ac/DC, you need to also understand another
measure of electricity; the concept of electrical pressure, or
electrical potential.
Current flow and electron flow are actually the same physical effect. That means it had a PD of 9V. If I connect two 9V batteries together,
Originally, electricity was thought of as some kind of magic charge, so one negative terminal is connected to the other’s positive
and the charges were different, so one was called a positive charge, terminal, there will now be 18V across the outside terminals.
and the other a negative charge; it was true for so long that it However, there will still only be 9V PD across either battery. Now, PD
became the convention. is the difference between two points, but the term ‘voltage’ refers to
the value of that difference; naturally, the voltage of a 9V battery is
When physicists finally discovered electrons, and electron flow, 9V. However, voltage may also refer to the voltage above or below a
it was found that the electrons flowed opposite to the previous reference point, such as the voltage of the earth itself – also called
convention, so after some years of argument, physicists decided “ground (GND)”. Being the largest possible reference to us humans
to accept that there is conventional current flow, even today simply who live here, GND is always considered to be zero volts [3].
called “electric current”, and “electron flow”, which by convention,
flows opposite to the electric current [1].
3
9.0V
It is confusing, but as long as you remember that current flows DC
from the positive of a battery to the negative of a battery, and
electrons flow from the negative to the positive, you have it sorted.
Most of the time electricians do not think about electron flow, and
electronics people do not think about current flow; just remember,
both are the same in every way except the perceived direction of
flow. It is only when dealing with electrons themselves that a person
needs to be careful. In electronics, electrons are everything, and
in electrochemistry, ions are everything; but in the electrical trade,
current is everything. Earth
While the number of electrons passing a point determines the This is fair enough, but remember it’s only a reference point. If I
current, and the coulombs of energy that is stored determines the connect the negative terminal of a 9V battery to GND, and measure
charge, there is one more parameter to be dealt with. Every physical the PD at the positive terminal, it will read 9V positive (+ve). However,
system has the same basic measures: the energy storage, the should I connect the positive of my other 9V battery to ground, the
energy flow, and the pressure that drives the energy flow. negative terminal will read as minus 9V, or 9V negative (-ve).
In electrical systems, that is called the “EMF” or “electro-motive Between the unattached terminals of the two batteries, there will
force”, or the “force that motivates electrons”. EMF is usually not be a PD of 18 volts, yet there is no more than 9V PD between any
known, except in electrical and science circles, but another name terminal and ground. This fact will prove very important, when we
for the same measure of electrical force is known. The “potential investigate three-phase electricity and the domestic electricity
difference” or “PD”, is the difference between the electrical force at distribution system [4]. ››
different locations, usually within a circuit.
4
No doubt you will probably have heard the term “voltage”, meaning
the number of volts (V), usually across a battery, which most of us
18.0V
are aware of by our teenage years. A 9V transistor battery – the little DC
rectangular one – had 9V between the positive and the negative
terminals [2].
9.0V 9.0V
DC DC
Earth
›› To summarise, voltage is a measure of the potential difference On the other hand, or in the other corner of the fight, ac could
between two points measured in volts, and the potential at any be generated at almost any voltage, fed into a transformer to be
given point depends upon the EMF of that point. converted into a much higher voltage, transmitted to the consumer,
where it was again fed into another transformer to be converted
AC/DC back down to the preferred voltage. Overall line losses have
improved over the years, but were always a small percentage of the
Okay, I almost forgot to mention ac/DC, right? Well no, we simply generated ac power.
needed these reference points first. Notice that despite the band
T-shirts always appearing as “AC/DC” or “ac/dc”, I have written WHY WAS THE POWER LOST?
“ac/DC”. This is because lower case is used when the parameter
is changing, and upper case refers to parameters that remain The final parameter that you need to understand regarding basic
essentially the same (ref: AS1104 - Electrical Nomenclature). electricity, is “resistance”. Every material known to man, at normal
operating temperatures at least, has resistance. According to some,
The voltage on the 9V batteries we have been referring to are DC resistance is the opposition to current flow. I prefer to think of it
values. That means “direct current”, or that the current will always as the toll paid by the current, for passing through the highways
flow in the same direction. Some think it means that the voltage will of electric circuits. In essence, electrons land on atoms giving off
not change but that is not correct. The battery will eventually go flat, their elevated energy as photons of light, or heat, and require more
but the voltage will always be DC, even when we charge the battery. energy from the battery or power supply for another electron to take
To charge the battery the current must flow the other way – in the that place. The resistor gets hot in the process, thus burning up
opposite direction – but it is still a direct current, even though it has energy [5].
changed direction. Additionally, the positive terminal of the battery
is the same polarity (i.e. still positive even though the current has
5 Photons are released when
changed direction). electrons crash into atoms.
TRANSMISSION OF ELECTRICITY
EDUCATORS NOTE:
Electricity is only good if it is readily available when and where
you need it. The Edison vs. Tesla debate (Issue #001) ended when Here is a great experiment to prove Ohm’s Law and
Edison’s DC system was unable to convey power more than a few demonstrate the value of understanding the basic functions
miles from the power generation plant. The DC had to be generated (linear equation) in maths. Take a number of materials, and
at a voltage equal to the voltage required at the load end, where measure voltage required to push a range of currents through
the electricity was to be used plus the voltage that was lost in the those materials. Tabulate the results and graph them, then
transmission lines. As transmission lines grew longer, more energy prove Ohm’s Law is a Linear Relationship: Y=MX+C or V=IR+0.
was being lost in the lines than was being used by the consumer.
History of Electricity:
How Much
Power Is Lost?
- by Bob Harper
Edison has two options: use the same lines, in which case
he sends 10A over 2000m at 0.0192 Ohms/m and loses
10x2000x3.84 = 384V. He therefore must generate 484V
@ 10A or 4840W to deliver 1000W. Of course, the second
option is that he could start with a bigger wire. He needs
to use 2km of 100mm Cross Section Cable, just to equal 1:10
Transformer
Tesla’s efficiency. Do the maths!
Copper weighs 8.94 tonne per cubic metre. How much would
those cables weigh? What cost?
RESULTS:
Prototype to
Production...
MIGHTY
MICROS
When it comes to electronics, collaboration
can generate some truly amazing results. The
Micromite Explore-28 is one such example.
INTERVIEW WITH
ROBERT ROZÉE Four people, spanning three different countries (Australia, New
Electronics Engineer from Christchurch, NZ. Zealand, and the United Kingdom), have come together to take a
simple PIC prototype into a full functioning, powerful production
board. We caught up with Robert Rozée from New Zealand, to take a
close look at the Explore-28.
GRAEME RIXON For those of us who aren’t familiar with using PIC micros, for
Electronics Engineer from Dunedin, NZ. practical purposes, what’s the difference between a PIC and, say,
www.rictech.nz an Arduino?
The first Micromite used an MX150, containing 128k of flash Micromite helps take the pain out of PIC programming. Do you lose
memory and 32k of RAM. This was just enough space to squeeze a anything (such as speed or efficiency) when using MMBasic over
complete floating-point BASIC interpreter and full-screen editor into, Assembler or other compilers?
leaving around 20k of flash for holding the user’s program and 20k
of RAM for variables. There are always compromises. Certainly one can write far more
compact code in Assembler (or C), and it will run much faster.
Soon after Geoff created the Micromite, Microchip released the Remember, BASIC is an interpreted language and so will always
MX170 with double the flash and RAM (256k and 64k respectively), be 20 or more times slower than Assembler. But BASIC has some
enabling a good deal of “wiggle room”, which was quickly distinct advantages, which can more than make up for the slower
consumed by the addition of 64-bit integers and support to drive speed and larger memory requirements.
small colour touchscreen displays.
For a start, BASIC is much simpler to learn, and this can lead to a
The largest flash/RAM combination offered at the time by Atmel, considerably shortened development time for your project. For the
in a DIP package, was 128k of flash and 16k of RAM in the 40-pin hobbyist this is especially true where a project that might take six
ATmega1284. That was it. There was no roadmap leading beyond months of learning (in Assembler or C) may never even be started.
these constraints, and so any 1284-based Micromite would be Compare this to perhaps a few days of development if the same
pegged at just 4k of user RAM. The 1284 also has a maximum clock task was coded in BASIC. Sure, the BASIC program might be slower,
speed of 20MHz, while the MX170 goes up to 50MHz. and use more ‘computing resources’, but does this really matter?
From tinkering with Micromite BASIC over the last few years, I can
While other manufacturers offer single-chip devices with more say with some confidence that in the vast majority of hobbyist
flash and RAM, none of them (that I can think of) currently offer projects, speed and size of code are of no importance. Indeed, this
the same quantities of flash and RAM in a pinned package as does also holds true for many commercial projects - computers, from
the PIC32MX line from Microchip. For the hobbyist those little pins the biggest right down to the tiniest, have advanced to the point
that can plug into a solderless breadboard are pure gold, far more that computation resources are only ever an issue in quite rare and
important than any philosophical discussion over chip architecture. specialised cases. ››
›› In cases where speed is absolutely essential, MMBasic does If we are talking about an MX170 running an MMBasic program
allow the user to embed within their BASIC code, and call C or MIPS that could also be rewritten in C for the 328P (the 328P has 32kB
Assembler routines that have been pre-compiled and converted of flash and only 2kB of RAM available, compared to 59k of flash
into hexadecimal format. These are called “C-functions”, and and 52k of RAM for MMBasic programs and variables respectively.),
the feature has been used to great effect by Peter Mather to add the C code will almost always be faster than the BASIC code. But
support for various colour LCD displays, additional software serial as I have said earlier, speed is not nearly as critical today as it was,
ports, and to directly manipulate on-chip peripherals. Some of these say, 10 or 20 years ago. MMBasic provides many non-speed related
C-functions are distributed with the language documentation, while advantages, such as ease of learning and speed of development, as
the most popular ones have ended up being incorporated directly well as inbuilt support for a number of different peripherals that the
into the MMBasic interpreter by Geoff. While creating C-functions is beginner may want to start out experimenting with. For instance, a
not for the faint-hearted, and there are some limitations to what a single statement can read a DS18B20 temperature sensor, another
C-function can do, the facility is there. can write to a two-line LCD display module.
Another plus for the Micromite is the ability to very quickly If we are talking about an MX170 running C code, then the MX170
experiment and directly see what happens. In the hobby sphere, will easily outperform the 328P. The 328P is an 8-bit core running
Arduino is often considered the benchmark. Now don’t get me at 20MHz tops, while the MX170 is a 32-bit core running at up to
wrong, I do believe the Arduino ecosystem is great, but because the 50MHz. The MX170 has 256kB flash and 64k RAM, while the 328P
code is compiled, there is always the compile-download-run cycle has 32kB flash and only 2kB of RAM. The MX170 is a far larger and
to go through. If your code compiles but doesn’t work correctly it more sophisticated bit of silicon, while costing only twice the price
can be extremely difficult to figure out why - the little computer your of a 328P (US$4 versus US$2 from Microchip direct).
code is running on is not very “accessible”; you cannot easily look
inside the 328P processor on an Arduino board and see what it is The reason for the two answers is that the Explore-28 board does
doing. So for the beginner, this limitation can be daunting. not have to run MMBasic. There are projects such as Pinguino and
chipKIT (with a PIC32 core extension) providing an Arduino-like
With the Micromite you, the programmer, are much more intimately experience. It is quite conceivable that either of these could be
connected with what is going on inside the chip. You can type in adapted to work with the Explore-28 with little effort.
code and instantly see what the results are, and if your code does
crash then the MMBasic interpreter ensures that it does so fairly THE EXPLORE-28
gracefully, and gives you a good measure of feedback as to where
things came unstuck. This has always been one of the big pluses for Running on MMBasic, with the form-factor of an Arduino Nano,
interpreted languages such as BASIC or Python. the Explore-28 provides the speed and efficiency of a PIC
microcontroller, but can be programmed directly from your USB port.
Instant feedback is definitely useful, especially when learning. In We continued the conversation with Rob Rozée to talk more about
terms of application speed and functionality, what’s the benefit of a the E-28 and how it came together. ››
MX170 over an ATmega328 (Arduino Nano)?
›› Anyone with a keen eye looking at the pictures of the board will To be honest, it’s something I had in mind right from the very start
notice, the E-28 uses two PIC micros on the one board. Can you and so it was a process of continual and slow evolution. If I were
detail the role of the 16F1455 in the board? asked to provide an exact moment I’d have to say 20 April 2014
at 5:43pm, which was when I started a thread on The Backshed
The 1455 provides two specific functions that the MX170 cannot Forum, titled “Simplest 32MX150 ICSP” . This forum is talk-central
perform itself: for all things Micromite.
1. It works as a USB to serial bridge using the open-source M-Stack Geoff’s first release of Micromite BASIC for the (then) MX150 had
USB stack. The MX170 does not have onboard USB itself, so in amazed everyone. Previously there was his Maximite BASIC (running
most cases when working with a bare DIP MX170, you would on an MX695, VGA output, PS/2 keyboard and programs stored on
need to use something like an external CP2102 bridge module to an SD card), but the Micromite stripped back the hardware even
connect to a PC. further, to the bare minimum - one chip and one capacitor. However,
some folks were struggling to get the firmware into the chip, and
2. The 1455 also contains an implementation of ‘ASCII ICSP’. I could see that the existing solutions were beyond the abilities of
This is a protocol that allows the 1455 to be used to upgrade many MMBasic enthusiasts. So, I started the aforementioned thread.
the MX170’s firmware using a programme called pic32prog
(https://github.com/sergev/pic32prog) . I developed ‘ASCII ICSP’ I’d worked with Arduino before, and had been impressed by the all-
specifically to allow easy uploading of the Micromite firmware in-one nature of the whole Arduino system. It significantly reduced
to the MX170 after seeing the complexity of using the official the barriers to tinkering with tiny computers, but there were still
Microchip solution - the MPLAB X IDE (a 400MB download) and a some hurdles (and nasty hidden potholes). Some people managed
PICkit 3 that costs around $50 from Microchip. Micromite BASIC to brick their Arduinos due to a small design flaw that was finally
is always evolving with new enhancements and bug fixes, and rectified in the UNO rev3 but never publicly admitted to by the
from very early on users were having to deal with this expensive designers; and while the Arduino IDE does a great job at taking care
and complicated firmware update process. of much of the drudgery of programming in C, there are still barriers.
For example, C is simply not that easy to understand for the non-
As it happens, originally “ASCII ICSP” ran on an Arduino Nano. My programmer, and an Arduino sketch that fails is not very pleasant
code for the Nano was converted by Peter Mather to run on the to try and debug. While lots of people do great things with Arduino,
1455, and then integrated with M-Stack by Peter, through a long lots of people also walk away due to frustration.
chain of emails between us running back and forth around the
globe. So, I set about trying to bring together the advantages of the two.
This required following several threads, or “lines of enquiry”:
Thank goodness for the internet - imagine going through that
process via post! What is the biggest benefit of this setup, over • Software to upload PIC32 firmware
using the MX170 on its own? • Firmware to interface to the ICSP port on the MX170
• Hardware components to sit between the USB port and MX170.
The biggest benefit is having one simple-to-use package that
contains everything, much as an Arduino board “contains The forum thread kicked off several solutions, and proved that some
everything”. The MX170 runs Geoff’s Micromite BASIC; the 16F1455 quite hopeful approaches were simply not viable. The task of talking
provides the USB to serial bridge as well as a very simple means to an ICSP port was (just) beyond the ability of simple bit-banging
to perform firmware upgrades; and an onboard regulator provides solutions - alas, a USB to serial bridge on its own was not sufficient.
a regulated 3V3 supply (MMBasic assumes a 3V3 supply for the
onboard A/D converters to read right). The process followed through several stages, along with a few
breaks of several months at a time. Getting in touch with Serge
The MX170 in a DIP package is a marvellous solution for many Vakulenko was a major turning point, as he helped me get set
applications, and those pins are what I feel make the Micromite up to add ‘ASCII ICSP’ support to pic32prog. At the same time I
magic. The Explore-28 simply expands upon this, and helps open used a spare Micromite to act as a crude programming head - this
up MMBasic to those who perhaps aren’t so confident plugging the enabled me to get the software sorted without the final firmware
necessary parts together, or whose application fits with the all-in- and hardware. Once pic32prog was sorted I took a break of a few
one solution. months, then moved onto the firmware and hardware, in the form of
an Arduino Nano, five resistors, and a zener diode. The firmware was
So you’re using two chips to still gain that simple connectivity. an Arduino sketch (C code) to translate a stream of ASCII symbols
That’s great! When did you realise this was a winning combination (essentially eight letters: d,e,f,g,D,E,F,G) into clock and data pulses.
and wanted to move from prototype to hardware? This was then published as a Silicon Chip Magazine article, and after
that I stopped again for a few months.
While Peter and I got the 1455 code working, I built the prototype. I Those prices are definitely very accessible. Why would someone
posted photos of this on the forum, and not long afterwards Graeme choose an E-28 over something such as an Arduino Nano? ››
›› There will be some cases where an Arduino Nano is the best Sounds very robust to us. Are there any improvements still to come?
choice, there will be other situations when an Explore-28 is the
better option, and there will be scenarios where a bare MX170 is We are all still waiting for Microchip to release an MX190 with
ideal. There is no one solution for every situation. double the flash and double the RAM. Geoff Graham is actively
developing Micromite BASIC, and with the ability to easily upgrade
My first piece of advice would be that if you find the Arduino a little firmware, the Explore-28 is in a position to take advantage of this.
intimidating, or have tried using the Arduino system in the past and Apart from a few minor tweaks to the PCB layout, I am hoping that
struggled, then give the Explore-28 a go. The board is quite cheap, the Explore-28 will be able to remain stable and unchanged in
and the learning curve for Micromite BASIC is extremely shallow. design for quite a while. Really, it is a very simple device that would
be difficult to improve upon.
Micromite BASIC also has some very nice built-in features that may
require a bit more work to get going with an Arduino. There are The one thing I would like to see happen, is for someone in China
64-bit integers, a full set of floating-point maths routines, support to pick up on the design and make clones. The compiled Micromite
for a number of neat devices available as single commands and, of BASIC firmware is free to distribute, and everything else in the
course, an intimacy that only comes with an interpreted language. Explore-28 design is open source. If clones flooded the market at
All you need to talk to any Micromite is a terminal emulator such as US$5 each I’d be absolutely chuffed - the more the merrier!
Tera Term, so it is a very lightweight development environment.
Robert, we thoroughly enjoy (and appreciate) your open-source
That said, even if you are a seasoned engineer working in a approach with the Expore-28. We’re excited to see where it goes in
commercial environment, you may still favour an Explore-28 (or DIP the future! ■
MX170) for certain things. For example, if you want to quickly whip
up something in half an hour, then a Micromite solution may be WANT MORE?
ideal. Often speed of running code is not a big issue, whereas speed For additional code files, or to leave your comments, head to:
of development is. Even if you plan on moving to different hardware https://diyode.io/002vdns
later on, a Micromite is a good test platform on which to experiment
with ideas and create mock-ups. Bear in mind, I used a Micromite
to create the first ‘ASCII ICSP’ programmer before migrating it to an
Arduino Nano and then (coded by Peter Mather) to a 1455.
Want to get an Explore-28?
That’s a great point. So often as a hobbyist we’ll look at tech specs
without giving too much thought for development time itself. What Check out these retailers to see if they ship to your location:
are some practical uses for the E-28, out in the wild?
► RICTECH LTD
Like the Arduino Nano, the Explore-28 is tailored to applications https://rictech.nz/products/20/
where the device is going to be tethered to a USB port. This may be ► CIRCUIT GIZMOS
collecting data from peripherals, that is then processed and passed https://circuitgizmos.com/gizmo-store/#!/
on to an attached PC. Or it may be controlling attached devices - Micromite-Devices/c/14171441
Micromite BASIC supports controlling RC servos, has a couple of ► MICROMITE
spare serial ports, along with I2C and SPI busses accessible from https://micromite.org/shop/micromites/explore28/
BASIC. Whereas a PC running Windows, Linux, or OS X can not
sensibly run applications in real-time, a Micromite is simple enough
that it can. Millisecond timing is possible, which is often perfectly
adequate for interacting with the physical environment. Frequencies
up to 300kHz can be measured, as can the time between pulses.
Reading & Resources:
Another practical use is in a teaching environment. While it is all the
rage to talk about teaching kids object-orientated programming, ► PINGUINO
I see great value in taking a step back and concentrating on wiki.pinguino.cc
algorithms and interactions with the physical world. Initially, ► CHIPKIT
BASIC was developed as a teaching tool to open up computers to http://chipkit.net/tag/arduino-ide/
non-technical users, to enable them to process data; and this is http://chipkit.net/wiki/index.php?title=ChipKIT_core
a task that the Micromite is well suited to, extending to include ► THE BACKSHED MICROMITE TOPIC
the collection of data from sensors and controlling devices. The www.thebackshed.com/forum/forum_topics.asp?FID=16
Explore-28 provides this in a cheap and relatively robust package.
Part 1:
Alarmduino
Ever wondered how alarms work? How do they know
that somebody is moving or how to detect a broken
window? Want to set up a custom alarm system that
can be tailored to your needs? How about we add
IoT capabilities to provide remote access to alarm/
disarm, or even open a door? - by Oliver Higgins
INTRODUCTION
A modern alarm system can very easily amount to thousands of we place our detectors. In its
dollars. On top of that, back to base monitoring and fees can be a simplest form, imagine we took
costly exercise. While DIY kits exist they are often not tailored to a wire out of pin 20 of the Arduino,
exactly what you need to suit your application. An alarm consists of looped it all around our house and
three basic parts, the inputs, outputs, and control unit. We will be then joined it to 5V on the Arduino. (I
using an Arduino Mega as our control unit, and add various inputs have omitted the real circuit for the sake
and outputs to make a custom alarm system that can work off as of explanation). We check to see if there is 5V
little as 5V. The system can handle multiple inputs and outputs and on pin 20. All good? Yes, the Arduino goes off and
is designed to be a starting point for any custom application you checks the other loops, then comes back to the loop
have in mind. We have broken up this project into two logical steps. on pin 20? Still 5V? Yes? Let’s continue. The closed
The first is circuit design and prototyping. Part 2 will enable remote loop will continue to be fine until it is broken. When the
access and enhance functionality, as well as put it into a tidy case Arduino detects that there is no longer 5V present on pin 20
for real-world application. the system trips the alarm and triggers the outputs. This way
we can have multiple “breaks” in one loop. The magnetic reed
THE BROAD OVERVIEW window/door switch is like this. We wire them into a daisy chain
with several linked via the normally closed (NC) option. If any of
The modern alarm is quite simple, however the logic is not always them get triggered, (i.e. opening the window moves the magnet
easy to follow. The alarm has a straightforward task, check to away from the switch) the entire loop is triggered. We can have
see if something has happened that should not be and if it is, do multiple loops, and these are referred to as zones.
something about it, Pretty simple? It is a little more complex, but
the premise is correct. An alarm system will have several different Once the system is triggered through these zones, we need to
types of triggers it can use to determine if there is a change in process this information and decide what to do about it. For the
the state. This includes reed switch, window break detectors, sake of simplicity, this system will detect a signal or break in
movement detectors and pressure sensors to name a few. any zone and trigger the outputs. The outputs, in this case, are a
small piezo sirens and a relay that could trigger a siren or strobe.
We will use the Arduino to check the various inputs and see if
anything has changed. We do this by creating wired loops on which
HOW IT WORKS
The system starts out by importing the libraries then setting up the
input and output pins used in the project. Once the setup phase is
complete the system goes into an idle state [1].
On the bottom row of the screen, you will see three options: ARM,
TEST and SET. The Arduino will just sit here until we choose an
option. We have two choices to arm the system: press button one,
which is the “Arm” option or uses the RFID card or key fob. Either
of these will trigger the arming sequence. The unit will beep three
times before a long beep. On-screen you will see a countdown and
then “System Armed”. This triggers the “armed” flag.
The system now continues to loop, checking each zone, one after
each other. All of this occurs within the chkZones function. If any
of the zones (pins) are high, then the “alarmActive” flag will be
switched, and the system calls the soundAlarmOn function. This
function is what triggers the outputs, such as the piezo and the
relay. The alarm will sound until the disarm function is called when
the RFID is swiped.
2
IDLE
TEST
SETTINGS
If the zone is active (i.e. it has been tripped) it will show a “+”. If it's
INPUTS in a normal state, then it will be “-“. It gives you a clear indication of
OK what's going on around the installation.
NO
The system works with active and passive sensors, so it's rather
ALARM DO UNTIL versatile. While we have seven distinct zones (you could easily
DISARMED expand to more), you can have multiple sensors on each zone for
virtually unlimited monitoring application. In addition to monitoring
DISARMED
▲ ABOVE zones, we also have assignable output triggers in the event of an
Block Diagram of the Logic. alarm, to drive sirens / strobes, or deploy the laser beam sharks.
Let’s take a moment to break down the technology that is being LET'S TALK INPUTS (AND OUTPUTS)
used in this project.
There are two types of inputs we're using here, passive and active.
RFID The system can use either, but they need to be treated a little
differently.
Radio Frequency Identification (RFID) uses electromagnetic fields
to identify and track tags attached to objects automatically. The A passive input such as our magnetic reed switch, literally opens
technology can be classed into active and passive IDs. Passive IDs and closes a connection. Because this is a mechanical connection,
are utilised in a situation such as door swipes or 'tap-and-go' credit it's possible for voltages to float on the wires, and provide false
cards. Passive tags use the nearby RFID reader's radio waves to readings to the Arduino. For this reason, we use a resistor on the
collect energy and use it to power the transmission of the encoded zone to ensure that unless power is being applied, the Arduino reads
data. Active tags need a source of energy to operate but have a the zone as low.
greater operating range. These are used in application such as race
timing and tracking. RFID tags can be attached to anything from For the PIR sensors we're using, they're active sensors which
parcels, to food to animals and even people. means they require power to operate, and feed a signal back to
our Arduino. For this reason, they provide a clear logic signal to our
The technology itself has been around for some time but has taken Arduino and no resistor is required on the zone.
considerable research and development to bring to market. The
inexpensive passive RFID “chip” needs to be exposed to 1000 times INPUT - REED SWITCH
the amount of energy it needs to retransmit its data, and this needs
to be done in a safe way. The ID tags can be used for more than just The magnetic reed switch is the go-to security device. They exist to
distinct user identification, but depending on the model, you can trigger the alarm system if a door or window gets opened when it
embed a significant amount of data. is not meant to be. They come in two parts and consist of a magnet
and reed switch. Inside they have two small pieces of the metal set
The RFID unit used in this project is the RFID-RC522. This is a very very close to each other. When a magnet comes close to the unit,
common unit designed for interfacing with micro controllers such the magnetic field draws the two pieces of metal together, closing
as the Arduino. The unit is capable of reading from a very close the circuit. Using this and the Arduino we can sense when the reed
distance, and the tags can hold a reasonable amount of data. If you switch’s magnet is moved (i.e. on the windowpane) and trigger the
wanted to, you could include a significant amount of data to ensure alarm.
that the keys are more robust to hacking. However, in this case, we
will just read the ID from the unit, and if it matches the ones listed INPUT - PIR
internally, the alarm will activate/deactivate.
The Passive Infrared sensor (PIR) is one of the most commonly used
In addition to RFID to provide arm/disarm, you could integrate a security devices after the reed switch. The PIR uses the infrared
keypad. However we’ll focus on remote accessability in Part 2, light spectrum to detect movement. This works by having two slots
which will provide a second arm/disarm method. in the lens that “sees” through. When the unit is idle, both slots
see the same amount of infrared light. When a person or an animal
LCD 16X2 passes through one of the beams, it detects the difference between
the two readings and triggers the output to go high.
For this project we will be using the 16x2 Liquid Crystal Display
(LCD). It is called the 16x2 LCD due to it being two rows of 16 OUTPUT - PIEZO
characters that we can use to display any information we feel
relevant back to the user. There are a number of different ways The piezo buzzer is used in this example as it is small and low
to work with the 16x2 LCD. From a hardware perspective you power. Having said that, it can still make substantial noise at
can use the standalone unit, which will have a variation of 16-pin close distances. In the case of the alarm, you would want a louder
interface or there are several iterations of an LCD shield. The shield siren, but the piezo works well to show how the system works. We
is great and includes buttons, but it does limit you in terms of size have also used it in the project to signal things such as the alarm
and the reduction of I/O pins. For this project we will be using the countdown and the reading of the RFID card.
standalone unit which means we only need to use six pins to drive
the display. OUTPUT - RELAY
The brilliant part about using the 16x2 is that Arduino has the LCD The alarm needs to do something once it has detected a break in
Library included and it is incredibly easy to use. We need to include one of the zones. To do this, we need an output. The most common
the library, initialise the object, then simply tell the LCD what we of these would be the flashing strobe and an alarm siren. The code
want to say and where to put it! itself easily allows modification to trigger alternatives, such as
THE BUILD
PARTS REQUIRED: JAYCAR ALTRONICS CONNECT THE RFID READER: The pin out for the unit [4] is as follows;
1 x Arduino Mega 2560 XC4420 Z6281
1 x LCD 16x2 QP5516 Z7013
1 x RFID Tag Reader (RFID-RC522) XC4506 Z6356 RFID PIN ARDUINO PIN
1 x RFID Tags XC4506 S5376 SDA 53
1 x Piezo AB3462 S6109 SCK 52
1 x PIR Input (optional) XC4444 Z6382 MOSI 51
1 x NC Reed Switch (optional) LA5072 S5153 MISO 50
1 x 3 Push Buttons SP0609 S1120 IRQ NC
4 x 10kΩ Resistors RR0596 R7782 GND GND
RST 49
BUILDING THE CIRCUIT 3.3V 3.3V
This circuit might look daunting at first, but it's really just a series
of smaller circuits. For this reason, we'll tackle it bit by bit, until
4
you have a full working circuit. Some connections will use the
breadboard, others such as the LCD will be made directly.
CONNECT THE LCD: Depending on your unit you may need to solder
a header on. To breadboard this we need to place the headers “up”
as it makes it easier to jump the headers over to the breadboard. A
10k variable resistor can be used between pin 3 and GND, however
we're simply connecting direct to GND for full contrast. Using the
following pinout to connect your LCD.
Please note this unit runs on 3.3V not 5V as the LCD is powered
from. Once it is hooked up, you will get a red LED (on this model)
LCD PIN ARDUINO PIN to indicate it has power. In the resources, you will find the RFID_
1 VCC 5V DUMPINFO sketch, run this code and you will get all the information
2 GND GND that is on your RFID tag displayed on the serial monitor.
3 V0 GND
4 V0 A8 CONNECT THE BUTTONS
5 R/W GND
6 E A9 This circuit uses three buttons [5] to interface with the system. They
7 DB0 NC provide you with various functionality when you don't specifically
8 DB1 NC want to arm or disarm, including functionality to test the zones. It's
9 DB2 NC important to note that, like the mechanical reed switch we need to
10 DB3 NC be very clear to the arduino about our intention. For this reason we
11 DB4 A10 use resistors when wiring our tactile switches. The Arduino then
12 DB5 A11 receives either a clear 5V signal, or a clear GND signal.
13 DB6 A12
14 DB7 A13
5
PIR Connections: There are two libraries required for this build. LiquidCrystal.h for
the 16x2 LCD is built in, and MFRC522.h is required to run the RFID
reader. We have included it in the package. Please install it into your
RELAY PIN ARDUINO PIN libraries directory or the local directory of the project.
VCC 5V
OUT ZONE Pin The most significant thing you will need to understand is how the
GND GND LCD library works. Its probably simplest to think about it as a very
similar function as the Serial.println(). You have two lines in which
we can write too. We need to tell it which line and where to start
Reed Switch Connections: writing. Then we give it a string and it prints it to the screen. The
library and unit provides a built-in character set, so we just sent it a
normal string. A basic instantiation and usage of the LCD would be:
RELAY PIN ARDUINO PIN
NO NC
NC ZONE Pin lcd.begin(16, 2);
COM 5V
This starts the LCD object and tells it that it is has 16 columns and
Note: Remember to ground your zone when using reed switches. 2 rows.
In our system, the small piezo provided feedback. Note: if you're not
using an active module, connect the + to pin 29 instead of 5V. This is the simplest way to output a message to the screen. It is
similar to the Serial.println() function and will write whatever your
message is to the LCD.
PIEZO PIN ARDUINO PIN
S 29 However we don’t always want to write to the very first section of
+ 5V the screen and we may need to specify. The alarm will sound until
- GND the disarm function is called when the RFID is swiped. The above
code will set the cursor to column 0, line 1. Line 1 is the second
row, since counting begins with 0.
Relay Module (For Siren / Strobe):
Note: the characters do not clear until you send a new character in
When the alarm is triggered, we switch the relay. This is to provide its place. In this project we have written the clearScreen function.
power to alert systems, such as a strobe, siren, or warbler. You will This just saves sending nulls or spaces at the end of any strings that
need to have a separate power source for these items as most run you send to the LCD.
on 12-24V.
CONFIGURING ZONES
RELAY PIN ARDUINO PIN You will need to setup the zones used by your project. How many
S 28 do you intend on monitoring? We have setup seven zones. If they're
+ 5V unused, they must be grounded to avoid false triggering.
- GND
The relay contacts should be configured using the NC / Common int Zone02 = 35;
contacts. If your siren or strobe runs from 12V, you will need a int Zone03 = 36;
separate power supply for it. You do not need to connect anything to int Zone04 = 37;
the relay output for testing if you do not wish to do so. The light on // add a line for each new zone, and assign
NO.
NC.
COM.
▲ ABOVE
This diagram shows
all major connections
required for prototyping
and testing, with each
of the 7-zones broken
out and grounded for
reliable operation.
CONFIGURING OUTPUTS BUTTON 3: SET - This will check all your alarm zones and check for
any zones currently in “alarmed state”.
The outputs are defined on the following pins. If you wish to add
more just continue with the pattern. You have more pins available up You really aren’t limited to the number of sensors you attach to each
to pin 44, then wire them in accordingly. zone, and the number of zones could be expanded with some minor
code adjustments too.
// outputs We have tested PIRs and reed switches using 30m of standard
int relayOut = 28; alarm cable, and everything seems to be stable over that distance.
int piezoOutput = 29; The current draw is small, keeping voltage drop to a minimum.
int Output01 = 30;
int Output02 = 31; BACKUP POWER
int Output03 = 32;
int Output04 = 33; We don't currently have a solution for backup power, which is a very
prudent measure in security systems. We described an Arduino
UPS system in Issue #1, which would be suitable for this project. It
LEARNING RFID CODES uses a rechargeable lithium battery and DC-DC converter to provide
power, while being automatically recharged via USB when mains
With the current version of the code, we need to manually add power is available. We can easily connect an off-the-shelf UPS
in the RFID Tag ID. Once you have all the components connected however, which may be useful if you're running 12V sirens/strobes
load the DumpInfo.ino file and run. Make sure you have the serial and have other power considerations.
monitor open. Once the unit has booted, swipe your RFID tag, and
the number will be displayed. Repeat, to get a copy of all the tags IMPROVING TAMPER RESISTANCE
you wish to use. Once you have these numbers (they will look like
this “48:93:163:124”) we need to add them into the code. Find the We're using active low method for our zone monitoring. This means
following line: that when everything is in a "safe" state, there is 0V being received
by the arduino on each zone. Only when a sensor is tripped, is 5V
present on the zone. We did this due to the way the arduino PIR
int keys = 2; // number of cards modules are designed. They provide GND when nothing is detected,
// tags saved, next line and 5V when it is activated. However, if you're using PIR modules
String results[2] = { “80:231:86:128”, that can be configured for low output in alarmed states, or you're
“48:93:163:124” }; using passive hardware such as reed switches, you can suitably
modify the sketch to handle this.
Decide how many tags you will be using and change “int keys = One potential pitfall of this setup is that it is theoretically possible
2;” to this number, you will also need to change “String results[2] for an intruder to cut the wiring to the sensors, preventing them
“ to the same number. Finally add your TAG ID “{ “80:231:86:128”, from triggering the alarm. Of course, it's a little bit "Mission
“48:93:163:124” };” as a string with a comma in between. There is Impossible" unless you have your wiring dangling in a convenient
no comma after the last value, i.e. { "x", "y", "z" }. place for them to reach, but it is possible. Additionally if a sensor
fails, there's a wiring fault, or other incident, it could fail to send
USING THE ALARM SYSTEM an alarm signal back to the unit. By using active high monitoring,
the alarm will trigger on a true activation, but also if wires between
Once you have coded your RFID tags to the system, there’s little zones are cut, or there's a fault with the zone wiring.
need to recompile the sketch unless you make substantial hardware
changes or need to enable zones you have disabled via code. It is possible to invert the logic response from the PIR also, but this
seemed like alot of work. Let's face it, if you have very high security
There are three simple functions with the on-board tactile switches; requirements, you're probably not installing a DIY alarm. Sharks with
These could be omitted, but they provide very useful functionality. lasers on their heads are far more appropriate. But i digress...
BUTTON 1: ARM - This is an instant-arm function, and activates the In order to reconfigure the system to handle an active high system,
same state as scanning a valid RFID tag. It’s useful to allow “exit it's rather straight forward. You can also mix and match high / low
arm” functionality for someone to lock up without providing a fob. zones depending on your sensors if you wish. The system will still
report zone faults the same way.
BUTTON 2: TEST - This will sound the piezo and trigger the relay for
two seconds, so you can check wiring and such.
Here is an example to reconfigure Zone 1. The process is the same SETTING UP MULTIPLE SENSORS ON ONE ZONE
for all zones.
When installing an alarm system there are many instances where
Around line 52, locate the following code block: you'll want more than one sensor per zone. Perhaps you want
switches on each window or door, maybe even a PIR too. Whether
it’s a particular room or an entire floor of a house, whatever your
if (digitalRead(Zone01) == HIGH) { purpose, there are instances where you’ll want a zone to be a truly
strTrip.concat("+"); identifiable "breach zone".
}else{
strTrip.concat("-"); Our system will support multiple sensors without too much work
} being required. You simply need to wire your sensors in parallel.
That is, each one is provided power, and each returns to the same
zone pin for that sensor.
Now change HIGH to LOW. This tells the system that LOW should
show as a problem on the screen. For instance, we set up Zone 1 to listen on pin 34 of the Arduino. If
you have three PIR sensors, each "signal" output still points to the
same place, pin 34 on the Arduino.
if (digitalRead(Zone01) == LOW) {
This tells the system that is Zone 1 does fall low (i.e. doesn't have 5V We'll cover multiple sensors in greater detail, to create a full
present), then this is a problem. installable item. While this is a fully functioning prototype, to avoid
problems with loose wires and false alarms, it really needs to be
Now around line 215, locate: moved to a proper protoboard so connections can be soldered. We’ll
also add IoT functionality to allow remote arm/disarm, dynamic
learning of RFID tags, add some additional programme flexibility, as
pinMode(Zone01, INPUT); //Alarm Loop 1 well as a few other cool features. Don’t miss it!
digitalWrite(Zone01, LOW);
MORE RESOURCES ONLINE!
To grab the code or discuss this project, head to:
https://diyode.io/002tvrg
Next change LOW to HIGH.
digitalWrite(Zone01, HIGH);
That's it! You have now improved the tamper resistance on Zone 1
and converted it to active high monitoring.
CREEPY
caught up with Arjen to find out how it was all done.
CRAWLIES
We work with schools, and we were approached by the Parents and
Citizens Association (P&C) for a distance education school, to be
involved in their Enrichment Weekend for parents, where they would
learn about specific topics and share experiences. At a previous
event we’d explored 3D printers, which proved really popular. There,
we talked about the RepRap project, which made all the cheap,
modern 3D printing possible. We explained how it all works, from
the engineering to the maths, to the chemistry. At this upcoming
ARJEN LENTZ event, there was going to be a demonstration by the school using
Chief Explorer at OpenSTEM LEGO Robotics.
https://openstem.com.au
@AUOpenSTEM LEGO is great, but I remain unimpressed with its robotics. It’s
expensive and limited in a very restrictive environment. Some may
see those restrictions as an advantage, but the cost factor is a
Meet a cool open source, walking serious hindrance that prevents many schools from adopting it; and
caterpillar that uses 3D printing and then, I do question how much students can actually learn using
Arduino, to teach kids about robotics! these kits. Now, our caterpillar does not directly address all of this,
but it does reinforce the point that robotics does not have to be
expensive.
So I promised the P&C person that I’d bring along a cheap robot - I used to do low-level C programming, so playing with Arduino
probably a caterpillar - that was, at the time, yet to be designed/ and directly talking to hardware is right up my alley. The robotic
built. It had been something I’d been meaning to get into for a while, caterpillar uses servos. I set them up to initialise to a position that
so this was the ideal opportunity to get it done. I chose a caterpillar seemed reasonable, and created functions to cycle them through
because they’re quite different; and its key feature would be that their motion. They were wrapped in a function that would initiate
it has no wheels - wheels are so “done”! Most common robots use “one full cycle” in one direction. This actually worked pretty well. I
wheels (or similar) for their locomotion, but what happens is that think that early on I had to adjust the starting positions once. I have
many just end up being glorified remote controlled toys! Consider to say, getting this part mostly right from the beginning was a really
“Sphero” - nifty mechanics, but in the end it’s essentially a remote pleasant surprise!
controlled ball!
Timing is also important, because we’re interacting with a physical
I wanted to try something different, and had noticed that caterpillars environment. If you move too fast, you won’t have any grip. So the
were rare - there was very little information to be found online. I did timing depends on what kind of feet the caterpillar has (mine are
locate one caterpillar online, from years ago, and it used polymorph rubber), the surface it moves on, and its weight. Another advantage
frame segments, a PICAXE for brain, and distributed AA batteries. I of building a caterpillar rather than something with wheels, is that
wanted to make our caterpillar autonomous so that it would most no one tends to ask “how fast can it go?” or suggest we race it! It’s
definitely not be “remote controlled”. Clearly, it would have a “little clear that caterpillars are not built for speed!
brain” and this, along with its locomotion, would make for some
excellent discussions with the kids. That’s so true! You’ve used ultrasonics for obstacle detection.
What’s the range and the physical response to obstacles, and how
We’re seeing so many great solutions for getting kids into robotics, fast does it work?
and yours is an excellent example. Creating something that moves,
which doesn’t have wheels is a fantastic challenge - how much trial The ultrasound ping operates at the point of the movement cycle
and error was involved? where the head is pretty much facing straight ahead. The code acts
when it detects an object within 10cm straight ahead.
Ah yes, the “no wheels” is precisely what makes it interesting!
Indeed, I had to figure out how a caterpillar moves. For lack of From experiments, I’ve found that the range of these sensors is
reliably trained caterpillars in my garden, I reverted to YouTube and quite fabulous. You can easily do pings across a room and get a
watched videos from people who had gone through the effort of fairly reasonable reading on distance. Given sufficient memory,
recording a decent stretch of caterpillar movement. It was great you could use it to create a rough map of an area, which is refined
and, as it turns out, caterpillars move by something called “reverse from different positions and angles - but for that, you’ll also need
peristaltic motion”; and this peristaltic motion is actually what a sufficiently accurate positioning system. This can be tricky to
moves food through our digestive system. achieve indoors. There are neat projects (like “SubPos” by Blair
Wyatt - an Australian), that achieve this by doing measurements
from cheap WiFi modules across the room; however, it still requires
more setup and cost, which I didn’t consider worthwhile for this
particular project. ››
RIGHT (INSET) ►
Red and green lights on the head, a white one on the tail.
›› So the caterpillar doesn’t really know its position in space; it I used OpenSCAD to
merely tries to avoid bumping into things. When it gets close to an create the designs,
obstacle, it stops, reverses three cycles, and then turns its head to as its programmatic
the left and right to take another measurement. It will then move in spatial approach suits
the direction that has the most space (i.e. the farthest distance to an the way my brain
obstacle). The caterpillar turns by rearing its front legs into the air, works. I actually really
then turning the left/right servos (that are in between the up/down like OpenSCAD, it’s
servos along the body), then lowering the front, straightening out, a marvellous open
and returning to normal motion. It’s a bit rough, but it works. source tool. I also
downloaded the
Straight forward obstacle avoidance is a great start to autonomy. datasheet for the
The body is entirely 3D printed - is what we see the first design or microservos to find out the basic dimensions
did it take a few revisions to get right? and positioning of screws and the like. Initially I also
looked at some examples of what others had
It took a few iterations to get. I had a mental image of what I was done with similar servos (through Thingiverse and GitHub).
aiming for, but when translating that into the real world, things
always need adjusting. We’re fans of OpenSCAD too - there’s definitely little point in
repeating the same thing someone’s already done, if it satisfies
your purpose - this really is the true benefit of open source. You’ve
started to implement a Gyro/Accelerator module. What are your
plans for this?
Well, the system would be able to detect the slope, as well as the
sideways angle. The slope information could be used to adjust
the movement to to deal with steeper slopes up and down. It’s
currently untested territory, but the code can work out the sideways
angle, and thus figure out if the caterpillar has fallen over. Then,
in principle, it would be able to initiate a wriggly manoeuvre to get
The exoskeleton is a combination of
3D printed materials and servo motors. itself upright again. This should be doable; however, at the moment
the caterpillar is somewhat top-heavy metal gears. They’re not much more expensive, and because I’d
because of the battery pack on its back. already proven the basic mechanism, it seemed worthwhile.
It would take some work to get an auto- Fundamentally, I think the construction with the servos is
righting feature for sure, but wouldn’t mechanically problematic. No matter how you construct it, a lot
that be amazing to see? No wheels usually of strain is placed on these tiny servos, which they’re not good
means more power required - using the with. The very expensive RobugTix T8X robotic spider also uses
current setup, how long will it run for? the microservos, and Adam Savage already reported burning out
three servos during his test. I don’t think it’s a proper way to design
One should never use, say, a 9V alkaline things, and it seems quite irresponsible to produce retail products
battery - they really are quite useless. like this. In that context, I think it could easily fail the basic “fit for
Distributing a number of AA batteries along purpose” test.
the body is possible and I considered this,
but it makes the engineering more complex The OpenSTEM Caterpillar was undertaken as an interesting
and doesn’t necessarily provide a lot of experiment and an exploration, but remains one of our mascots
runtime. After some “dry” tests (running poor who we take with us to schools and events. I think it’s great if
caterpillar in thin air), and briefly borrowing other people want to also build it and learn from it, but I would not
a high capacity (1500mAh) LiPo from a friend, consider turning it into a retail kit.
I opted for a LiPo battery pack. At the moment
it’s a 7.4V 850mAh 2S LiPo, which is probably still You’re right - direct drive servos may not be an optimal long-term
overkill - I had to choose something so I went for a solution, but they prove the movement pattern, and are very fun to
reasonable capacity with a fairly small size. play with. If you had your time over, or were creating a V2.0 of this
project, is there anything you would change?
It will last for many hours. I use the caterpillar for
demonstrations and robotics incursions at schools, and I I think the first design and implementation was very worthwhile,
always bring a charged spare with me but I rarely need it. and quite necessary for learning the various important lessons. It
I connect the LiPo via a UBEC (Universal Battery Elimination now also has a red and green LED at the front, as well as a white
Circuit), which again is overkill but it provides me with a “reversing” LED at its tail - just because we can. For our next
sane voltage (5V), plus a buzzer to warn me when the LiPo is generation of robotic caterpillar, I’m thinking about a structure that
running low. Arduino will run on 3.3V (so a 3.7V 1S LiPo would uses ligaments. I haven’t yet sketched this out... but I’ll try to explain
work for that), but the servos need a bit more, so that’s why I here.
went for a 2S that provides 7.4V and then regulated it downward.
I’ve played with booster circuits for other projects, but they often Imagine a tube, with rings at regular intervals. Some of the rings
tend to be inefficient. would have a servo attached, which controls two wires that are
threaded through adjacent rings. So basically, a servo could pull
A few LiPo cells are also much lower in on one wire, while releasing the other,
overall weight than many AA batteries - at thereby bending the structure. Two servos at
least when comparing capacity per gram or 90-degree offset should provide full control
similar! Of course, distributing 18650 cells in every direction. A few such constructs
(for instance) may prove useful if you need across the length of the caterpillar should
to extend battery life beyond what you have! provide a very functional structure.
What unexpected challenges did you face
with this project? ◄ LEFT
Robotics that resemble natural movements seem
to quickly take on human or animal characteristics.
I initially used TowerPro SG90 microservos -
the really small blue ones that weigh a mere
9g each. They are cheap as chips because It could also deliver other advantages: fewer
they get used a lot in model airplanes. servos required, lower power consumption,
But, the servo used for the caterpillar to less strain on the servos, smoother external
“raise its neck” when turning, got really hot; so much so it actually structure (could get a neat coat). It could contain the battery inside
softened and warped the PLA of the frame! I also noticed some of the tube, which would ensure the caterpillar is not top-heavy,
the other servos becoming erratic, so basically failing. After initially plus there could be options for snake-style and other locomotion;
just replacing one failing servo, I decided to give the caterpillar a perhaps even a waterproof version? ››
“caterpillaroptomy” - a complete spinal replacement from SG90
to the MG90 model, which is the same sized microservo, but with
I think we all have a lot of ideas that stay on the backburner due to
time! What are you working on now?
After the caterpillar, I also built a little hexapod using three servos
and paperclips. It was a very simple design by someone from the
Gold Coast in Queensland (Australia). Again, this is just to show that
robotics does not have to be complicated or expensive.
Kids have an excellent time working out that I’ve used paperclips!
The caterpillar costs about $40 including the battery and possibly
the UBEC(w/buzzer), the hexapod should be less than $20. Both
are built around an Arduino Pro Mini, although observant eyes will
notice that the caterpillar currently has an Arduino Nano brain.
BUILDS
BEFORE
BEERS
I’ve been designing circuits and PCBs since I was 13, but I first
started playing with electronics even younger. What initially got me
into technology was LEGO; it got me interested in building physical
things, and the Mindstorms programmable block got me interested
in programming.
I think we’re all fans of LEGO at one time or another. It’s quite a leap
from tinkering to designing your own products. How did you go from
playing with electronics to developing your first product, Perf+?
RIGHT ►
Ben's 3 Solutions:
Building this schematic
of a 6502 computer
using 2 interlocking
Perf+ boards. Very tidy!
PERF+: CREDIT:
Build by Myndale.
aised $15,461 of its $1,500 goal (AU dollars) via Kickstarter
R
The original crowdfunding project. Gaining attention from
EEVBlog, Hackaday, and more. It’s definitely a clever approach to
prototyping.
REMOTEBOOT:
I chose Crowd Supply for my
second crowdfunding project
Raised $17,589 of its $1,500 goal (AU dollars) via Kickstarter.
Remotely boot or restart your computer from anywhere in the
because they offered a more
world. WiFi connected and a great Wake On LAN alternative, targeted audience, and offered to
especially for low-cost motherboards that don’t support Wake On
LAN control.
provide marketing for my project.
PERF+ 2:
Raised $11,820 of its $500 goal (US dollars) via Crowd Supply.
The next version of Perf+. Perf+ 2 includes larger holes, a solder GOT SOMETHING TO SAY?
mask between holes, and optimised to make the use of surface To leave your comments or see more images
mount components easier. https://diyode.io/002bbnz
RPi GUI
INTERFACE
So you have a Raspberry Pi and a cool idea, but how Once you have dealt with GUI more, referring to it as simply GUI
do you make it as easy as a smartphone for your user (often pronounced like "gooey") will make sense, and you can walk
to interact with? Add a nice intuitive interface! around talking like a code pro!
Building a Graphical User Interface is actually quite
easy, and with some patience you can produce Once you gain an understanding of GUI, your Raspberry Pi projects
amazing results. - by Oliver Higgins can start to take on a whole new life. To keep the code simple we're
using a standard screen and mouse. This keeps the theory simple
and with the least additional support required, however the same
principles will work on a touchscreen appropriately setup too.
You have probably seen "GUI" somewhere, no matter how new
to programming you are. GUI stands for Graphical User Interface. You may already own, or have at least looked at, the Raspberry Pi
That actually means our title should just be RPi GUI; since we've touchscreens. Once you have been through this article and learnt
effectively just wrote "Graphical User Interface Interface". But like how to create interactive elements, you'll no doubt want to move to
many acronyms in English, phrases such as "ATM Machine", "LCD touchscreen. This can serve as a springboard to home automation,
Display", and "PIN Number", it helps with identification of acronyms. digitisation of older hardware, and so much more. So let's dive in
While technically we're repeating ourselves, it's an odd quirk of the and take a look at the Raspberry Pi GUI!
English language (and human nature).
At this stage, we are going to assume you have a fundamental In short, a good interface is one that makes it easy for the user
knowledge of Python. So open idle, complete code, and run it. to tell the computer what to do. It makes the task of getting
the processor to ask the user for information, and returning
We will start by producing the GUI equivalent of “Hello World”. Using equally simple and understandable information back to the
Tkinter is quite simple but you need to be aware of how the code user. Clear communication between the computer and the
structure works. We start by importing the Tkinter object. Please be user is the underlying goal when it comes to interface design.
mindful here of the case; we are using Python 3, and there is some
variation compared to Python 2. The general process of starting the For most of our projects in DIYODE Magazine, we'll focus
GUI is to create the Window object (also known as the form). Set purely on practical UI/IX layouts that are raw function. We
up the window as required, build any display parts such as grids or want to demonstate how something works with the shortest,
buttons, bind any functions if required then start the main loop. ›› most clear route possible. If you were trying to commercialise
a product however, it's probably worth paying further
attention to the user experience and interface.
›› HELLO WORLD IN TKINTER def btnClicked() has in “if” statement that checks the current state
of the GPIO pin 17. If it’s high then it sends it low; if it’s low then it
goes high. This is a Toggle function on pin 17.
#!/usr/bin/python
from tkinter import * defbtnExit() has a single line: root.destroy(). This terminates the
root = Tk() program and provides a clean way to "close" the programme
root.wm_title(“Hello World”) (especially useful if working fullscreen without a keyboard).
root.mainloop()
The final four lines of code are to create the buttons. Firstly we
create the button. In doing this we set a number of attributes.
TO BREAK THIS DOWN: Firstly, “root” is the window we are binding. Second is the text string
that will be displayed on the button; and third is the command or
function we want to bind it to. Finally, we will specify the height and
from Tkinter import * width of the button.
Sets title of the window, then starts the GUI loop. #root.geometry(‘800x480’)
As we progress and add buttons into the form, we need to bind print (“LED off”)
them to the functions they will be performing. In this case, we are GPIO.output(17,GPIO.LOW)
going to create a form and add two buttons to it. One to turn the LED ledButton[“text”]=”LED OFF”
can simply load and go. However we'll take you through the code to ledButton[“text”]=”LED ON “
explain it below.
def btnExit():
We start by importing the Tkinter and the GPIO libraries into the root.destroy()
window title. The next lines are to set up how the GUI will function command=btnExit, height=20, width=80)
root.attributes(“-fullscreen”,True) will make the GUI cover the entire ledButton = Button(root, text=”LED OFF”,
screen, which is ultimately what we want to do. If you wish to be command=btnClicked, height=20, width=80)
more specific, then comment this line out with a # then uncomment ledButton.pack()
the next line (remove the #), and make sure that the resolution is set
correctly. Our GUI/window is set. root.mainloop()
A NOTE ABOUT THE CODE: Make sure you have updated your
RPi before starting, and that you have the GPIO library install.
Open the command window and enter the following:
Tkinter includes many different widgets to help you create the most
appropriate user interface. Widgets you can use include:
root.attributes("-fullscreen",True)
#root.geometry('800x480')
GPIO26
GPIO19
GPIO13
GPIO6
GPIO5
ID_SD
GND
SPICLK
SPIMISO
SPIMISO
3V3
GPIO22
GPIO27
GPIO17
GND
GPIO4
SCL1
SDA1
3V3
GPIO21
GPIO20
GPIO16
GPIO12
GPIO12
ID_SC
SPICE1
SPICEO
GPIO25
GPIO24
GPIO23
GPIO18
RXDO
TXDO
GND
GND
GND
GNL
GND
5VO
5VO
THE BUILD
3V3 5VO
SDA1 5VO
SCL1 GND
GPIO4 TXDO
GND
GPIO17
RXDO
GPIO18
ADDITIONAL PARTS REQUIRED: JAYCAR ALTRONICS
GPIO27
GPIO22
GNL
GPIO23
1 x Mini Servo Motor YM2758 Z6392
3V3 GPIO24
SPIMISO GPIO25
SPICLK SPICEO
GND SPICE1
GPIO5 GND
GPIO6 GPIO12
and doesn't require much instruction. Of course pay attention to
the LED orientation (flat side to negative). For high current servos
GPIO13 GND
GPIO19 GPIO16
GND GPIO21
Extra Credit:
GOT SOMETHING TO SAY?
To get the code or discuss this project, head to:
https://diyode.io/002nscd
With relative ease, we can expand on this principle and would be useful here also) to drive fans, motors, or much larger
effectively create a 4-way dimmer. Of course, 4 is an arbitrary lights.
number we're using since it's enough for a demonstration. You
can keep going until you run out of I/O, and even then there are You'll also notice we've started populating position coordinates
breakout solutions. on the Tk grid. This is a dynamic positioning grid. We effectively
assign elements to areas on the grid. If you don't do this, you risk
THE BUILD an unpredictable layout.
ADDITIONAL PARTS REQUIRED: JAYCAR ALTRONICS There you have it! Go forth and conquer some amazing UI ideas! ■
4 x Red or Green LEDs ZD0170 Z0801
4 x 330Ω Resistor RR0560 R7040
GND
GPIO26
GPIO19
GPIO13
GPIO6
GPIO5
ID_SD
GND
SPICLK
SPIMISO
SPIMISO
3V3
GPIO22
GPIO27
GPIO17
GND
GPIO4
SCL1
SDA1
3V3
12,16,20, and 21 for our circuit. These are selected for no
reason other than convenient breadboarding.
GPIO21
GPIO20
GPIO16
GPIO12
GPIO12
ID_SC
SPICE1
SPICEO
GPIO25
GPIO24
GPIO23
GPIO18
RXDO
TXDO
GND
GND
GND
GNL
GND
5VO
5VO
Insert the resistors and LEDs as shown, taking care to orient the
flat side of the LED to the resistor side. Then load the code from
the resources, PiGPIO_Dimmer.py.
LED4.grid(row=0,column=3)
Effectively we have setup four PWM outputs, one for each LED.
We then create a corresponding slider for each output. This
effectively provides you with a slider for each LED's brightness.
This can easily become the foundation of some home automation
controls. You can also step-up the PWM outputs (we provided
PWM driver circuits in our 555 Timer article in Issue #001 which
Safe
3-Phase
Generator
Building a 3-phase power monitor isn’t your average
DIY project, but when Tisham discovered he didn’t TISHAMPATI DHAR
have a 3-phase power source to test it with... the Research Engineer, Aerial Photogrammetry.
low voltage 3-phase synthesiser was born! http://whatnicklife.blogspot.com.au/
@whatnick
Three-phase is something that many of us will never actually Before we get into the AC simulator itself, tell us what spawned the
deal with in our tinkering. It’s not in your average house or back need for this project?
shed and requires special precautions to safely work around.
All that aside, for those using 3-phase (industrial workshops, It started with a competition run by SeeedStudio, which involved
fast food restaurants, and much more), power monitoring is building something with the NodeMCU. I built an energy monitor
as necessary as for anyone else (perhaps even more so since with an I2C ADC (analogue to digital converter). It wasn’t very
their power usage may be much higher than average). It takes accurate though, so I started a project to make the ATM90E26,
some special skills and a different approach to single-phase which is a utility-grade metering IC. It’s easy to DIY, with devkits
AC. Tisham’s 3-phase AC simulator provides a safe, low-voltage costing around AUD800. After I published the Arduino code online
source for developing 3-phase testing equipment. for the single phase ATM90E26, I started receiving requests to
support and debug ATM90E36 code, which other people were What voltage does your simulator output?
writing. The ATM90E36 is a 3-phase energy monitor chip, and in
order to test the code I made a devkit for this chip as well. The code The DAC outputs 0-3.3V, which gets AC-filtered then passed through
reads the values from the 3-phase chip fine, and I managed to test a TL084 JFET opamp. The opamp is powered from 23A 12V cells, so
each phase individually using my existing single phase test rig; without saturation output is +/- 12V rail-to-rail.
however, to test all at once I had to book the hackerspace in Tonsley
(in South Australia) for a variac and isolation transformer. This was Nice and safe compared to actual 3-phase - good one! How can you
helpful, but the test only lasted a couple of minutes since I foolishly load-test the low-voltage unit (since you can’t simply connect the
plugged in a low resistance (1-5ohm) load bank to the 12VAC actual load)?
without considering power ratings of the resistors. The load bank
went up in smoke and interrupted the test. So rather than waste The plan is to use small current-sensing transformers (CTs) at 5A
all the travel time and resources living dangerously at high max range (see resources) and high power load resistors, such
voltages, I decided to build a safe, low-voltage synthetic as 10W wire-wound (see resources). This stage is not built yet
3-phase rig. and the simulator only outputs 3-phase voltages at the moment.
Three-phase current inputs are being tested by passing the voltage
through a small divider.
Maybe you can use the old “pull apart the kettle” trick, if you get
stuck for a dummy load? It sounds like you’ll have PCBs produced,
◄ LEFT do you anticipate any challenges moving from prototype to PCB?
Tisham's prototype.
That’s right, the PCBs for the 3-phase synthesiser are not yet
produced. It is currently made of discrete components, and devkits
from manufacturers, plugged and taped onto breadboard. I have
produced PCBs for other prototypes - specifically, the ADS1115-
based single-phase energy monitor. For this I had to learn EAGLE,
scope out PCB manufacturers, and learn cost/capability matrices.
Then wait for weeks/months to get prototypes, since there is no
SeeedStudio or OSHPark equivalent here in Australia.
Sounds like “living down under” is the only major hurdle here. Other
Oh we’ve all let the smoke than the voltage, are there any notable differences between grid
out a few times. So the idea for a simulator 3-phase and your simulated 3-phase?
was born to allow you to test thoroughly and
consistently - what a great idea! Can you roughly My simulated 3-phase probably has higher harmonics due to
explain how you’re creating the 3-phase output? being generated from stepped DAC output, I have my scope ready
to perform harmonic analysis. I will have to go to the 3-phase lab
The 3-phase output is created by sending a digitised sine wave to do the same for the mains 3-phase. The timing is also critical
array to an I2C DAC at around 3.2MHz (the highest supported clock to maintain the angle between the phases; mine may vary a bit,
I could get out of an Adafruit Teensy 3.2). The sine wave array has whereas the grid is pretty stable.
165 points and each other phase is generated by circular shifting
the array by one-third of its length. I have made the code for the Timing is definitely a challenge with 3-phase simulation; single-
Teensy available via github (see resources). The output of the DAC phase AC is so simple by comparison. What unexpected challenges
has a DC component and is stepped (has harmonics). So I pass it did you face with this project?
through an RC low-pass filter and an opamp to bring it to +/- 12V
peak to peak AC, which my energy monitor devkit is designed to There are no breadboard-ready breakouts for 3-4 output DACs,
handle. which makes it difficult to prototype. The demo PCB for Microchip
MCP4728 that I’m using, is also unexpectedly large. The Arduino
Sounds like a reasonable approach, and it obviously works! Is library for it had fallen out of date as well, and so I had to update it
monitoring 3-phase more difficult than standard mains power? (see resources for a link to the updated version that I put on GitHub).
Of course, getting 3-phase to test my energy monitor was the initial
Monitoring 3-phase has to deal with higher voltages between challenge, which lead me down this rabbit hole in the first place! ››
phases. It also requires more ADCs (around 6 for 3-voltages,
3-currents), whereas single-phase can make do with 1, 2 if you
want to capture the power factor.
A mix of development boards make it work. Tisham's workbench complete with working prototype.
›› Those boards do appear rather large, but not the most difficult my tools of choice). I would be interested in hearing from anyone
thing to overcome (even if your prototype ends up three times the who is interested in collaborating or contributing to this project.
size it needs to be). If you had your time over, or were creating a
v2.0 of this project, is there anything you would change? Sounds amazing. With a little luck, one of our DIYODE readers will
see this and get in touch! Thanks for taking us through your Three-
One of the suggestions from hackerspace for building a 3-phase Phase Synthesiser Tisham, we look forward to seeing what’s next! ■
50Hz simulator was a constant speed drive, which spins one of the
BLDC motors commonly used in quadcopters. I would like to build GOT SOMETHING TO SAY?
an electro-mechanical rig to do this. It might end up being simpler, For more photos or to discuss this feature, visit:
with less harmonics than the DAC-based approach that I’m currently https://diyode.io/002chcd
using.
OBELISK SYSTEMS
Introducing
the StarLAB
Based in the Hunter Valley in
New South Wales (Australia), the
StarLAB is the flagship product
of Obelisk Systems, which is an
education and embedded systems
company founded in 2016.
The StarLAB is a complete STEM teaching solution for Year 9 and What a fantastic idea. It’s so exciting to think about kids learning
10 students in Australia, and includes all the hardware, software actual skills they can use in real life! How long has StarLAB been
and online resources required to engage students with robotics, up and running?
coding and computer programming. The StarLAB’s online
lessons, professional development resources, and the annual The StarLAB program has been running for around seven months
Rover Challenge are all built around its sensors and expansion (a year if you include the beta testing school phase), but for a
boards. We caught up with Obelisk Systems’ electrical and young system it’s growing really fast. In fact, since our product
marketing engineer, Clinton McKinnon, to find out more about launch in February 2017, more than 50 schools and in excess of
this clever company. 1,000 students across Australia have been having fun with the
StarLAB program.
The StarLAB is such an innovative idea. How did it all begin?
That’s a great achievement in such a short period of time. Run us
The StarLAB is the product of four friends who set out to make through who’s behind this success.
a 'cool piece of tech' and along the way it developed into a full
STEM education platform for students of all ages. So I, Clinton, am the head of marketing, and the company’s chief
enthusiast about STEM and the StarLAB – if given the chance, I
The StarLAB is a coding and sensor platform that lets students will talk your ears off about anything STEM-related! Occasionally,
explore the world through a wide variety of sensors. Students I also put my recently obtained electrical engineering degree to
are taught to code the StarLABs sensors, and as they learn to use by writing apps.
code, they can observe physics in real time, and eventually,
with the rover expansion, use those observations to design an Luke is the architect of the StarLAB platform. He has an uncanny
autonomous vehicle. This may sound very complicated, but ability to predict a request and have it completed two weeks ago!
the support materials were designed with teachers in schools, Luke is most famous at the StarLAB for adapting the platform to
so anyone can teach STEM with StarLAB right out of the box – scratch in a weekend (because someone asked if he could), and
we even mapped out materials to the NESA-approved iSTEM designing the amazing MK2 Rover in just over a week.
curriculum!
Lewis is the official voice of the StarLAB, so when you play one of
As we further developed the API, we came up with a few the videos in our lessons, you’ll hear his dulcit tones! Not just a
unique tools that used the wireless networking available in our smooth set of vocal cords, Lewis also writes the firmware for the
hardware. This included a feature we’ve dubbed “multiplayer StarLAB, and has appointed himself the master of quality control
programming”, which allows multiple students to code on the for the online lessons. ››
same hardware at the same time, from their own computers.
You guys are a living example of a small team achieving big things.
What are the core principles behind your program?
The core principal of the StarLAB is that STEM is not four (or five in
the case of STEAM) subjects, but one integrated subject. The truth
of STEM is that without all of the elements you can’t understand
how any one of them work. StarLAB teaches STEM as a single
We want to give students the skills they need to excel in their own
professional lives, and to develop the confidence to try and make
the world a better place. We want to help teach them that if they
don’t succeed the first time then they can dust themselves off, get
up, adjust their plan, and try again.
It sounds like the youth of today are in good hands when they
become involved with the StarLAB. What else do you guys have up
Testing interfaces in the StarLAB system. your innovative sleeves?
We’re always working to improve and expand our platforms, but lots
subject, meaning at no point will you find yourself asking “why am I of those plans are far too secret to talk about yet! The biggest new
doing this?”, because you can see and interact with it in a real and thing we’re currently working hard to develop are training courses
physical way. for teachers, and a coding club that will give students a chance
to come and code with the engineers from our team. We’re also
Sounds like a surefire recipe for success for StarLAB students. What working on two hardware expansion products: the first of which
milestones has the program achieved so far? will allow students to design their own electronic circuits, and the
second will give the StarLAB an interface with the Arduino platform.
Our biggest milestone so far was the launch of the StarLAB platform
in February. At that point in time, we had around 20 teachers attend Some people see STEM and robotics as “skills for tomorrow”, but
our launch party, which was held at a small room at The Stadium we don’t really like that perspective because people are often
in Newcastle (we weren’t in the actual stadium – maybe one day). doubtful of things that try to predict the future. The reality is, there
Then in May, we had the rover launch, at which point students are STEM and robotics jobs available right now, and so our goal is
could start driving the StarLAB around. Our next big milestone will to help ensure that today’s kids don’t miss out on these current
be in November at the ME Program Mars Rover Challenge, which opportunities to enjoy the fun of the already changed world. ■
will see students from around Australia compete to code the best
autonomous rover. You can connect with StarLAB and Obelisk Systems at:
https://www.starlab.education
In terms of official recognition, we took out top honours in the @obelisksystems
NBNco grant, and have also received grants from Beyond Bank and @obelisksys
DIGGING
FOR SATELLITES
When I was younger I spent a lot of time hiking and biking in the
MIKE FIELD hills, using just a map and compass for navigation. When affordable
IT Systems Engineer and Bike Enthusiast. hand-held GPS units first became available they were the most
www.hamsterworks.co.nz amazing of tools. Although they are now ubiquitous, I’ve always
@field_hamster wondered just exactly how do they calculate where we are? In 2013
I saw an article on the Hackaday blog, about a homemade GPS
receiver by Andrew Holmes. I put this on my project “to do” list, and
No, that’s not a typo. Mike wanted to set about slowly acquiring the hardware and knowledge required to
go deep; really deep, and figure out make it happen.
what’s actually behind a GPS signal.
That thirst for knowledge often sparks some interesting questions.
What hardware did you need to receive the raw GPS data?
Probably every single one of us has used GPS (Global Positioning I used an inexpensive active GPS antenna from Ali Express, coupled
System), perhaps without even realising. Whether it’s on your phone, to a KiwiSDR board from SeeedStudio.com. The Kiwi SDR board
your Fitbit, your in-car navigation, or on a boat. The GPS really came is actually aimed at being a Software Defined Radio that can be
into use in the mid 90s, but the last decade has seen exponential accessed over the internet, but also includes a GPS front-end. I
growth of GPS-enabled devices, and ready-access to tiny GPS then patched wires onto the test points, and used a Digilent Nexys
receivers with unbelievable accuracy. Mike from New Zealand was 2 FPGA development board to capture the raw signal samples
curious about what’s actually behind GPS; and not just the satellites, that are being received by the front-end of the GPS. They are then
but what data is being received and decoded in a split second, sent to a laptop to be recorded for offline analysis. Although the
which tells us where on earth we are? We caught up with him to find Nexys2 board is an old design and no longer available, it was a good
out what he learned. solution for this project, as it has an interface that acts much like an
Enhanced Parallel Port, allowing it to transfer the 2MB/s of raw data
Many of us would have played with GPS receivers to obtain location without missing any samples.
coordinates, but rarely do we think beyond that output data. What
made you take on the journey of understanding how the GPS works That’s a reasonable amount of bandwidth! How did you get started
at a fundamental level? receiving and decoding?
RIGHT (INSET) ►
Mike plotting his current location
(about a gazillion times, give or take a few...).
The initial reference point was the “Global One thing that I didn’t realise is just how high the
Positioning System Standard Positioning Service GPS Space Vehicles’ orbits are, and how weak
Signal Specification, which describes how the the GPS signals are. They are approximately
signal is transmitted, what data is encoded, how it 20,000km away, they transmit with about 25W of
is encoded, and how you can use the information power, and the signals need to be received with
to find your location. a non-directional antenna (because you need to
receive more than one at a time). They are in a “semi-
Before I had the ability to record my own data, I synchronous orbit” - they orbit the earth every 12 hours.
scoured the internet and found a single set of raw GPS data;
however, the only information available was the recording sample Also, the data rates are also really, really slow - only 50 bits per
rate and the intermediate frequency of the GPS signal. With a lot of second. This slow rate is why it takes 30 seconds to get a GPS
experimenting I was able to detect the signatures of the GPS Space position fix from a receiver “cold start” - at the slow rate, it takes
Vehicles (satellites), and eventually decode that the signal was this long for the Space Vehicles to transmit their orbital parameters
recorded in Nottingham in the UK, and even identify the corner of and clock correction factors. It’s pretty amazing how the orbits of
the building where it was recorded. The company in that building the Space Vehicles are known to such high precision - although they
made navigation systems, and from this information, as well as are orbiting at thousands of kilometres per hour, the orbit is known
LinkedIn, I was able to track down the person who recorded the to within a few centimetres.
data - who now works for the European Space Agency!
It’s a good thing that orbital precision is there when you have
The initial version of my software was small (about 700 lines of hundreds of millions (or billions) of dollars worth of satellite up
C) and very simple (built for tinkering with the algorithms rather there! Was there anything you can take away from the experience,
than speed). It took all night to process three minutes of data. The other than a greater understanding of GPS?
processing of GPS signals is amazingly simple - just XOR-ing three
bits together, and counting how many are set, and once I had a It is amazing that the most advanced technology like GPS can be
working implementation I was able to speed it up by over 200 times! explored on a hobbyist’s budget. Things that would require a very
As the code currently is, it uses about half an Intel CPU core to expensive research lab and an equally expensive budget can now be
receive data from eight different satellites. Now on my to-do list is built in a garage or on a workbench in the spare room! Another thing
to have the software process data in real time! I discovered was that Digital Signal Processing (DSP) and Software
Defined Radio (SDR) isn’t that hard, and can actually be quite
Wow - when you consider the amount of data crunching that interesting code to write. The range of inexpensive SDR hardware
equates to, it really does make commercial GPS receivers seem that has recently come onto the market has really created a whole
even more impressive! What unexpected surprises did you find new hobby, at the intersection of Ham Radio and Home Computing.
amongst all that data? If you want to get started in DSP, they have an excellent introduction
is a book that is available for free. ››
Einstein lived in an iPhone era! What unexpected challenges did you M0 = -1.96696360836378514314048970846
It is really hard to make something this complex work correctly, sqrt_A = 5153.7914524078369140625
is having one wrong value (e.g. the time of week is out by six i_0 = 0.929460680202385813863941166346
seconds) and the position will be unable to be found. Also, I know w = 0.581836914791512338496204392868
virtually nothing about control loop theory, so I should probably read omega_dot = -8.26677291570257726900144621112e-09
more about this and actually do a decent design, rather than just idot = -2.81440294546514755206673727254e-10
It’s true that proof of concept and a working product can often look Crc = 232.3125
quite different. What knowledge have you now gained regarding Crs = -4.875
GPS that would save you time if you tackled this from scratch again? Cic = 4.470348358154296875e-08
Cis = -1.0430812835693359375e-07
There are lots of hidden, elegant ideas that have been used to Toe = 180000
make GPS work. The simplicity of how the special “Gold Codes” are
generated, the way that the data is transmitted so as to make it This is an example of the Orbital Parameters for Space Vehicle 15.
simple to receive, the way you can minimise the CPU time required They allow the GPS receiver to calculate exactly where a Space
to acquire the Space Vehicle signals. Even what seems to be trivial, Vehicle was when it transmitted the signal. ‘sqrt_A' is the square
like the selection of the intermediate signal frequency, has hidden root of the orbit’s average distance from the centre of the earth -
depths. Being aware of these subtleties and taking advantage of 26,561,561.671 metres.
them could make a repeat of this project much simpler.
I’ve got a few projects on the go, I am working on some audio 0101010011001100101001111101001110000100011011001
also playing around with ESP8266 WiFi modules and the MQTT 0101001110100000111101101110000110001001010010110
platform and security system for home. I’m also trying to reinvent/ 1001011111011110001100011011101100001111001001110
rewrite my FPGA website. We are just about to move to a new house, 0101100010000110111111100111000110101001010000100
https://diyode.io/002xqdn 1101000010100000001011011011110011110001000111111
0110001110101101010000110011011000001100000000110
110110101110101111000010101001000010110010011000
► DSP GUIDE
www.dspguide.com/pdfbook.htm This 1023-bit string is one of the two special Gold codes that
► HACKADAY BLOG allow all the GPS satellites to transmit on the same frequency.
www.aholme.co.uk/GPS/Main.htm When repeated It contains every sequence of 10 bits other than
► GPS STANDARD POSITIONING SERVICE “0000000000”. Two different Gold codes are combined with the
www.navcen.uscg.gov/pubs/gps/sigspec/gpssps1.pdf GPS data signal, making it like noise, but still allowing a receiver find
the signal.
MODEM
RESTARTER
Automatic Here’s a problem that I’m sure we’ve all experienced
- a router that for whatever reason, simply stops
System Using
supplying the internet we need, and nothing fixes it
better than a simple “turn it off and on again”. With
Arduino and an ESP8266-compatible board, this can
The ESP8266
be done automatically. - by Tim Blythman
It’s the solution repeated by seasoned IT professionals everywhere: Because we’re using WiFi, the sketch first needs to connect to
the hard reset. A power cycle, AKA “turn it off and on again” that the WiFi network, and then try to connect to a website. I’m using
simply does what it says. Resetting a malfunctioning piece of Google, because if Google’s down, that’s pretty much as good as
hardware to a known good state. What we’re trying to detect and the internet being down. Of course, not being able to connect to the
correct here is the situation that can drive anyone mad - that the WiFi network is a good reason to ring the alarm bells too, so this
internet isn’t working. I wanted a system that will check if the router needs to be detected as well.
is connecting to the internet OK, and if not, apply the hard reset that
will make it all work again. This project also uploads reports to a The next step is to reset the router. If you’ve got a router that runs
phant stream, so that the status can be checked remotely. off low voltage, even via a transformer or PSU, then that’s quite
easy, but if you’ve got a router (or some other device) that runs off
THE BROAD OVERVIEW 240V directly, then more hardware is needed to do this safely. Of
course, the power can’t just blindly toggle either - it needs to turn
There’s two main parts to this problem: detecting that the router the power off for long enough for the router to reset, but also give it
isn’t doing what it should, and then making the reset happen. long enough after power on to get into a normal operating state. ››
›› Because everything should always have more features, I’ve also the router to restart. There’s a timeout to let the router go through
added some code to upload the status to a phant stream (see article its boot process before the checking starts again.
on p89 of the July 2017 issue). Of course, if the internet is down,
an update can’t be done, so the status is either OK, or a reset has On startup and at regular intervals, a message is also sent to
recently occurred. If there hasn’t been an OK for a while, there’s the phant server by a separate function. If a reset occurs, then a
something wrong. different message is sent.
HOW IT WORKS Under the Arduino IDE, connecting to a WiFi network is as simple as
issuing the command:
We originally set out to use an Arduino plus WiFi Shield for this
project, but the project seemed simple enough that I should be able
to program the WiFi Shield directly. The main parts of the hardware WiFi.begin(SSIDNAME,SSIDPWD);
are the WiFi Shield (operating as an Arduino board) and a 5V relay //connect to WiFi network
module. The router power is fed via the relay’s normally closed (NC)
contacts, so that to effect a reset, the relay module is energized for
a few seconds. Using the NC contacts also means that the default The code that checks if the board can connect to the internet is
state is “power on”, and things will generally keep running if there is below. We're using a counter to detect the number of “fails”, and
an issue with the Router Restarter. only tripping the reset if the count gets to three. This gives a bit
of robustness in case of occasional glitches that might occur in
The other necessary piece of hardware is a USB-Serial converter to the internet. In essence, we’re assuming that if the ESP8266 can
do the initial programming. If you don’t have an immediate need to connect to Google, then everything is fine.
use the USB-Serial converter for another job, then it’s an easy way
to power the built project as well. But you may as well keep it for
another project, and power the device directly once complete. WiFiClient client;
if(client.connect(“www.google.com.au”,80) {
// connect to google on port 80-
// could be any website
A closeup of the shield. Most of Serial.print(“connection ok:”);
the “pins” on the WiFi module are cnt=0; //reset fail count
broken out to headers }else{
on the WiFi Shield. Serial.print(“connection failed:”);
//count the fails
cnt++;
}
◄ LEFT
Any 5VDC relay module #define PHANTPUBLICKEY “_your_public_key_”
with Normally Closed (NC)
#define PHANTPRIVATEKEY “_your_private_key_”
contacts will work.
#define PHANTNAME “powerstatus”
#define HOSTNAME “data.sparkfun.com”
#define HOSTPORT (80)
THE HARDWARE
THE BUILD
DON'T WANT TO CUT YOUR POWER CABLE? You can easily I cut my relay module in close to the DC plug end of the cable, but in
make up an inline joiner for this project using a DC plug, DC retrospect, I should have put it closer to the mains plug pack, given
socket, and a short length of cable. Connect the DC plug that I’m plugging the USB power supply for the Router Restarter into
from your power supply into the socket, and the new plug the same power board. ››
into your router and you're set. That way your power supply
is still in-tact which may be useful for any warranty etc.
RST
RIGHT ►
Connection diagram for
the Modem Restarter.
Note that the Relay Module needs 5V to its power input to operate The other #defines are more for finetuning, so can be left for now.
correctly, even though it will activate on a 3.3V signal to a control If you do not have a phant stream set up, you can just leave the
input it may produce unreliable results. default values - it will just try to upload to a non-existent stream. If
you don’t intend to set up a phant stream at all, you can replace the
CODE AND CONFIGURATION dophant() function with an empty function by removing the code
inside the function (so it does nothing):
As noted earlier, the code won’t simply work out ‘out of the box’, as
there are some parameters that will need to be set to work with your
WiFi network and phant stream: void dophant(char* txt){
//do nothing instead of upload txt phant
}
#define SSIDNAME “SSID”
#define SSIDPWD “PASSWORD”
#define PHANTPUBLICKEY “PUBLICKEY”
#define PHANTPRIVATEKEY “PRIVATEKEY” ASSUMED KNOWLEDGE:
Phant Stream
#define PHANTNAME “FIELDNAME”
At a minimum, replace the text inside the quotes with your own SEE ISSUE #001 PAGE 93
versions. If you are not using the phant server at data.sparkfun.
com, you will need to change HOSTNAME and HOSTPORT although If you haven't setup your own PHANT stream yet, check out
HOSTPORT will probably still be 80. the article in Issue #001 https://diyode.io/001ykxw for a
step-by-step guide.
1 Selecting the host board in Arduino IDE. 2 Serial Monitor Debug Data.
Assuming that you’ve set up the Arduino IDE for your ESP8266
board (see our setup article elsewhere in this issue), plug it in and
choose the correct serial port.
There are a lot of board profiles available. For the XC4614 WiFi
Shield, I chose the ‘ESPDuino’ option as it is based on an ESP-
13 module like the shield, and this worked fine. If you have TESTING THE SYSTEM
trouble, you can manually change the options - I would start by
trying a different Upload Speed. The CPU Frequency and Flash Providing everything is working properly, you can now test that it
Size should not matter too much, as the sketch is quite small does indeed cut power when there's no internet connection. The
and will operate fine at the slower 80MHz. You might find your simplest way, depending on what type of internet connection you
module or board has a documented Flash Size that you can input, have, is to pull out the hard-wire lead (Cat5 or telephone lead).
and if not there is a test sketch that can check the flash size at
File>Examples>ESP8266>CheckFlashConfig [1]. If you're in Australia and have an NBN connection with FTTP
(Fibre to the Premises) it's not a good idea to remove the fibre optic
The next step is to put the board into bootloader mode. On the lead and may require a technician to visit if you do. If you cannot
Duinotech board we used, hold down the “KEY” button, press "disrupt the internet", the best option is to simply use the off switch
and release the “RST” button, then release the “KEY” button. on the router. After a short time, you should hear the mechanical
If you have one of the all-in-one boards with a USB-serial "click" of the relay module trying to restart the router. Under the
converter built in, then this might be done automatically. If not, default settings, it will take about 30 seconds to activate, and
there is more information about how this happens here: will toggle the relay for five seconds. If it doesn’t seem to do this,
check the wiring and Serial Monitor to see that the fault condition is
https://github.com/esp8266/esp8266-wiki/wiki/Boot-Process detected.
Now you can press upload from the Arduino IDE. To me a least, it The first thing I did after getting it all working was to make up a
appears that this process takes much longer than for other boards. permanent power lead that would not require me to plug in the USB-
Open the Serial Monitor, and observe the debug data [2]. serial converter to run the Router Restarter.
If you get a 0.0.0.0 IP address, then the WiFi settings might not be I found an old USB plug with a lead that, I think, came from a hub
correct. A HTTP 404 message in the response from the phant server that stopped working. I found the red and black wires and soldered
might indicate that the phant stream keys or field are incorrect. a small piece of 0.1” header strip to them.
NOTE: It may be habit to set an IP address when using WiFi or This then plugs into the header where the USB-serial converter is
Ethernet modules. However it's not a good idea for this project. You plugged, being sure not to get the polarity incorrect. The pins on the
actually want the DHCP protocol to assign a valid address. If that board should be labelled anyway, and you can always check with a
doesn't happen then it indicates an issue too. If the IP address isn't multimeter. A few seconds of work can save you a broken module. ››
assigned correctly, it will also then restart the router. This is also
useful for resolving other system bugs that a restart can fix.
13 12 11 10 9 8 7 6 5 4 3 2
ON ON
D
ESP13 Shield
5V
G
SW1
TX RX G 5V
G
WARNING: Don’t assume that black and red are power, 3V3 G EN AD D
RIGHT ►
The finished project using a modified USB
cable for power, meaning you can save your
USB to Serial module for another project.
Apart from the settings mentioned above that definitely need to be Of course, your server probably doesn’t run off a small plug
changed, there are one or two that might need to be tweaked to pack, and to get this project working will probably need a way of
make the Router Restarter work with your setup. The relay is pulsed controlling 240V. The relay in this project is rated for 10A at 240V,
for five seconds in the reset routine - this should be enough for most but I wouldn’t recommend modifying any 240V wiring unless you’re
devices, but if you are finding it isn’t working reliably, the duration qualified and know what you’re doing.
can be increased. There is also the BOOTTIME constant at the start
of the sketch - this is the time that the sketch waits for the router If the server has a low voltage power button (e.g. like an ATX power
to restart before testing the internet connection. If it is too short, supply), then the relay could be used to toggle that. In this case,
the Router Restarter might get stuck in a loop, as the router doesn’t you would probably have to use the normally open contacts, and
have enough time to get up and running before it is reset. If you are program the relay to activate for five seconds to do a hard “power
having trouble, this can be extended. off”, then pause and give a brief pulse to turn it back on.
In the article from the July 2017 issue, I also created a small If this doesn’t work and you are not legally qualified to work with
Android app, which monitors a phant stream for changes; this app 240V, then it might be possible to use a remote controlled wireless
would work equally well monitoring the stream for this project. power point to do the switching. For example, a pair of relays could
Check out the article at https://diyode.io/001ykxw. be connected to “press” the off and on buttons on the remote to
initiate a power cycle.
With the phant capability of the Router Restarter, it can easily be
extended to feed more data to the phant stream, or even a second There are a few projects descibed online to solve this pointy issue of
phant stream; for example, you could add a temperature sensor mains power switching, and it's something we'll probably tackle in
output. Just add a “dophant()” function call with the required value. greater depth too. ■
Perhaps, if your router has a habit of overheating, you could use that
to trigger a reset as well. GOT SOMETHING TO SAY?
Get the code for this project or leave a comment, visit:
Another way you could use this project is if you run a server, and https://diyode.io/002zsgp
you want to check if the server is “up”, and running correctly. In
this case, you would use the web address of your server instead of
Google. You could also separately test the IP address and URL of the
server to discriminate between server outages and DNS issues.
$
1596
SAVE $3.99
$
2796 $
1596
SAVE $3.99
$
3196 $
1600
SAVE $4.00
SAVE $6.99 SAVE $7.99
$
1276 $
2396
SAVE $3.19
$
7 97 $
1196
SAVE $2.99
$
7 56
SAVE $5.99
$
1992
SAVE $4.98
$
2876
SAVE $7.19
ea
5
$ 56
SAVE $1.39
$
1276
SAVE $3.19
Introducing
The ESP8266
This tiny WiFi chip packs a massive punch. Easily
programmed and barely the size of a USB plug.
Let's take a closer look. - by Tim Blythman
If you’ve been working with microcontrollers, especially Arduinos, devices. In fact, many modules are fitted with 0.1” spaced headers,
or have ever been interested in adding WiFi to a project, you might allowing for use on breadboards, even though they are typically not
have heard of the ESP8266 IC and its various modules. It’s a product much bigger than a coin.
of the Espressif company, and was not widely known until it was
noticed by the maker community. Through the community’s efforts They do come in a few different shapes and sizes though, the image
and Espressif’s release of their SDK, the ESP8266 has turned on this page showing two different styles of ESP8266 commonly
into one of the go-to choices for makers who wish to add a WiFi available.
microcontroller to their projects.
FEATURES
WHAT IS IT?
The ESP8266 is not just about the WiFi, and its specs look like they
The ESP8266 is a microcontroller with b/g/n WiFi and a full put an Arduino UNO to shame. But, that’s not to say that you should
TCP/IP stack, meaning that most of the hard work in making throw the UNO out - because the ESP8266 needs to spend time
and communicating over a WiFi connection is done by the handling WiFi connections, and it is less suited to timing critical
microcontroller. The ESP8266 needs external flash (for applications including PWM. There are a few restrictions on use of
program storage) to operate, and to fit this bill, the ESP8285 (a the I/O pins – for example, some are shared with the SPI bus that
microcontroller with in-built flash) and a vast range of modules accessed the program flash storage, so cannot be used without
have been developed. It’s these modules that most makers will be great care.
familiar with, as they also remove the need to solder surface mount
HOW CAN I USE IT? there’s a few bumps on the way to using these boards. For a start,
some boards do not use an obvious pin numbering scheme. There
I first started out using ESP8266 modules with an ESP-01 module, seems to be a mismatch between the Arduino IDE pin numbers
and connected it to my computer via a USB-serial converter. A lot and the ESP8266 pin numbers. For some of the boards, there
of modules will come loaded with a variant of the “AT Command” are defines, such that “D4” is actually mapped to the logical pin
firmware, meaning you can issue commands directly to the reference in the Arduino sketch. In other words, if the pin number
microcontroller - with functions such as “scan for WiFi networks” and doesn’t seem to be working, try prefixing a “D” to the number.
“connect to server”. You can perform the microcontroller equivalent Fortunately, everything seems to be mapped correctly on the
of opening a web page in about half a dozen commands. This setup XC4614 WiFi Shield from Jaycar that we tested.
is a great way to test and get to know how the ESP8266 works.
Generally, you may find compiling and uploading takes longer than
The next step will be to program a microcontroller to run these other boards, and the sketches always compiled to at least 200kB,
commands and autonomously access the WiFi network. An presumably incorporating some base libraries.
understanding of how network protocols work is really handy for this;
for example, for emulating the function of a webserver or web client. If you are using the bare modules or some of the boards, you
might also find that you need to use some tricks to correctly put it
Another step beyond using the AT commands is to program the into “bootloader” mode to accept sketch uploads. To program the
ESP8266 as a microcontroller in its own right. In this project, XC4614 WiFi Shield from Jaycar (as a standalone board) with an
I’m using the Arduino-ESP8266 add-on, which offers a WiFi USB-Serial converter, I had to hold down the “KEY” button, press
library with similar features to the Ethernet library. There are also and release the “RST” button, then release the “KEY” button. On
implementations of languages such as NodeMCU, Lua and even boards that don’t have buttons (such as the ESP-01), it’s necessary
BASIC. to use two jumper wires to provide the correct sequence of inputs to
activate the “bootloader” mode.
To program the ESP8266 on its own, you’ll need a Serial-USB
converter, or preferably, one of the many boards that incorporate the I also found that I was getting "function not defined in this scope"
ESP8266, a USB-Serial converter, and usually a breadboard friendly errors where the same sketch would compile successfully for other
pinout including breakouts for IO pins. As with many ICs these days, boards, but not for ESP8266 based boards. In this case, it appears
the ESP8266 is rated at 3.3V, so these boards should also include a to be a bug in the ESP8266 board profile, which is referenced here:
5V-3.3V converter as well.
https://github.com/esp8266/Arduino/issues/1669
INSTALLING THE ESP8266 ADD-ON FOR ARDUINO
The quick fix for this is to add function prototypes to the top (before
You will have to have Arduino IDE version 1.6.4 or later, so that the function is used) of the sketch, and an example of this is given
you can use the Boards Manager feature to install the add-on. It’s in the Modem Restarter project article on page 111.
as simple as opening the Boards Manager (Tools>Board>Boards
Manager…) and searching for ‘esp8266’, and installing the entry SUMMARY
by ESP8266 Community. If your search doesn’t show this entry, you
might need to go into File>Preferences, and add this URL: If you feel like you know your regular Arduino boards quite well,
then you should have no trouble getting the ESP8266 up and going.
arduino.esp8266.com/stable/package_esp8266com_index.json The Arduino implementation isn’t quite as polished, but as with the
other boards, there is a community of people on the forums who are
to the Additional Boards Manager URLs near the bottom of the always working to make it better.
Settings tab.
We also use the ESP8266 in our WiFi modem restarter project
After this, you should see a group of boards appear under ESP8266 elsewhere in this issue! For this project, we use Jaycar’s XC4464
in the Tools>Board menu. I found the “Generic ESP8266 Module” USB-serial converter and XC4614 WiFi Shield. This shield breaks
seemed to work for most cases where I wasn’t sure which board out all the IOs, has convenient RST and KEY buttons and includes
to use. You’ll also find a heap of example sketches under the 5V-3.3V converters for power and the serial port, providing some
File>Examples>ESP8266 menu. The CheckFlashConfig sketch can handly methods to get it all going. ■
help you fine-tune these settings.
GOT SOMETHING TO SAY?
USING THE ESP8266 ADD-ON To leave your comments
https://diyode.io/002txkh
Earlier, I mentioned you shouldn’t throw away your UNO yet, and
after being comfortable with official Arduino boards, you might find
Direct from
the Community:
Some Amazing Creations!
Robert has built a few cosmic ray detectors in his time, but his latest is a 9 x 9 pixel
hodoscope (cosmic ray detector). For those interested in space science and cosmic
rays, you should definitely check out Robert’s website for his open-source projects at
http://cosmicray.com.au ■
TEMPERATURE DIFFERENTIAL
SWITCHING CIRCUIT
John from New Zealand
HELLO MASTER!
WHAT CAN I PRINT
FOR YOU?
WAIT!
WHERE ARE YOU GOING?
YOU'RE INTELLIGENT -
YOU CAN FIGURE IT OUT!
WHOA... CHEERS!
*CLINK*
https://www.facebook.com/DremelAustralia/
3 Tools
27 Pieces
Dream like a child.
Build like a machine.