Elektor 03 2020
Elektor 03 2020
Elektor 03 2020
com
lektor
DESIGN SHARE SELL ELECTRONICS
magazine
Open-Network
Weather Station
Mk.2
Measure, log, stream,
multi-sensor
environmental data
to ThingSpeak,
openSenseMap
Object recognition using the Maixduino board Switch and dim a variety of loads
Analogue Electronics Design BalBot: a Self-Balancing Robot BASIC for the ESP32/ESP8266 CAN Bus + Arduino for Solar PV Cell Monitoring
Elektor 1.2 GHz Multifunction Frequency Meter (1992/93) Elektor New Precise Nixie Clock Revisited How-To: GitHub For Dummies Inexpensive
E-Scooter Joy-IT HD35 Electronic USB Load My IoT Button: A Button for the Web Open-Network Weather Station Mk.2 PeakTech 6080 A
Lab Power Supply Practical ESP32 Multitasking Safe products in the IoT era SigFox and the IoT Small Circuits Revival Starting Out
in Electronics Tamper-Evident Box TMS0280 Speech Synthesizer …and more
IoT Home Hacks
with ESP8266
Description:
Ready to start building Internet of
Things (IoT) solutions? With a little
know-how and the right tools, such as
the ESP8266 Wi-Fi module, you can
design and build handy IoT solutions for
your home or office. In IoT Home Hacks
with ESP8266, Hans Henrik Skovgaard
introduces the ESP8266 – in the form
of the WeMos D1 Mini Pro – and then
covers a variety of IoT hacks that you’ll
find immediately useful.
O W6
lektor
N 31,4 rs
€ fo
r mem
be
www.elektor.com
A well-developed
www.elektormagazine.com
network — more
Elektor Magazine, English edition important than ever!
is published 6 times a year by
Just a few weeks ago I had planned to report about the Embedded World
Elektor International Media
78 York Street 2020 trade show in this editorial space. As always, I discovered interesting
London W1H 1DP products there. But the show, held at the end of February, now seems to be a
United Kingdom thing of the distant past. In the meantime, we got used to queueing in front
Phone: (+44) (0)20 7692 8344
of supermarkets and DIY stores, and seeing our colleagues on video only.
Head Office:
On the other hand, videos from last year on the Internet now seem almost
Elektor International Media b.v. surreal to me — lectures on electronics to a closely packed audience, or music
PO Box 11 festivals with cheering crowds.
NL-6114-ZG Susteren However, life goes on. With a little creativity you can network even in these
The Netherlands
times. One of my colleagues recently celebrated his birthday using the ‘Zoom’
Phone: (+31) 46 4389444
video platform. Among his ‘guests’ were many electronics engineers, some of
whom had joined in from their lab. Personally, together with a few friends I
Memberships:
am about to broadcast a regular DJ livestream, from living rooms but properly
Please use London address equipped technically. You may also have ideas on how to continue exchanging
E-mail: [email protected] ideas with like-minded people in order to advance a common project. Elektor
www.elektor.com/memberships offers a platform for electronics projects at www.elektor-labs.com, which was
recently given a new look, a faster engine and extended functionality.
Advertising & Sponsoring: Elektor’s English edition quietly reached number 500 in March 2020 and Elek-
Margriet Debeij
tor Germany turns 50 this month. Both are unique successes in the industry,
Phone: +49 170 5505 396
E-mail: [email protected]
precisely because many readers have remained loyal to us for decades. But
especially in these times, this should not be a reason for Elektor to rest on
www.elektor.com/advertising
its laurels. On the contrary, wires and brain cells are glowing. For example, I
Advertising rates and terms available on can divulge that new offers and media formats are in active development to
request. inform all electronics technicians in an even more targeted way.
Stay tuned and above all, stay healthy!
Copyright Notice
The circuits described in this magazine are for domes-
tic and educational use only. All drawings, photographs, Jens Nickel
printed circuit board layouts, programmed integrated International Editor-in-Chief, Elektor Magazine
circuits, disks, CD-ROMs, DVDs, software carriers, and
article texts published in our books and magazines
(other than third-party advertisements) are copyright
Elektor International Media b.v. and may not be repro-
duced or transmitted in any form or by any means, The Circuit
including photocopying, scanning and recording, in
whole or in part without prior written permission from International Editor-in-Chief: Jens Nickel
the Publisher. Such written permission must also be
Editor-in-Chief, English edition: Jan Buiting
obtained before any part of this publication is stored
in a retrieval system of any nature. Patent protection Membership Manager: Denise Bodrone
may exist in respect of circuits, devices, components
International Editorial Staff: Eric Bogers, Rolf Gerstendorf, Denis Meyer,
etc. described in this magazine. The Publisher does
not accept responsibility for failing to identify such Dr Thomas Scherer, Clemens Valens
patent(s) or other protection. The Publisher disclaims
any responsibility for the safe and proper function
Laboratory Staff: Mathias Claussen, Ton Giesberts,
of reader-assembled projects based upon or from Luc Lemmens, Clemens Valens, Jan Visser
schematics, descriptions or information published in or
in relation with Elektor magazine. Graphic Design & Prepress: Giel Dols
Mk.2
6
Regulars
26 How-To: GitHub For Dummies
How to download something from GitHub
42 Developer’s Zone
Tips & Tricks, Best Practices
and Other Useful Information
12
98 Steeped in Electronics
Lead-free soldering and EU regulatory zeal
Projects
6 Open-Network Weather Station Mk.2
Part 1: Introduction and hardware elements
54 Tamper-Evident Box
Send data securely through postal services
18
62 Elektor New Precise Nixie Clock Revisited
An engineering bulletin for enthusiastic
users new and old
Next Edition
Elektor Magazine Edition 4/2020
(July & August)
A Wireless Temperature Sensor for the Nixie Bargraph
Thermometer • Home Information System • Advanced
LCR Meter Sneak Preview • Open-Network Weather Sta-
tion Mk.2 Software • S/PDIF Converter • Analogue Elec-
tronics Design (4) • HV Power supply with Curve Tracer
94 Inexpensive E-Scooter
108
• LED Booster for Microcontrollers • Home Automation
How does Lidl’s „road approved“ Made Easy • Node Red Book • Small Circuits & Tricks •
300-euro E-scooter perform? Retronics • and more.
101 Review: Elektor Magazine edition 4/2020 covering July & August 2020 is published
The PeakTech 6080 A Lab Power Supply around 3 July 2020. Delivery of printed copies to Elektor Gold Members is
A neat lab PSU for not much money subject to transport. Contents and article titles subject to change.
Open-Network
Weather Station Mk.2
Part 1: Introduction and hardware elements
By Mathias Claußen and Luc Lemmens (Elektor Labs)
+5V
MOD1
DC-DC converter
T1 T2 OKI-78SR-5/1.5-W36-C €60 (main board incl. enclosure)
FQP27P06x FQP27P06x €40 (cone including BME280),
1 3 €50 (dust sensor incl. case )
GND
(prices approx.)
R2 R1 R9
2
100k
1M
C1
8
100µ 1k
25V
2
K1 IC1 LED 1
+ R3 R8 MAX8212
100k
1M8
-
4
Power supply with polarity
3
GND
protection and undervoltage
R4
5 lockout
220k
IO34 SPEED
BS170 IO37
24
DIR
If — for whatever reason — the charging
5V I2C 7
SDA IO26
IO38
25
RAIN process or the powering device fails to
SCL
GND IO27
10 GND
produce enough energy to compensate
9 K3
6
IO25
IO33
8 for the power inevitably dissipated by
IO32
T4 the weather station, the energy source
K4 BS170
SCL
must be disconnected to prevent deep
29
SDA RX0
TX0/IO17
28
+3V3 K5 discharging, which is a common source
+3V3
27
12
+3V3 of battery failure. For this task we
K9 IO12 MISO
R7
V+ 1k IO13
13
MOSI selected the good old programmable
15 11
IO2 IO14 SCK
IO2 16
IO4 IO15 14 CS0 voltage detector type ICL8212, which
IO4
17
IO0 19
IO0 GND
today equals its CMOS successor type
GND GND GND
22
MAX8212 from Maxim Integrated. With
only three external resistors for adjust-
ing thresholds/hysteresis and one exter-
nal p-channel MOSFET as a switching
device, the ’8212 does exactly what we
Figure 1: Schematic of the Main Board in the Open-Network Weather Station Mk.2 that’s compatible want: avoid any risk of deep discharge
with global sensorics platforms like ThingSpeak and openSenseMap. Note the bare-bones but of the battery.
perfectly working bidirectional 3.3-V/5-V, FET-based level shifters on the I2C bus. With the given values for R2, R8 and
b
component list
-
+
T1 T2
K1 LED1
R3 R1R8 C1
R2 MOD1
(C) Elektor
R9
R4 IC1 191148-1
K8
5V
e GND 5V
C2 K9
K2
T IO2
V+ GND
MOD3
SCL
K4
MISO
MOSI
GND
SCK
CS0
3V3
SDA
K5
R6
R5
10k
10k
(or LoRa, once we have it implemented). K1 5 K3
4 3 MOD1
+5V
The main board also contains a Reset and SPEED
3
SDA
4
2 SCL BME280 BOB
DIR
a User button, plus a USB connection for 1
MOD2
flashing the weather station’s firmware. +3V3
SDA
SCL
R3 NC 1 7
K4
SD card RAIN +3V3
10k
6
K5 GND
For the micro-SD card connector (K5) we 5
4 +3V3
RAIN
3
opted for a small breakout board avail- GND 2
NC
AIR
1
able in the Elektor Store. It has a 100-mil PRESSURE
191148-027 KD
pitch pinheader that’s easily soldered and
connected to the main PCB. This BoB has
to be mounted perpendicular to the main
Figure 3: Schematic of the Connector Board for the rain and wind sensors. It also accommodates
board in order to access the card. You can
the pressure/humidity/temperature sensor module.
either replace the straight pinheader on
the BoB with an angled type or use pliers
and judiciously applied force to bend the
pins over 90 degrees. Be careful not to case specified in the Component List. Connector board (no. 191148-2)
damage this small board though. The lab prototype of the board is pictured Although this board also accommo-
in Figure 2. Note that the 3.81-mm dates the pressure/humidity/tempera-
I2C bus & LCD (0.15-inch) PCB terminal blocks can be ture sensor (module), its main function
The on-board I2C bus is used for commu- turned 180 degrees (i.e. with the connec- is to provide connectivity between the
nication with the LCD (on K6) and the air tions facing inwards) to create more ESP32 microcontroller and the peripheral
pressure/temperature/humidity sensors space in the housing for connecting the sensors. Refer to the circuit diagram in
(on K4), but it can also accommodate cables. An oddball solution indeed but Figure 3. This ‘circuitry’ replaces the
other I2C compatible sensors or devices totally workable. board inside the thermo/hygro unit that
you may want to add to the weather
station. Pull-up resistors R5 and R6 are
needed for this bus. However, if you
connect an I2C device on K4 that already
contains pull-ups on the bus connections,
component list
be sure to omit R5 and R6 or desolder/
cut these parts from the PCB. The LCD
module suggested for use here [2] does
have on-board pull-up resistors tied to its
5 V supply voltage. FETs T3 and T4 act
as bidirectional 3.3 V / 5 V level shifters
to match the ESP32 I/O pins, which are
not 5 V tolerant.
Not forgetting…
MOD3 accommodates an optional RFM95
breakout board (BoB) to cater for LoRa
connectivity. This is a future extension
and not supported yet in the current
software release.
Connectors K7 and K8 interface to a
Honeywell particle (dust) sensor. The
sensor is subject to damage and malfunc-
tion caused by frost, so we didn’t mount
it in the thermo/hygro sensor case which
requires installing in more open space.
The PCB designed for the main board is
a perfect fit for the Spelsberg IP66-class
Web Links
[1] ESP32 Weather Station, Elektor Labs magazine edition 1/2019: www.elektormagazine.com/magazine/elektor-70/42351
[2] 2×16 character LCD with I2C: www.elektor.com/two-wire-lcd-071035-93
[3] Publication support page: www.elektormagazine.com/191148-01
[4] Project development page: www.elektormagazine.com/labs/remake-elektor-weather-station
Next time
In Elektor magazine edition 4/2020 cover-
ing the pleasant-weather months of July
& August we continue with the software
developed for the Open-Network Weather
Station Mk.2. You can actively follow the
progress on our Labs website [4].
191148-01
Figure 6: Ready assembled Dust/Particle Sensor Board mounted in the IP66 class case.
component list
There is no hotter topic in the world of IT than artificial intelligence (AI). A good low-cost introduction to
the fields of speech and image recognition as well as other aspects of AI is the Maixduino board which,
including the fitted camera and small LCD panel, comes in at only around €30/£25/$35; what’s more, it can
readily be programmed using the familiar Arduino IDE. In the first instalment of this series we will look at
the comprehensive array of hardware offered by the Maixduino and at a couple of demonstration programs,
including one that can recognize 1000 different objects.
has the same format as an Arduino Uno notice the higher component density and an audio amplifier with a 3 W output
(from which it gets its name), but the that many additional connections are driven by a digital-to-analogue converter.
hardware it includes is considerably more available. At the heart of the board there So there is plenty of hardware on the
comprehensive. The board is manufac- are two large modules. The first is the board to let you get started on a range
tured by the Chinese company Sipeed. Sipeed M1 AI processor module based on of possible projects without having to
Alternatives to the Maixduino include the the Kendryte K210 device, whose interior add extra boards.
Nvidia Jetson Nano, the ROCK PI N10 workings we will look at later, and the The pinout of the board (see Figure 2)
Model A, the Intel Neural Compute second is an ESP32 module for communi- closely resembles the original. The
Stick 2 and others, but these all cost cating over WLAN and Bluetooth and for supply voltage can be provided over
considerably more. acquiring analogue signals. The ESP32 the DC barrel jack or using the VIN pin
In this first instalment of this series we contains two processor cores clocked at at 6 V to 12 V; alternatively, 5 V can
will look at the rich hardware environ- 240 MHz and so by itself offers a consid- be supplied over the USB connector. Six
ment offered by the Maixduino and how erable amount of processing power, and of the ESP32’s GPIOs are brought out;
it can be programmed with the help of it can be used to offload communica- these are the ones that can alternatively
the Arduino IDE. As well as a couple of tion functions from the main processors. be used as analogue inputs A0 to A5. On
typical Arduino-esque applications we will The ESP32 has already featured in many the opposite edge of the board are the
look at how to use the camera and the articles in this magazine, and so we will inputs and outputs of the K210 module.
screen. And the final highlight will be a not go into further detail about it here. These can be controlled using the usual
demonstration of how to use the board The header connectors correspond in Arduino commands, with the ‘Arduino pin
to recognize objects. number and arrangement to the origi- number’ being the number of the input
In the second and third instalments we nal Arduino, and the pin assignments or output bit of the K210.
will delve deeper into the topic of artifi- are mostly identical. But beware that
cial intelligence, describe the structure of the inputs and outputs are designed for #define LED 12
neural networks, install MicroPython and 3.3 V or even 1.8 V operation, and the // K210 IO12, Maixduino pin 10
its accompanying IDE and demonstrate input circuitry will be destroyed if pinMode(LED, OUTPUT);
how facial recognition works. We will also 5 V is applied. // configure port as output
look at how you can program your own Further details are shown in Figure 1.
digitalWrite(LED, HIGH);
AI applications and how to communicate Two 24-pin sockets are provided for
// port to high (3.3 V)
with the Internet. interfacing to the camera and to the LCD
panel. A slot is provided for a microSD The RST pin is designed to operate at
A deep dive into the ‘super card which can be used to make a 1.8 V and external circuitry should not
Arduino’ large amount of storage available to apply a higher voltage than that to it.
The specifications of the Maixduino will the Maixduino. The USB connector is Outputs IO36 to IO47 are also designed
have hardware enthusiasts licking their the modern type-C kind and is used for for low-voltage operation: these are not
lips! The overall size and construction of programming and monitoring. And, to brought out to the headers, but are used
the board is broadly aligned with that of allow the processing of audio data, the internally, for example to drive the LCD
the Arduino Uno, but you will immediately board includes a digital microphone and panel. The serial RX and TX ports and the
Software development
It is not just the shape of the board
Figure 5: Installation of the Maixduino core tools. that is similar to the original Arduino:
Coming up...
The demonstration application we have
looked at in this article can only scratch
the surface of the topic of artificial intel-
ligence, but with luck your interest in the
possibilities of machines that learn has
been piqued.
Web Links
[1] Maixduino description: https://wiki.sipeed.com/en/maix/board/maixduino.html
[2] Sipeed forum: https://bbs.sipeed.com/
[3] Maixduino circuit diagram: http://dl.sipeed.com/MAIX/HDK/Maixduino/Maixduino-4.30/
[4] MobileNet demonstration: https://github.com/sipeed/Maixduino/tree/master/libraries/Maix_KPU/examples/mobilenet_v1
[5] MobileNet model data file: http://dl.sipeed.com/MAIX/MaixPy/model/mobilenet_0x300000.kfpkg
Advertisement
01256 812812
[email protected]
Everyone involved in electronics knows more or less what module. Figure 1 shows the author’s finished prototype. Many
thyristors and triacs are, how they work and how they are functions are possible with this combination of an ATmega
used. However, these components offer so many possibilities microcontroller and a triac. Depending on the firmware, the
that only specialists are able to fully exploit their potential. module can be used as a simple switch or remote switch, a
Nowadays thyristors are mainly used in special applications timer, a dimmer, or a soft-start module for switching inductive
with high voltages (above 1 kV) and strong currents (many loads such as transformers or motors.
kiloampères), so this article only focuses on triacs.
Basics
First we look at the basic operation of triacs and the relevant A triac is a semiconductor switch that conducts current in both
parameters. Then we describe the circuitry of the control directions when it is switched on, which means it is an AC
100k
220 120
1k
SCR1
C8 BTA_312B R15
CX1
4k7
47n C6
D5
235V AC 4,7n 10n
LL4448
AC_L 250V AC
KL1-2
F1
T4A
ATMEGA168PA_TQFP
R4
29 23
22k PC6(/RESET) PC0(ADC0)
24 JP2
PC1(ADC1) 1 2
21 25
GND PC2(ADC2) 3 4
26
20 PC3(ADC3) 5 6
AREF 27
18 PC4(ADC4/SDA)
28 ISP
AVCC PC5(ADC5/SCL)
19 R10 R9 R2
ADC6
C2 22
100k
100k
ADC7
22k
22p 7
PB6(XTAL1/TOSC1)
3 30
4 PD0(RXD)
31
PD1(TXD)
2 X1 32
PD2(INT0) OK2
C3 1
1 8 PD2(INT1) LTV816S 1 R7
22p 2
PB7(XTAL2/TOSC2)
470
PD4(XCJ/T0) 4
9
3 PD5(T1) S2
GND 10
PD6(AIN0) JP1
5 11 3
GND PD7(AIN1) 1 3
4 1
2 D2 LL4448
VCC 12 2
6 PB0(ICP) 2 4 2 D1 LL4448
VCC 13 4 3
PB1(OC1A)
14
PB2(SS/OC1B)
15
PB3(MOSI/OC2) 3 R8
16
470
PB4(MISO) S1
17 R5 R3 OK1 1
PB5(SCK)
100k
470
LTV816S
1 3
IC1
D10 C1 C5
2 4
5V2 220µ 100n
LED1 C4
470p
190047-006-94 KD
Figure 4: The circuit diagram of the control module. Crystal X1 has a frequency of 11.0592 MHz.
Triac control module A series capacitor would be simpler, but MKT capacitors with
Now let’s get down to practice. Thanks to its intelligence, the the necessary capacitance and voltage rating are not exactly
universal triac control module can act as a multi-purpose simple cheap. A series resistor is even simpler. We want the triac to
switch, a timer with delayed switch-off or a dimmer, or be used operate in quadrants II and III. This requires a negative gate
to control inductive loads. That’s a lot of versatility from a trigger voltage relative to the T1 electrode, which is connected
single module. If you understood ‘intelligence’ to mean ‘micro- directly to the AC mains. This is most easily achieved with a
controller’, you got it right. Here we chose an ATmega device. half-wave rectifier. However, the feasibility of this is directly
With regard to triac selection, the main criteria are the current dependent on the current consumption of the circuit.
to be switched and the maximum voltage on the triac. With The MCU and the trigger energy required by the triac are the
operation from a single-phase AC mains, around 600 V is main considerations in this regard. The MCU does not have much
sufficient (230 V × √2 plus a safety margin). For industrial to do and can therefore spend most of its time in low-power
applications it is better to use triacs with 800 V reverse sleep mode. The average trigger energy is low because only
voltage rating, due to the high transient voltages in indus- short trigger pulses are needed. The question is how low we
trial environments. The current actually possible in practice can make the current consumption. The MCU is in Extended
depends not only on the rating of the triac, but also on the Standby Sleep Mode most of the time and is only awakened
manageable power dissipation, and thus on the cooling. to generate the trigger pulses.
The power dissipation is equal to the product of the forward
voltage and the switched current. The worst case is high-frequency triggering without zero cross-
The minimum load current in the application must also be ing detection, with a trigger signal generated every 278 µs.
considered. Both IL and IH must be clearly exceeded, as other- Then the ATmega needs 1.9 mA in practice, with a V CC of
wise the load will not be switched on cleanly or the current will 4.7 V. With a peak gate current of 11 mA for each 10 µs pulse
not flow continuously. The 600 V devices BT134-600E (4 A) and a period of 278 µs (3.6 kHz), the average gate current is
and BTA312B (12 A) are good general-purpose devices that 400 µA. The total current is therefore approximately 2.3 mA.
are suitable for many simple purposes. This determines the value of the series resistor and its power
dissipation. With half-wave rectification, the effective value is
Powering the module Ipk/2 and the average value is Ipk/π. This yields:
Supplying power to the module is not trivial. A small switching
power supply would be nice, but would need a lot of space. Ipk = 2.3 mA × π = 7.3 mA
Ieff = Ipk / 2 = 3.7 mA
Hardware
In the circuit diagram shown in Figure 4, power for the MCU
and the peripherals is provided by the series resistors R11-R13, (IC1) is programmed through the ISP interface on JP2. Fuse
half-wave rectification with D13, and filtering with C1. The MELF F1 at the AC mains input protects the circuit in the event of
resistors used here for R11-R13 have a high breakdown voltage a short circuit.
and power rating. Due to the high impedance of the power
supply, it effectively approximates a current source, allowing Software
the Zener diode D10 to easily provide a constant voltage. The project software [1] was written using the Arduino IDE.
The MCU clock is controlled by crystal X1 to ensure precise However, the author did not use the Arduino functions because
timing of the trigger pulses. The network formed by diode they are too slow. The program created by the author is very
D12 and the voltage divider R2, R3 and R19-R22 generates fast and operates in real time. The sketches were there there-
a signal suitable for zero crossing detection, which is clipped fore intentionally not ported to Atmel Studio.
to VCC by diode D5. Unfortunately, it is not possible to use the boot loader to
The gate current is limited by R16 and R17. Fast triggering program the microcontroller. So much current would be needed
of the triac is provided by C6 in parallel with R16. A snubber at switch-on that the supply voltage would not rise. This means
formed by R24 and C8 is connected across T2 and T1 of the that the fuses must be set to disable the boot loader. The
triac to prevent false triggering. The triac used here is a Hi-Com microcontroller can be programmed directly from Atmel Studio
type, so the combination of a small capacitance and relatively using a suitable ISP programmer.
high resistance is sufficient. For each app, the project folder contains the corresponding
sketch and the hex file. In the initial programming, it is essential
The optional auxiliary load, consisting of R25-R27 and C7, is to program the fuses as shown in Figure 5. Then the desired
a special feature. It is only required if the external load has hex file can be loaded from the project folder and flashed in
high inductance, such as a transformer. These components are the MCU (see Figure 6). If a sketch is modified, it must be
usually not fitted. Capacitor CX1 suppresses RFI. recompiled (verify and compile). The IDE status field shows
The module is operated using the pushbutton switches S1 the folder containing the generated hex file. An example of a
and S2. This can also be done with optocouplers OK1 and typical file path is
OK2 connected in parallel with the switches. Switches with
long actuator pins should be used to ensure adequate safety C:\Users\name\AppData\Local\Temp\buildxyz.tmp/
distances. LED1 acts as a power indicator. The microcontroller Triac_...ino.hex
Applications
As the folder name and build number are reassigned every All apps have the same initialisation procedure. On power-up,
day, the file also has to be updated daily in Atmel Studio. If
the BOD level of 2.7 V determines the end of the reset inter-
the folder AppData is not visible in File Explorer, select Show
val. After the following program start, the watchdog timer is
hidden files and folders under View/Options. activated and the program is put into sleep mode. This allows
Then load the desired hex file in Atmel Studio and program VCC to rise quickly and reliably (Figure 7). The WD timeout
the ATmega microcontroller. triggers the WD interrupt and terminates sleep mode. Then
execution of the actual program starts.
Warning: For programming, the module must be fully separated The sketch excerpt in Listing 1 shows how setting the WD
from the AC mains and powered by a safe low-voltage supply. timer and sleep mode is implemented. The listing contains part
of the code of the initialisation procedure. First the watchdog
is set and activated. Then the microcontrol-
ler is put into sleep mode. The WD timeout
triggers the WD interrupt, which wakes up the
Listing 1
microcontroller.
void setup() A separate sketch is available for each example
{ app. Each app has its own distinct functions,
//after reset, start with sleep mode to stabilize VCC. which can be selected using pushbuttons or
//prepare the watchdog for wakeup
jumpers. More information is available in the
comments of the individual sketches.
asm ("WDR"); //clear wd-timer
A simple switch and timer app
WDTCSR= 0x1c; //set WDCE, WDE to enable setting
The Sketch Triac_no_zd_32 app manages
WDTCSR= 0x1c; //wd-timer 0.25s without zero crossing detection, so it illustrates
WDTCSR= 0x14; //clear WDE the basic programming of the module and its
WDTCSR= (WDTCSR | 0x40); //set WDIE, enable WD-interrupt features. The module is operated from a 5 V AC
interrupts(); //enable interrupts power adapter for programming and testing. If
you are interested in hardware-level program-
SMCR= 0x0f; //prepare xtd-standby ming of the WD timer, the various sleep modes,
asm ("SLEEP"); //enter sleep mode the interrupts, the timer functions or the I/O
SMCR= 0x00; //finish, not necessary commands, you should study the code in
noInterrupts(); //disable interrupts, after wakeup
detail. All of the software can be downloaded
free of charge from the Elektor web page for
this article [1].
MCUSR= (MCUSR & 0xf7); //clear WDRF, wd-reset active
WDTCSR= WDTCSR | 0x18; //set WDCE, enable setting WDE
With this app the module can act as a switch
WDTCSR= 00; //clear WDIE, disables wd-timer or as a timer, with the actual function selected
by a pushbutton. With the additional operat-
. . . ing mode ‘Autostart’, the timer starts running
immediately after power-up and the load is
} switched off when the timer period expires.
This function can be used to limit how long a
lamp remains on. The switch-off time is stored in the program. Dimmer
In the on state, the program generates periodic 10 µs pulses Dimming the brightness of a lamp is a typical application for
with an period of 278 µs to drive the triac. The control pulses a triac. The lamp power is adjusted by phase angle control.
are not referenced to the AC mains frequency, so the switch- Here the switch-on point of the load (phase angle) is varied
ing times are not synchronized to the mains voltage. In the with respect to the zero crossing point of each half-wave of
worst case, the load will only be switched on 278 µs after the mains voltage. Dimmers can cause a lot of EMC problems
the zero crossing. At this point the mains voltage will have because they generate voltage waveforms with high amplitudes
already reached 29 V, resulting in voltage spikes that can and steep edges, depending on the phase angle. The worst case
cause EMC problems. To illustrate this, the oscillogram in is switching at the crest of the mains voltage (with a phase
Figure 8 shows what happens over an interval of 1 second. angle of 90°). When the triac is triggered, the voltage on the
The trigger pulses are not correlated to the zero crossings, triac quickly drops from the crest value to zero (Figure 11).
so they wander with respect to them. The voltage over the Depending on the load, this results in very high currents and
triac varies according to the offset between the zero cross- high noise levels. An upstream RFI filter (for example, from a
ing and the trigger pulse. discarded dimmer) is therefore essential.
This is remedied in the next practically oriented application, in Many LED lamps do not work with conventional dimmers, due
which the zero crossings are detected so that triac triggering to the design of their power supply. This module also has diffi-
is synchronised with the zero crossings. Unlike the following culties with quite a few LED lamps. You should therefore use
measurements, the reference voltage here is VCC. T1 of the dimmable lamps.
triac is at VCC, so here you see the control pulses on the gate
with negative polarity. An interesting feature of this triac control is that after the
first pulse, additional pulses are inserted until the end of the
Switch and timer with zero crossing detection half-wave. This allows the module to be used with relatively
Unlike the previous app, here a signal derived from the AC complex loads. At full power, the first pulse after the zero
mains voltage is used to detect the zero crossings of the mains crossing is extended to 190 µs. This ensures that IH is exceeded
voltage. This signal is applied to the INT0 input, where its
falling edges trigger interrupts that mark the start of the first
half-wave. The end of this half-wave and the start of the next
half-wave are determined by Timer 2. This avoids complicated
hardware for precise detection of both zero crossings.
For reliable triggering with low load currents, the first trigger
pulse of each half-wave is extended to 280 µs. It is following by
two more 10 µs trigger pulses. This ensures that the IL of the
triac is exceeded even with high-impedance loads. Figure 9
shows this relationship. The short bumps (approximately 3 V)
in the voltage on the triac at the end of each half-wave are
particularly noteworthy. They result from the relatively low
current through the connected LED lamp, which drops below
IH at the end of each half-wave. However, this has little impact
on the noise level.
Figure 10 shows the superimposed traces over an interval
of 1 second. The control pulses are synchronous with the Figure 11: Dimmer with phase angle control. Ch1 (blue): gate pulses; Ch2
mains voltage. (green): zero crossing signal; Ch4 (red): voltage on triac.
Figure 14: Transformer current with no load. Ch1 (blue): gate pulses; Ch2 Figure 15: Transformer current with a small load. Ch1 (blue): gate pulses;
(green): zero crossing signal; Ch4 (red): transformer current. Ch2 (green): zero crossing signal; Ch4 (red): transformer current.
even with high-impedance loads. you should start with a phase angle of around 180° and then
The output power can be set with the two pushbuttons or with slowly reduce it to 0°. This is exactly what is done in this app.
optocouplers. Figure 12 shows the pulse sequence after a restart. The first
trigger pulse is generated approximately 8.6 ms after the zero
Soft start for inductive loads crossing. Another pulse is added ahead of it after each full
Inductive loads, especially transformers, can draw very high wave, until the time is reduced to around 0.3 ms. Figure 13
switch-on currents. Here switching at the voltage zero crossing shows the situation after settling down. Within the first 3 ms,
is the most difficult situation. The residual magnetisation of the the load current goes through zero due to the phase shift. In
core can also cause problems, because the switch-on current order to achieve a continuous current flow, it is necessary to
waveform may be offset from the zero line. As a result, the put the control pulses close together in this interval.
flux density in the core (the hysteresis loop) is shifted in one Figure 14 shows the transformer current with no load. The
direction and can easily enter the saturation region. When that zero crossing signal shows the relationship to the mains voltage.
occurs, the winding inductance suddenly drops to zero and the Here you can see the magnetisation current, which reaches
rising current is only limited by the resistance of the winding a maximum at the voltage zero crossing. The remaining part
and other elements. Ring-core transformers are especially prone results from the iron and copper losses of the transformer. The
to this. They should therefore be fused at a significantly higher phase lag of the current is not exactly 90°, due to losses and
level than what is required solely for the load current. nonlinearities in the core. Figure 15 shows the transformer
Sometimes a varistor or series resistor with a time-delay relay is current with a load. The load current and magnetisation current
used to limit the switch-on current until a symmetrical magnetic are superimposed. The load reduces the phase shift.
field (and correspondingly clean AC voltage) is established. A prerequisite for faultless operation is fully symmetrical control
In theory, this problem can also be encountered if the phase of the triac. The control pulses must have the same offset to
angle is slowly increased. When switching on the transformer, the zero crossing for both half-waves, so that the phase angle
Web Link
[1] Project support page:
www.elektormagazine.com/190047-04
Advertisement
GREEN
MEMBERSHIP
✔ 6x Elektor Ma
gazine (PDF)
✔ 3x Elektor Indu
stry Magazine
(PDF)
What is GitHub?
GitHub is a hub for git, where ’Git’ is a versioning
system, meaning it keeps track of changes made
to any document it’s aware of. The main purpose
of ’git’ and GitHub is to allow groups of people
to work together on the same software project.
Because GitHub is a tool for professional- and
production-quality software development, it has
lots of functions and options that most people
never need, and that make it complicated to use.
How to download from GitHub? The green ’Clone or download’ button is only visible in the root of the repository.
At Elektor too we publish code on GitHub and
tell people to download it from there. We then
often get the question “How do I download something from The green ’Clone or download’ button
GitHub?” This seems like a silly question to the experienced There is an easy download button, but it is only visible when
user, but it’s true, you cannot just download the files you see you are in the root of the repository. Once you are there things
listed in a repository. There is no Save or Download button, become easy: just click the green button labelled ’Clone or
and when you click on a file, it gets opened in a browser, not download’. However, you might get confused by the surprising
downloaded. If you right-click on a file and then save it, you options about ’cloning with HTTPS’, or open it on your desktop,
end up with a file containing HTML code, and not the contents or download ZIP. Here you just click ‘Download ZIP’ and ignore
you expected. the other stuff. You do not need to sign in or have an account.
Advertisement
The Internet of Things (IoT) makes all imaginable devices smart for requests. The client, which in this case is the IoT device,
and connects them to the outside world through the Internet. can send data to services (on a server) or request data from
In the first article of this series, we outlined the basic architec- services. In the second article of this series, we look at the
ture of an IoT landscape consisting of sensors, actuators, and a hardware and software aspects of the IoT device.
server backend. We saw that you usually do not have to set up
your own server infrastructure, since there are many options Selecting the hardware
available in the cloud. You communicate with them through What hardware should you use? There are basically several
the Internet. Things are really simple if you also adhere to the options — for example, a single-board computer such as the
established standards. RESTful communication is widely used Raspberry Pi. Along with WLAN, the RPi has enough process-
Figure 1: Pin assignments of the ESP8266 NodeMCU microcontroller Figure 2: Arduino IDE configuration for programming the ESP8266.
board.
include <ESP8266WiFi.h>
void setup()
{
Serial.begin(115200);
WiFi.begin(<SSID>, <Password>);
while (WiFi.status() != WL_CONNECTED);
{
delay(1000);
Serial.print("Connecting ...");
}
}
Figure 4: ESP8266 NodeMCU board with WLAN module.
If you want to use the WLAN functionality of the ESP8266, you Data in the cloud
have insert the line #include ESP8266WiFi.h in the header A REST endpoint is required in order send data to the cloud,
of the source code to include the corresponding library. The which means to a remote server. You do not have to program
library expects the right data for establishing a connection to this yourself; you can instead use existing services. Most of
the Internet: the SSID and the password. For now you can do these cloud services are free of charge for tests and personal
put these in the source code as static data, but later on you use. Let’s proceed experimentally and step by step. At [5] you
will want to allow users to configure them. Establishing the can create a free REST API for test purposes, which can be
WLAN connection is remarkably simple (Listing 2). accessed from the microcontroller board via the WLAN. This
Now you should proceed with the design under the assumption works with just few mouse clicks, even without prior login.
that when an event is received, a message is sent via the network. Have a look under [6]; there you can see that we have already
A REST endpoint acts as the receiver of this network communica- created an endpoint (Figure 5). To test whether and how this
tion, as described in the first article of this series. This endpoint endpoint can be reached from the microcontroller, you can send
accepts the data or message and can further process it and initi- a GET request to the service when the button is pressed. This
ate a response. With a simple IoT button, the only data that has is implemented in the program loop (Listing 3).
to be sent is the ‘button press’ event. With suitable expansion of
this application, you could also sent additional data as parameters The following line in the source code checks whether the micro-
of the REST request. Now let’s see how it works. controller is connected to the Internet:
Listing 3. Send a GET request to the REST endpoint. String payload = https.getString();
Serial.println(payload);
void loop()
}
{
else
if (WiFi.status() == WL_CONNECTED)
{
{
Serial.print("Error: ");
status=digitalRead(button);
Serial.println(httpCode);
if (status==LOW)
}
{
https.end();
digitalWrite(LED, LOW);
}
BearSSL::WiFiClientSecure client;
else
client.setInsecure();
{
HTTPClient https;
digitalWrite(LED, HIGH);
https.begin(client, "https://iotbutton.free.
}
beeceptor.com");
int httpCode = https.GET();
}
if (httpCode == 200)
}
{
This means that all the enclosed source code lines are executed
only if there is a connection to the Internet.
The next step checks whether the button has been pressed:
status=digitalRead(button);
if (status==LOW)
Listing 5. Send a GET request via REST and go into BearSSL::WiFiClientSecure client;
deep sleep mode. client.setInsecure();
#include <ESP8266WiFi.h> HTTPClient https;
#include <ESP8266HTTPClient.h> https.begin(client, "https://iotbutton.free.
beeceptor.com");
#define LED D4 int httpCode = https.GET();
void setup() if (httpCode == 200)
{ {
Serial.begin(115200); String payload = https.getString();
pinMode(LED, OUTPUT); Serial.println(payload);
digitalWrite(LED, HIGH); digitalWrite(LED, HIGH);
WiFi.begin(<SSID>, <Password>); delay(2000);
while (WiFi.status() != WL_CONNECTED) ESP.deepSleep(0);
{ }
delay(1000); else
Serial.print("Connecting ..."); {
} Serial.print("Error: ");
} Serial.println(httpCode);
}
void loop() https.end();
{ }
if (WiFi.status() == WL_CONNECTED) }
{
digitalWrite(LED, LOW);
A0 D0
RSV D1
RSV D2
D12 D3
D11 D4
INT 3V3
MO GND
MI D5
SCK D6
GND D7
3V3 D8
S1 EN D9
RST D10
GND GND
5V 3V3
Figure 8: The circuit diagram consists of the microcontroller board and a Figure 9: Collaboration between the IoT device, IoT cloud and other
single pushbutton. services, using ThingSpeak as an example.
mately 71 minutes. This option is a good choice in scenar- the code. Instead, the microcontroller is put into sleep mode
ios where periodically measured values are transmitted. after the data has been sent successfully over the REST inter-
The instruction for this is: ESP.deepSleep(SLEEP_TIME * face (Listing 5). Compile the source code (sketch) and load
1000000) it into the microcontroller. After starting up, the microcontrol-
• Interrupt deep sleep: The ESP8266 does not automatically ler connects to the network, sends a message, and goes into
restart, but instead is awakened from deep sleep mode sleep mode. When the microcontroller is awakened by the
by an interrupt. This form of deep sleep mode is initi- pushbutton (RST), this process is repeated from the beginning.
ated by ESP.deepSleep (0). In this case there must be no You can check online whether the GET request has reached
connection between GPIO16 and RST. When the event is the REST API.
triggered, a Low signal is sent to the RST pin. This restarts
the ESP8266, and the firmware is executed. Back in the cloud
The basic IoT button implementation is ready now. The actions
For the IoT button, this means it is no longer necessary to to be taken when the microcontroller message is received can
connect the pushbutton to a GPIO pin. Instead it is connected be configured in a few further steps, because there are also
between the RST pin and ground, as shown in Figure 8. various cloud services available for these scenarios – such as
Consequently, there is no need to check for a button press in Microsoft Azure IoT [8][9][10] or ThingSpeak [11]. The proce-
Web Links
[1] ESP8266 NodeMCU user manual: www.handsontec.com/pdf_learn/esp8266-V10.pdf
[2] CH340 driver: https://sparks.gogo.co.nz/ch340.html
[3] Arduino IDE: http://www.arduino.cc/en/main/software
[4] Board manager URL: http://arduino.esp8266.com/stable/package_esp8266com_index.json
[5] Beeceptor: https://beeceptor.com/
[6] IoT button console: https://beeceptor.com/console/iotbutton
[7] ESP8266 current consumption: https://arduino-hannover.de/2018/07/25/die-tuecken-der-esp32-stromversorgung/
[8] Microsoft IoT cloud: https://azure.microsoft.com/en-en/services/iot-hub/
[9] ESP8266 in the Azure cloud:
https://sandervandevelde.wordpress.com/2019/05/07/connection-a-cheap-esp8266-to-azure-iot-central/
[10] NodeMCU in the Azure cloud:
https://www.thingforward.io/techblog/2018-05-22-connecting-nodemcu-to-microsoft-azure-iot-hub-part-1.html
[11] ThingSpeak: https://thingspeak.com/
dure essentially consists of configuring an endpoint directly in the IoT project ready for production, or even turn it into a
the cloud service and then contacting it with the IoT device via commercial application. This mainly involves minor mechan-
the Internet. Then the desired actions can be initiated through ical peripherals (enclosure) and the power supply (perma-
the service (Figure 9). nent battery connection). Extensions are also conceivable. For
You can set up a free account for the ThingSpeak service, which example, replacing the pushbutton by a motion detector would
only requires verification of an email address, and then create allow the device to generate an alarm and communicate it
a new REST endpoint (channel). via the Internet when an unauthorised person approaches a
Fill in the detailed form, which is explained to the right secured property. The actual work is done online through the
(Figure 10), or first give your newly created endpoint a name. configuration in the cloud.
Each channel is given a unique URL and the ability to not only (190303-B-04)
receive requests but also send additional data by means of URL
parameters. Although no additional parameters are needed for
a simple IoT button, the channel read and write keys (as well
as example application for how to include the keys in the GET
requests) can be found under My Channels/API Keys. Once a
channel is correctly configured, you can use the menu item Apps
to define which actions should be triggered (Figure 11) — for
example, sending an email via a web service or posting a tweet
on Twitter. Here the IoT backend acts a sort of intermediary.
Updates of and additions to projects published in ElektorLabs Magazine spiced up with tips & tricks, tech
advice, and answers to reader's questions.
It’s me again with a reader tip from the field. The article
states that the RTC BoB is too tall to simply replace the
DS1302 (IC2) of the clock. It then goes on to mention
three possible ways to modify the clock to make the BoB
fit. I have found a fourth possibility which I personally
consider to be the best because it does not require any
changes to the clock at all as it fits in place of the exist-
ing IC. The trick is not to use the pinheaders shown, but
to use cut off component wires, plenty of which should
be around in the electronics enthusiast’s work area.
Once the BoB is equipped with its three components,
place it — component-side facing down — on top of
an 8-pin IC socket. Then stick eight wires from above
through the board’s holes into the contacts of the socket,
as shown in the photo. Using a pair of small, flat pliers
is better for your fingers and makes it easier to ensure
that all pins go down all the way into the contacts. Cut
the wires flush with the little PBC and solder them. Carefully lever the BoB out of the helper socket and insert it into the socket
for IC2 on the clock PCB. As you can also see on the photo, the RTC is now even lower than the original IC.
Hans Schneider (Germany)
Epilogue: Many thanks for your reply. Your answer incited me to take a closer look at the USB ports on my PC. It has both
USB 2.0 and USB 3.0 interfaces. I have found that I can/may not use USB 3.0 under Windows 7 for the newer ESP32-PICO-
Kit 4.1 modules. Maybe this discovery is also interesting for other users. Why programming the module the first time on a
USB 3.0 port worked, remains a mystery.
S. Kepper (Germany)
190379-C-01
The BASIC development environment for the rather complicated programming A simple project
Annex WiFi RDS [2] described in Elektor of modern SoCs. To realize a digital clock with the ESP8266
March & April 2020 [1] is now available You can choose between different that displays the weather forecast at the
as a practical entry project. The ESP8266 programming languages, various IDEs, same time is a matter of a few BASIC
modules, available in various designs for libraries, drivers, resources and compil- lines, as example projects on the Annex
little money, open up endless possibili- ers. Or should you sneak past them and website [3] prove. I came up with a
ties for the electronics engineer projects take some unfamiliar code that is difficult simple idea with special elegance: the
of many levels, not only thanks to their to understand and somehow transfer it combination of a digital and an analogue
WLAN capability, but also because they to the module? It gets really complicated display. In the project “ESP8266 Sand
can be easily connected “wirelessly” to if you want to control your project via Clock”, a small one-minute hourglass
smartphones, tablets and PCs. Since web interface with a smartphone. The located next to a conventional four-digit
there are also various sensors and development environment called Annex digital clock, is to be turned over
actuators that can be easily connected WiFi RDS makes such a project much precisely in time.
to the microcontroller for little money, simpler by using the BASIC program- But that’s not all: the trickling sand could
do-it-yourself construction could actually ming language. This in turn leads to quick be illuminated. Four NeoPixel LEDs are
be a real pleasure again — if it weren’t achievements. used as background lighting. Of course,
USB
LED3 Dio
ESP8266
R1
GND
D4 D3 D2 D1 VCC
5V
sometimes it’s just a heroic approach 47k DS18B20
LED4 GND
- +
forever scheduled to mañana ;-). TM1637
+5V
But because the ’real thing’ is much
easier thanks to BASIC, the finished C1
hourglass shown in Figure 1 doesn’t 22µ C2
need as much software work as one 10V 22µ/10V GND
might think.
190400-022-94
Browsing the extensive, practice-oriented
help file for Annex WiFi RDS, includ-
ing the contents of the corresponding Figure 2: The electronic hourglass circuit is really this simple: in addition to the ESP8266 module,
website, gave me some ideas for new four resistors, two capacitors, four LEDs, a temperature sensor, a display and a servo are required.
projects. Despite its power, BASIC is easy A parts list is not necessary.
to master even for casual programmers.
Thanks to the Annex Rapid Development
Suite, software development is consider-
ably simplified compared to other current
solutions.
The electronics
The D1-Mini controller board used
offers an ESP8266 module and, thanks
to its pins, is suitable for experiments
on a breadboard, as all relevant SoC
connections are brought out. Via its
USB interface and auto-flash capability,
the module is easily and quickly loaded
with firmware using the Annex Toolkit
[4] without hardware intervention. Don’t
forget to set the correct time zone on the
CONFIG page and enter the BASIC script
in the autostart line there (the path of Figure 3: The test setup of the hourglass on a breadboard according to the circuit of Figure 2.
my active script is always “/program/
default.bas”).
For my tests I built the circuit from
Figure 2 on a breadboard. The result Therefore almost all external pull-up BASIC software
can be admired in Figure 3. resistors are connected to +3V3. The After one-time installation of the
If the supply voltage is connected via internal voltage divider of the analogue firmware on the ESP8266 using the
the micro USB socket, +5 V and +3.3 V input ensures that voltages from 0 to Annex Toolkit [4] and following the
are also brought out and both voltages 3.3 V can be processed and that even instructions in [5], you only need a web
are additionally loadable (within limits), 5-V swings do not cause problems. The browser to access the module’s web
thanks to a Schottky diode and a 3.3 V voltage divider with the LDR should be server. New code can be quickly written
voltage regulator inserted. The currents dimensioned in such a way that with full in the editor or inserted into default.bas
required for the peripherals used here lighting, no more than 500 mV appears at by using copy & paste.
do not push this to the limit. If you want the input. If the analogue input remains In the Annex help file (F2 key in the
to be absolutely sure, you can power unconnected, 0 V is applied here and editor) you will find explanations, pin
the servo separately from +5 V. The two the display is consequently set to full assignments and script snippets for the
electrolytic capacitors between +5 V and brightness. TM1637 LED display, the analogue servo,
ground absorb the current peaks of the Caution when connecting the tempera- the NeoPixel LEDs and various commer-
servo. ture sensor DS18B20! The unit with cially available actuators and sensors as
Please note that the inputs of an ESP8266 module board has a different pin configu- well as for the different ESP modules.
can handle a 3.3 V level maximum. ration than the sensor in the TO housing. The online help also contains a helpful
tion via pushbutton. In automatic mode, LED display segments are visible and the Other frames with plexiglass fronts (e.g.
the RGB controllers and display fields LDR light sensor can also absorb suffi- from the range of a large take-away
follow the continuously calculated values cient ambient light. The servo axis for furniture store) could also be used as
of the animation live. the hourglass was guided through a small an alternative. The transparent front
The website is only intended to demon- hole in the screen. With appropriately cut can then be backed on the inside with
strate here by way of example how sections of foam rubber plates or black a transparent paper or a suitable photo
the Annex firmware in the background paper the light transmission of the front print.
handles the bidirectional communica- material is limited to the necessary zones 190400-B-04
tion with the web browser. The Annex- on the display, behind the hourglass and
supported use of CSS (Javascript, AJAX on the LDR.
and web sockets are also supported)
means that there are virtually no
limits to experiments in communica-
tion with (almost) any web browser.
There are also many examples of this
4 sale @ www.elektor.com
on the Annex website — especially in ªWeMos D1 mini Pro
the files that can be copied from the www.elektor.com/wemos-d1-mini-pro-esp8266-based-wifi-module
Annex Toolkit to the /program direc- ªBook: IoT Home Hacks with ESP8266
tory on the ESP module during firmware www.elektor.com/iot-home-hacks-with-esp8266
installation. It’s worth browsing! An ªPDF file: ESP32 & ESP8266 Compilation
interesting script can be inserted, saved www.elektor.com/esp32-esp8266-kompilation-en
and started quickly in default.bas in
the Annex Editor window with a text
editor (e.g. GEANY.exe) for testing via
“crtl+a” (select all) as well as copy &
Web Links
paste! Complete sections of the script
can be quickly converted into comment [1] BASIC for the ESP32 and ESP8266 (1):
lines from the menu and vice versa. www.elektormagazine.com/190400-03
[2] Annex WiFi RDS: https://sites.google.com/site/annexwifi/home
Moving to the final housing
[3] Example projects: https://sites.google.com/site/annexwifi/projects
The tested circuit was finally installed
without any circuit board or breadboard [4] Toolkit: https://sites.google.com/site/annexwifi/downloads
in a small wooden frame, covered with [5] Manual: https://sites.google.com/site/annexwifi/home/first-steps
a translucent canvas on the front side [6] Article web page: www.elektormagazine.com/190400-B-04
Figure 5). Thus only the active, luminous
Board iterations
are expensive Beware of
Chances are high that the first version of your PCB will
need a few tweaks. To allow you to keep track of different mirrored footprints!
board iterations, mark and label them clearly. Do not The mirrored-footprint error is so common that it merits
forget to update the version number on the board every having its own paragraph header. Explaining it is not
time you change it. It’s also recommended to write down necessary, you know what I mean; just stop making this
the changes and their causes. Volume quantities tend to mistake. End of paragraph.
increase as confidence in the product grows. This makes the
product cheaper, but it makes modifications more perilous.
Discarding ten prototypes is probably less expensive than
replacing one resistor with a wrong value on 1,000 boards
pulled from a production run. No longer remembering
exactly why that resistor value was changed doesn’t make
things any easier.
What’s next?
Our product is almost ready, or is it? We now have a few
prototypes to test and to play with. Testing, you said? Yup.
Testing for functionality, for certification, for quality — there
Web Link is a lot of testing to do. So how do you do that? And what
are the implications? Will this article series never end?
[1] PCB Design is Not Easy:
190369-C-01
www.elektormagazine.com/160397
At the risk of repeating myself, temperature may well be the T = N15 + 40 [°F]
world’s most surveyed physical quantity. Several methods exist
to measure temperature. In electronics the most common ways Here N15 is the number of chirps in 15 seconds. Converted (and
to do it are: rounded) to Celsius gives:
• thermistor: a device whose resistance increases (positive
temperature coefficient or PTC) or decreases (NTC) with T = N8 + 5 [°C]
temperature;
• Resistance Temperature Detector (RTD): exploits the Here N8 is the number of chirps in 8 seconds. The cricket ther-
precisely known relationship between temperature and mometer is fairly accurate between 5 and 30°C.
resistance of a material, typically a metal like platinum;
• thermocouple: a junction of two different metals that Cricket Emulator
produces a temperature-dependent voltage as a result of Just for fun, using an Arduino Uno, a passive buzzer and a
the thermoelectric (Seebeck) effect; DS18B20 one-wire temperature sensor, I inverted the process
• semiconductor-based sensors: the voltage across a to emulate a cricket based on the ambient temperature. Now this
diode or PN junction decreases by approximately 1 to 2 mV looks like a silly project and, to be honest, that’s how it started.
per degree Celsius; However, once I had it up and running, I quickly noticed how
• infrared thermometer: infers temperature from thermal sensitive the human ear is to rate changes. In the end I think
radiation. this emulator could make for a useful temperature indicator in
applications where it is not practical to keep an eye on a display.
The last technique is often used to measure human body tem-
perature by pointing a ‘temperature gun’ at the insides of an ear. Full project details can be found at: www.elektor-labs.com/3945
Up to this point nothing new, you say, discreetly suppressing a
yawn, but did you know that you can use the ear itself to deter-
mine the temperature?
As it turns out, the chirping sound produced by a cricket is tem-
perature dependent. Similar to estimating the distance of a thun-
derstorm by counting the seconds between a lightning flash and
the thunder that follows it, the temperature of the air can be esti-
mated by counting the number of chirps produced by a cricket in
one minute. This correlation was reported in 1881 by Margarette
W. Brooks, but the credit went to Amos Dolbear after he published
an article entitled “The Cricket as a Thermometer” in 1897. The
green tree cricket officially known as Oecanthus fultoni has been
known as the thermometer cricket ever since.
Calculating the temperature T from the cricket chirp rate is easy, Not all temperature sensors are created equal. This 24-hour log shows the outputs
especially in Fahrenheit: from a DHT-22 and a DS18B20 sensor placed next to each other.
BalBot
a Self-Balancing Robot
Modern acceleration sensors ease
the construction process
Balancing algorithms
As already mentioned, a suitable control loop is required. The
position of the robot corresponds to the actual size. It should Figure 3: Tilt angle curve in the serial plotter integrated in the Arduino IDE.
deviate as little as possible from the vertical (target size). A PID
controller is ideal for this. Our robot named BalBot achieves an
astoundingly stable dynamic balance with optimally adjusted
Kp, Ki and Kd parameters. The target value or the vertical is 6. In the main loop, only the MPU signal is read out,
first fixed in the software. Figure 2 illustrates how this works and the control signal for the motors is computed
in practice. u s i n g t h e P I D c o n t r o l l e r p i d .C o m p u t e ( ) a n d
The MPU6050 module permanently records the current position forwarded to the motor driver with the following call:
of the robot. Its values are processed by the PID algorithm
in Arduino. The control sketch carries out the calculations for motorController.move(PIDout, MIN_ABS_SPEED);
controlling the motors. If the robot is in danger of tipping over
in one direction, the resulting tilting moment is compensated In addition a check is carried out to determine whether the
by a corresponding compensation movement of the wheels. FIFO buffer of the MPU6050 is overflowing. This should not
The robot remains vertical even if it is pushed slightly. The happen during normal operation. If necessary, the buffer
corresponding sketch BalBot.ino is also included in the free size can be adapted.
download archive. The line:
Its code is divided into six parts: Serial.println(ypr[1] * 180/M_PI); // actual tilt
1. Initially the libraries are loaded. If not included in the outputs the tilt angle. In the Arduino IDE serial plotter it
Arduino IDE by default, they can be got via Internet [2] can be tracked continuously. If regular, sinusoidal value
[3]. Then the motor connections are specified. The motors curves appear, that is a clear indication for the oscillation
can be operated both forward and reverse by means of EN of the control. In this case the control parameters need
(enable) and IN (input). The motor power is controlled by to be adjusted. In most cases it is helpful to reduce the
PWM. Kp value. Ideally, the line should only show small, irreg-
2. The values required for operating the MPU6050 are subse- ular signal deflections, such as those caused by random
quently defined. These are essentially the standard settings. disturbances (air movements or uneven floors). Figure 3
Details can be found in the IC datasheet [4]. shows the random compensating movements around the
3. Now the PID parameters are specified. They are of central rest position.
importance. The following three values define the control
behaviour: Kp (range 0-1000; default value 400), Kd (range Parameter optimization and adjustment
0-100; default value 30) and Ki ( range 0-500; default The optimization of the PID values could also be done by means
value 200). of a simulation for example with MATLAB. In the professional
4. These values must be adapted to the real conditions of the field, this procedure is standard for complex controllers.
respective hardware. Differences in mechanical construc- But with BalBot, the classic ’trial and error’ approach can also
tion (due to differences in motors, wheel sizes, etc.) can be used. Here, the individual parameters are gradually adjusted
be compensated here. Notes on the adjustment of these until the best possible control is achieved:
parameters can be found in the next section.
5. The required interfaces are now activated in the setup. The 1. First, the three parameters Kp, Ki and Kd are set to zero.
serial interface is only used to output debug information. 2. Next, Kp is slowly increased step by step. If Kp is too low,
This code can be omitted in the ’final release’. The MPU6050 the robot will tip over because the corrections are not fast
module is then started and checked for function - an error or large enough. If Kp is too high, the robot will perform
message is output if necessary. The specified offset values violent back and forth movements without reaching equilib-
can usually be accepted without modification, since the rium. Kp must be adjusted so that the robot moves back
gyroscope automatically calibrates itself. and forth only slightly.
Web Links
[1] Article support page: www.elektormagazine.com/200074-02
[2] PID_v1.h: https://github.com/br3ttb/Arduino-PID-Library/blob/master/PID_v1.h
[3] MPU6050_6Axis_MotionApps20.h: https://bit.ly/37T7T1c
[4] MPU6050 datasheet: www.invensense.com/products/motion-tracking/6-axis/mpu-6050/
[5] ‘Arduino Bluetooth‘ app: https://play.google.com/store/apps/details?id=com.circuitmagic.arduinobluetooth&hl=en
In the previous episode we got acquainted with Ohm’s Law and did some elementary calculations. Now it
gets a bit more complicated — but no fear: we don’t need higher mathematics...
First a small update to the previous reasoning is rickety but it does make Parallel connection of resistors
episode. There, we mentioned that a some sense of what is happening. Resistors are not only connected in series
decimal prefix is often written instead Now let’s see exactly what happens. (’sequentially’) but also in parallel (’side
of the decimal point: 8.2 kΩ becomes Thanks to Ohm’s Law, we know that the by side’), as outlined in Figure 2. First
8kΩ2 and 5.6 nF becomes 5nF6. There voltage U across the series connection eliminate R2 for a moment; then we
we noted casually that the µ (’micro’ or of R1 and R2 (which we call R) equals know that a certain current will flow
10-6) is at least tricky to find on our US/ through R1. Now we add R2; a certain
UK keyboards. In fact the key combi- U=RI current will flow through it as well.
nation is ALT+0181, but that is clumsy. Therefore, when connected in parallel,
That’s why instead of the µ, a ’u’ is often Now resistors are not mysterious compo- the total current increases; and since the
written and then we get: 4.7 µF = 4.7 uF nents — no power is lost in them. So the voltage across the resistors remains the
= 4uF7 or even 4u7. current I in the series circuit is equal same, that means the total resistance
to the current leaving the series circuit, has become smaller!
Series connection of resistors and so both resistors pass the same Looking at Figure 2 again, two things
Over to business as usual. What happens current. Each of the resistors drops a are clear: both resistors R1 and R2
when we connect two resistors in series, certain voltage (which in turn follows have the same voltage U across them.
as outlined in Figure 1? If we consider a from Ohm’s Law), and because resis- Consequently, the sum of the currents
resistor as a component that impedes the tors are purely passive components, no through the individual resistors is equal
current flow, we could reason as follows: voltage is added along the way (and no to the total current I: we are dealing with
the current is obstructed by R1, and the voltage disappears either), so the sum purely passive components, so no current
small amount of current that manages of the two partial voltages U1 and U2 is disappears or gets added along the way.
to pass that resistor is obstructed again equal to the total voltage U. Armed with If we call the total resistance of the paral-
by R2. So it is obvious that the total that knowledge, we can write: lel circuit R again, we get:
resistance increases when connecting
resistors in series. Yes we know, this U1 = R1 I U=RI
U2 = R2 I
And since U1 + U2 = U:
U = (R1 I) + (R2 I) = (R1 + R2) I
And it follows that the total resistance R
equals the sum of resistors R1 and R2.
Okay so you had guessed that and it’s
obvious too, but of course it’s nice to
know for sure.
We leave it up to the reader to check the
above by means of a numerical example
(e.g. take a battery voltage of 15 V,
Figure 1: Series connection of two resistors. R1 = 10 Ω and R2 = 20 Ω). Figure 2: Parallel connection of two resistors.
Small circuits not using SMD components or special tools, that can be built on stripboard and invite
experimentation and improvisation – these are frequently a springboard to a career in electronics. Here we
again present a selection from the Suggestion Box of your favourite magazine.
Idea: Michael A. Shustov (Russia) and Andrey M. Shustov (Germany) be restored; after a short time C1 is charged again via D1 and
Energy-efficient Light-sensitive Relay the circuit is armed once more.
In the first episode of this series (Elektor January & February Transistor T3 does actually the same thing as the pushbut-
2020) we described a few variations on the subject of tons: in the dark this light-sensitive transistor is off and the
‘energy-efficient relay’ from the father & son team Shustov. circuit is in the rest state. When light strikes the transistor (for
These are actually also variations of the well-known stairwell example from a torch) it will switch on and pull the base of T1
switch circuit. The Shustovs haven’t been sitting idle: Figure 1 to ground — and then the circuit behaves in exactly the same
shows a version that has been expanded with a light-sensitive way as after pressing one of the buttons.
transistor, so that the lamp is not only turned on by pressing This method makes the circuit appropriate for application in
one of the buttons SB1 through SBn, but can also be turned a cellar, for example, where it is normally dark (!) — you do
on from a distance using, for example, a torch. not have to search around for the light switch and only have
If we forget about T3 for the moment, then the circuit operates to strike a match or something...
exactly as described in the first episode. In the rest state the
series-connected pushbuttons SB1 through SBn are all closed
(for the sake of simplicity only one is drawn). A small current
can flow through the lamp via R1 and LED1 to ground — the
LED will light up to indicate that the circuit is ‘armed’. At the
same time, capacitor C1 is charged via D1. By the way, the
current through the lamp is not high enough for it to light up.
(And it will be clear that this has to be an incandescent lamp).
As soon as a button is pushed there is no longer any current
through the lamp and the base of transistor T1 is pulled to
ground (via R3, R2, R1 and LED1). The transistor will start to
conduct and C1 will discharge via R4. As a consequence, the
voltage across R4 becomes high enough for T2 to turn on so
that enough current will flow through the lamp for it to light
up (of course once the pushbutton is released).
This state is stable for as long as the voltage across R4 is high
enough for T2 to continue conducting. Once capacitor C1 has
discharged sufficiently so that T2 turns off, the initial state will
1
LA1
D1 1N4004
SB1-SBn
R1
T1 Idea: Joseph Kreutz (France)
R2 R3 BC557
Preamplifier for Crystal Pickup Elements
2k
10k 300k
LED1 T2 You will know them — the so-called ‘stereo consoles’ from
2N7075
the seventies of the previous century? These large wooden
GB1 T3
12V L-53P3C R4 monsters with on one side a radio attached to an amplifier
50k C1
1000µ (no transistors, only tubes) with bulky mechanical selector
16V
pushbuttons and large volume and tuning knobs on either side
of a beautiful ‘multi-band’ tuning scale. And on the other side
200110-51 KD
a gramophone for 33, 45, and 78 rpm records?
That gramophone… Belt drive was a rarity, direct drive still
390k
100n 10µ
then turn it on again.
The circuit is built around a ‘good old’ 555 — one of the oldest
R2
C1
1M8
2µ2 workhorses in electronics and still a favourite component when
C2 U1
some timing is involved.
3 7 TL071
6
C7 Audio out It is not difficult to understand the operation of the circuit:
100n
Crystal
2
5 10µ
the regular trigger pulses from the microcontroller (note: the
1
microphone 4 R5
C4
software that is running on that controller has to generate
1M
10p
these, but that will not be a problem for any slightly accom-
plished programmer) will turn on transistor T2 each time, which
R3 R4 R6 results in the discharge of timing capacitor C4 of the 555. The
2M2
47k
22k
555 is configured as an astable multivibrator.
C3
100n As a result the voltage across the capacitor cannot normally
reach the trigger threshold necessary to activate the 555. The
200110-52 KD
3 V+
had to be invented. The drive used a rubber wheel between
the motor shaft and the inner rim of the turntable. And of R3 4 8 R4
270k
47k
C2
RESET V+
100n
course this gramophone was equipped with a crystal element 7
DIS
T1
RFR9024
(sometimes called a ceramic element). IC1
R2 NE555
820k
Such an element generated a relatively high output voltage, OUT 3
T3 OUT
6
but had to be loaded with a high impedance. The latter was 2
THR BS170
Trigger
not a problem for the valve equipment of the time, of course. T2
Bs170 CV GND GND
Trigger
However, it is a problem now, because the ‘phono’ input of a 5 1
D1
modern amplifier (assuming that it still has one, in this CD era) C1
100n
1N4148
C4 C3
R5 R1
27k
10k
10µ 10n
has a normalized input impedance of 47 kΩ and that is much
too low with all its consequences; furthermore, all modern
200110-53 KD
phono amplifiers are designed for signal levels in the order of
millivolts. This is guaranteed not to work well.
If, in spite of all this, you would like to experiment with old
‘crystal gramophones’, we need a preamplifier/impedance output (pin 3) of the 555 remains high and the power supply
converter. Fortunately such a thing is easily realised, as voltage to the microcontroller is turned on via T3 and T1.
Figure 2 demonstrates. The heart of the circuit is a high-im- However, when the trigger pulses remain absent for more than
pedance FET opamp type LT071. With resistors R1 through 10 seconds, the voltage across C4 will be high enough for the
R3 the input impedance is matched as good as possible to the 555 to toggle: the output becomes low and T1 will turn off via
microphone or element. The opamp is used to build a standard, T3 and the power to the microcontroller is cut off. After about
non-inverting amplifier with a bandwidth that is limited by 5 seconds the 555 will switch back and the power supply is
capacitors C3 and C4 from about 33 Hz to a little less than switched back on.
16 kHz. The gain is about 21 times and is suitable for connect- 200110-02
ing to a CD input of a modern amplifier.
There is not much more to say about this simple circuit, except
that it is not only suitable for crystal pick-up elements, but
also for the crystal microphones that were often supplied with
the tape recorders of that era (and is already indicated in the
schematic).
Idea: Wolfgang Borst (Germany)
External Watchdog for Microcontroller Systems
A microcontroller that runs 24 hours per day, 7 days per week,
can latch up for whatever reason (note: can, it fortunately
only happens rarely). In these cases, the normal reset signal
generated by the internal watchdog may not be sufficient to
4 sale @ www.elektor.com
escape from this situation. On these rare occasions only one ªElectronic Circuits For All
thing will do: turn off the power supply voltage completely and www.elektor.com/electronic-circuits-for-all
then turn it back on.
Quick Specifications
• Open source design
without hidden tricks
• Capacitive box-opened detection
• Incident light
box-opened detection This project is a (logical) sequel to my ing a tamper-proof device, but then
• Travel time verification TRNG [1] and OTP Crypto Shield [2] and learned that securely erasing data from
• Temperature attack detection tries to solve the problem of securely a flash-memory-based device like a solid-
• Infrared communication exchanging one-time pad (OTP) keys state drive (SSD) or SD card is practi-
• Reusable stored on, for instance, an SD card. cally impossible [3]. Furthermore, even
I started out with the idea of design- SRAM memory exhibits some parasitic
VCC VCC
R2
C1 100k
100n
L1
10µH 7 P3 P2
D1 1k 25k R3
20 VCC 23 E A E A L2
AVCC PC0(ADC0) 1k
1N4148 S S 220µH
C6 R13
100n C10 C1X 30x30mm
1M
10n plane
D4 R30
16 C14 C15 R4
1k5 PB2(SS/OC1B) P1 P4
D2
10k
E 1k A E 25k A
1N4148 T4 T3 C18 24
PC1(ADC1) 120p 10n
VREF1 R21 10n
IC1 R14 1N4148 S S
10M
R11 C11
ATmega328P
1M
4 26
R12 PC5(ADC5/SCL) PC3(ADC3) 10k
C17
C7 3 C8
10k
25 D3 1N4148
1n PC2(ADC2) 10µ
2 R5 PB0-CLKO/2C 100n 10V
14
1M PB0(ICP) tantal
R23 R20 27
R6 PC4(ADC4/SDA) 22k
R29 VCC
* not LM385 R15 R10
10k
100k
10k
10k
10k
10n
21 9 BAT1
AREF TXD-IR
R25 4 VBAT-MEASURE/2.3B 8
PD2(INT0)
10k 5 7
PD3(INT1) PD3 CR2032
9 6 6
PB6(XTAL1/TOSC1) PD4(XCK/T0) PD4 HOLDER
Vbat X1 32.768kHz 18 5
VCC Vbat PB4(MISO)
R24 10 4
12 MISO
T1 1M PB7(XTAL2/TOSC2) PD6(AIN0)
13 3
BC857C 6 PD7(AIN1) SCK
3 C3 C4 R9 R19 R18 2
1 2 5 MOSI
330
100
R22
100
S3 22p 22p
4 15 1
33k PB1(OC1A)
IC2 1 R7 K2
start R28 PD5(T1) 11 LED2 LED1
3 4 2M2 DM3AT-SF-PEJM5
MAX9915
100k
EXT+T 2 8
VCC T2 7 DAT1
BC857C 6 DAT0
R27 10
VSS DET-A
220k LED3 VCC 5
2 IrDa link
PD0(RXD) CLK
100k
PC6(/RESET) R8
10µ K1 CD/DAT3
S2 1
22k
Figure 1. The tamper-evident box uses phototransistors and open-plate capacitors for detecting tampering.
680
C3 1µ
100n 1µ
coarse adjustments and P1 and P3 for 5
C2-
RS232
K1
fine tuning. D1
1N4148
2 1 11
T1IN T1OUT
14 1
TXD
4 3 12 7 2
4k7 R1OUT T2OUT GND
6 5 10 13 3
R4 IC2 R7
R2 T2IN R1IN RXD
Temperature measurements ATtiny 8
100k
ISP 9
R2OUT GND R2IN K2
1k5
45-20SU 8 +3V3
The MCU has a built-in temperature R3 (RESET)PB5
1 15
4k7
abnormal temperatures and to log the LED1 TSAL6200
3
D2 2
VCC VCC
1
IrDa link MBR120 4 3
(XTAL2)PB4 S1
approximate minimum and maximum 9600 bps
1-LED (Tx & Rx) 2 (XTAL1)PB3 RESET K5 6
RESET
FAC_RST
RXD
RTS
5
6
8 7
temperatures during the box’s journey. R6 R5 GND 5 HW_TRIG TXD
5V FTDI cable
10 9
1 3 4 NC CTS
680
component list
At Bob’s place
After a long and perilous journey,
the box (hopefully) arrives at Bob’s
place. He connects his IR adapter to
a computer, places it in front of the Figure 6. The fully assembled board with open-plate capacitors installed on both sides.
box’s IR LED, and presses the Reset
button on the adapter. This will produce
a three-second pulse on the infrared port
to tell the box to activate its infrared
port and start communicating on it. After
three seconds Bob proceeds by sending
a single character ‘U’ to calibrate the IR
adapter’s UART, and the terminal starts
displaying data:
As we can see, the battery voltage has
decreased, but there are no visible signs
Figure 7. The bottom side of the board/ PCB is populated with SMD components and through-hole
of tampering as the Cx voltage ratios
transistor T4 that looks like an LED. Capacitor C1x is mounted over the microSD card connector.
and the phototransistor voltage values
have not changed much. Bob calls Alice
and asks her for the challenge string. He
enters it in his terminal, and, if every- Status-4 Box zeroized. Status-5. Tampering,
thing is fine, he will see: Bob immediately writes down the current wrong password, or low battery!
time and date and calls Alice again to Capacitor Cx1 voltage ratio: 0.712
Box unlocked. Status-4. Challenge verify the response string. If Alice Capacitor Cx2 voltage ratio: 0.713
string correct!! accepts it, she will now give Bob the Phototransistor voltage [V]: 0.179
Capacitor Cx1 voltage exact time and date that she wrote down Box temperature [degC]: +12
ratio: 0.703 when she locked the box. This allows Bob
Battery voltage [V]: 2.793
to calculate the theoretical travel time
Capacitor Cx2 voltage ratio: 0.711
and compare it to the time measured Status-5
Phototransistor voltage [V]: 0.178
by the box. If the two match, then Bob The zeroization sequence was executed
Box temperature [degC]: +24
is allowed to use the OTP key stored on due to the detection of a tamper event
Battery voltage [V]: 2.752 the microSD card to encrypt and decrypt or after entering five invalid challenge
Min temperature [degC]: -2 his secure communications with Alice. In strings. The tamper-check voltages are
Max temperature [degC]: +31 case of being tampered with along the no longer updated, allowing the holder
Travel time [s]: 502,164 way, the box will erase the part of the of the box to see the last recorded state
Response: SRAM containing the codes and the travel before tampering was detected.
Trust no one 01a2g23w46e57f80g12r3 timer. In this case the box will output The zeroization sequence is executed in
e34fv245hasdvfr4. something like this: one of the following cases:
component list
Web Links
[1] Random Number Generator: www.elektormagazine.com/labs/random-number-generator-150116
[2] One-Time Pad (OTP) Crypto System: www.elektormagazine.com/labs/one-time-pad-otp-crypto-system
[3] Erasing data from flash drives: www.schneier.com/blog/archives/2011/03/erasing_data_fr.html
[4] Data Remanence in Semiconductor Devices: www.usenix.org/legacy/events/sec01/full_papers/gutmann/gutmann.pdf
[5] Elektor video interview on security: www.elektormagazine.com/news/secure-communications-an-interview-with-luka-matic
[6] A small and simple Z80 computer: www.sunrise-ev.com/z80.htm
[7] Tamper-evident paper-mail box for secure distribution of one-time pads:
www.elektormagazine.com/labs/tamper-evident-paper-mail-box-for-secure-distribution-of-one-time-pads
Back in May 2016 Elektor Labs magazine minor adaptations. However, if you are
project decoder published the New Precise Nixie Clock satisfied with adding date display and
[1] and since then many readers either preventing/limiting tube cathode poison-
Nixie
purchased the complete kit or just the ing (more about that later), then replac-
PIC bare PCBs, and bought their own compo- ing or reprogramming the microcontroller
clock update nents to build the project. In fact, judging will suffice.
from the number of views as well as
entry level
tech-interested followers on the Elektor The most eye-catching enhancement
Æ intermediate level Labs website [2] it’s one of the most Andy made is the multi-colour backlight-
expert level popular designs of the past years. ing for the Nixie tubes to replace the
In the wake of the May 2016 publication, six blue LEDs from the semi-kit. Besides
1 hour approx. (upgrade/mods we received requests and suggestions to being decorative, the new backlighting
only);
enhance and extend the clock, especially also indicates what information is being
3 hours (semi-kit assembly) the software. That job was finally seen shown on the clock display. Andy used
to by one of the staunchest followers a strip of perfboard and through-hole
lab tools, on Labs, Andy Leitch. Andy completely WS2812 RGB LEDs for this, but in order
PIC programmer rewrote the software originally produced to make it completely tidy and easy to
in assembler, to ‘C’ and adapted the assemble, Labs designed a circuit board
hardware enabling the clock to also with the same LEDs in SMA housings.
€10 approx. (upgrade/mods only); display the date and act as an alarm This PCB is available from the Elektor
€140 approx. (semi-kit excl. case) clock, among other things. To fully exploit Store in the same black colour as the
the functionality of the new firmware now other PCBs from this project. More about
available [3], the circuit boards require it below.
27k
27k
27k
27k
27k
27k
470k
470k
hours-10 hours-1 mins-10 mins-1 secs-10 secs-1
V1 V2 V3 V4 V5 V6
1 Nixie IN12 1 Nixie IN12 1 Nixie IN12 1 Nixie IN12 1 Nixie IN12 1 Nixie IN12
LA1 LA2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
2 11 10 9 8 7 6 5 4 3 12 2 11 10 9 8 7 6 5 4 3 12 2 11 10 9 8 7 6 5 4 3 12 2 11 10 9 8 7 6 5 4 3 12 2 11 10 9 8 7 6 5 4 3 12 2 11 10 9 8 7 6 5 4 3 12
1 2 1 2 1 2 1 2 1 2 1 2
3 4 3 4 3 4 3 4 3 4 3 4
5 6 5 6 5 6 5 6 5 6 5 6
7 8 7 8 7 8 7 8 7 8 7 8
+180V
9 10 9 10 9 10 9 10 9 10 9 10
K4 K6 K8 K10 K12 K14
V1.0 1 2 V1.1 V2.0 1 2 V2.1 V3.0 1 2 V3.1 V4.0 1 2 V4.1 V5.0 1 2 V5.1 V6.0 1 2 V6.1
V1.2 3 4 V2.2 3 4 V2.3 V3.2 3 4 V3.3 V4.2 3 4 V4.3 V5.2 3 4 V5.3 V6.2 3 4 V6.3
LA1 5 6 V1.3 V2.4 5 6 V2.5 V3.4 5 6 V3.5 V4.4 5 6 V4.5 V5.4 5 6 V5.5 V6.4 5 6 V6.5
T8
7 8 MPSA42 V2.6 7 8 V2.7 V3.6 7 8 V3.7 V4.6 7 8 V4.7 V5.6 7 8 V5.7 V6.6 7 8 V6.7
+180V
9 10 V2.8 9 10 V2.9 V3.8 9 10 V3.9 V4.8 9 10 V4.9 V5.8 9 10 V5.9 V6.8 9 10V6.9
K5 K7 K9 K11 K13
K3
3 6 7 4 3 6 7 4 DIM1 3 6 7 4 3 6 7 4 DIM2 3 6 7 4
T3
R7 MPSA42
10k
T2
MPSA42
R23 33 34 35 36 15 16 17 2 3 4 5 27 28 29 19 20 21 22
14
13 OSC2
10k OSC1
RB1
RC1
RA1
RB0
RB2
RC0
RC2
RA0
RA2
RB3
RA3
RD0
RD1
RD2
RD3
RD4
RD5
RD6
39 31 +5V
RB6 VSS
R9 38 12
RB5 IC4 VSS
T4 37 R11
10k RB4
MPSA42 11
10k
VDD
PIC18F45K22
R8 32
10k VDD 1 rst +5V
+5V
RD7
RC5
PGD
RA5
RC3
RC4
RC7
RC6
RE2
RE1
RE0
RA4
D2 CI GND
IC6
C7 1N5814 7 +5V
1 3 IS T5 P1 R15
100n 8 IRF644 R28 R12
K1 DC D3 500k
10k
C10 D4
2
www.elektormagazine.com
SE
1k
BAT46
47k
GND
3 BAT46 MOD1
2 IC7 TC 10µ
T9 250V 1W VCC
C12 C13 C15 MC34063 C18 BC557 C11
10µ 100n 220µ GND
Figure 1: Circuit digram of the the revised New Precise Nixie Clock. This version incorporates all changes to the original design of 2016.
100µ GND 100µ
25V 25V C3 25V R16 C1 R17 S1 NC
4 25V
5k6
1k
+ TXD
470p 100n LED1 - PPS
Bz1
C1 C2 C3 C7 C4 C5 C6
100n 100n 100n 100µ 100n 100n 100n
VDD VDD VDD VDD VDD VDD
+ R1 16V
0 100 DI DO DI DO DI DO DI DO DI DO DI DO
D
VSS VSS VSS VSS VSS VSS
K1
180588-002-94 KD
Figure 5: Circuit diagram of the decorative backlight board implemented with SMD LEDs. Note the decoupling capacitors which are needed to suppress
noise caused by the relatively high current.
component list
(C) Elektor
180588-1 V1.1
K1
LED1 LED2 LED3 LED4 LED5 LED6
D0 +
R1 C7
C1 C2 C3 C4 C5 C6
+
Microcontroller developers often need timers, to perform retransmissions and other error recovery
procedures, for debouncing of button presses, or just for a blinking LED indicator. The ESP32 device and the
Arduino IDE provide software timers using the included FreeRTOS library. In this third part of the series we
focus on the timer facility.
In order to illustrate how FreeRTOS timers work, we’ll work with simply adding the line:
a demo assignment to construct an alert LED class. This is not static AlertLED alert2(13,1000);
your average blinking LED however. When activated, it quickly
blinks five times and then is off for the rest of the period, and Our demonstration will focus on one indicator but the C++
repeats. It will visually appear as an attention getting alert or class packaging makes for convenient use.
as a visual phone ring alert.
The AlertLED class will use one FreeRTOS software timer inter- The AlertLED class
nally for each LED driver. As a class, you will be able to add as The class definition is copied below for convenience. The class
many as you need, without burdening the memory utilization data members include the member thandle (line 11), which is
of the ESP32. Listing 1 illustrates the full program [2]. Line a handle to the FreeRTOS timer (type TimerHandle_t). Initially
100 shows the creation of an alert LED instance with a simple it is assigned the value of nullptr (same as the C language
C++ declaration statement: NULL). The data member named state will track the LED state
static AlertLED alert1(GPIO_LED,1000); (line 12), which is active high (true = on). The data member
count (line 13) will be used in the callback as a substate, which
The class instance name here is alert1, using the specified is explained later. Finally members period_ms and gpio config-
LED (GPIO 12 from line 5), and the flash period of 1000 milli- ure the blink period in milliseconds and the GPIO to drive for
seconds. We could easily add another one for GPIO 13, by the LED (lines 14 and 15).
Method AlertLED::alert()
220
The demonstration
For a simple demo alertled.ino, we can again use the Lolin
ESP32 OLED Display Module. The wiring is shown in Figure 1.
The LED is wired according to the active-high configuration.
Web Links
[1] Practical ESP32 Multitasking, Elektor Magazine 1/2020: www.elektormagazine.com/190182-01
[2] Project source code: https://github.com/ve3wwg/esp32_freertos/blob/master/alertled/alertled.ino
Our short series of articles closes with a look at the development of a custom dashboard to help visualize
measurements sent over the Sigfox network, both graphically and numerically.
In the previous instalments of this series we examined the received by the Sigfox backend, and stored. And from that
basic Sigfox hardware for acquiring and transmitting measured point we can proceed to visualize the data on a dashboard.
data and the concepts underlying data transmission in the
Sigfox network. Our measurements are now sitting in the Sigfox The thinger.io dashboard platform
backend waiting to be picked up and processed further. We will be using thinger.io, an open source IoT visualization
A free web-based dashboard tool is available that lets the platform which enables the rapid and straightforward construc-
user create and operate a custom visualization and monitor- tion of clear and attractive data visualizations. It can even be
ing interface on any PC, laptop, tablet or smartphone. And, if used free of charge for simpler projects.
suitably enabled, this dashboard can be called up and viewed The system at the moment does not support mathematical
by anyone (or just by any authorized user) over the Internet operations on the received data, and that means that the
from anywhere in the world. readings must be delivered to it in a form already processed and
The starting point for the developments described here is the ready to display. However, the required processing can easily
Arduino sketch Sigfox-3_0.ino running on the MKR FOX 1200 be handled by our Arduino software running on the MKR FOX
board. If you select the fourth menu item ‘Send three readings’ 1200 board. The model for visualizing the data values is based
then the three measured quantities (atmospheric pressure, on a dashboard or instrument panel which can be made publicly
air temperature, and light intensity as recorded by the LDR) available to anyone with a web browser.
will be continuously acquired, the results being shown on the
ePaper display on the motherboard and output over the serial Step by step
monitor to the Arduino IDE. When the button is pressed these A few simple steps are required to develop a custom dashboard
readings will be automatically sent over the Sigfox network, as follows.
Figure 3. Main account screen showing statistics. Figure 2. Setting up a new account.
• Create a free user account at thinger.io. address you can go to the login page and log in. The main
• Set up a ‘data bucket’ at thinger.io to accept the readings screen of your account is called ‘Statistics’ and this is the start
sent from the Sigfox backend. point for all further actions (see Figure 3). The main menu is
• Set up an access point and token at thinger.io, and with it on the left-hand side, containing all the functions needed to
configure the Sigfox backend so that the Sigfox backend create a visualization dashboard for your IoT project.
has the necessary credentials to
transfer data to thinger.io.
• Set up a callback on the Sigfox
backend to send data over the
Internet from the backend to the
data bucket at thinger.io.
• Design a suitable graphical
dashboard on the thinger.io site
to visualize the data.
Creating a user account
at thinger.io Figure 4. Setting up a new data bucket.
A (free of charge) user account has
to be set up at thinger.io in order to
use its services. To do that, go to the
thinger.io homepage [1] (Figure 1)
and click on ‘Sign up’ at the top right.
This will take you to the form for
registering a new user (Figure 2).
Fill in the fields of the form and click
on ‘Sign up’.
The services available to users
with free accounts are somewhat
restricted, but nevertheless are more
than enough for most small experi-
mental projects. Full details on what
is available can be found under the
‘Pricing’ tab.
Once you have confirmed your e-mail Figure 5. Specifying the properties of the data bucket.
https://api.thinger.io/v1/users/{user_id}/buckets/
{bucket_id}/data
In the address replace user_id with the user name from your
thinger.io account (from Figure 2) and bucket_id with the
bucket identifier, here ‘elektor’ (from Figure 5), in both cases
without curly brackets or quotation marks.
Under ‘Use http Method’ select ‘POST’. Figure 18. First window for creating a widget.
The next step is to set up authentication for the data transfer
to thinger.io. This is done in the two fields next to ‘Headers’.
In the ‘header’ field enter the word ‘Authorization’ and next to
that, in the ‘value’ field, enter ‘Bearer’, followed by a space and sends a variable with name AtmPressure. The value of this
then the access token that we created as shown in Figure 9. variable corresponds to the value of the backend variable called
pressure, which we previously specified in the ‘Custom payload
Bearer eyJhbGci7j76j67jzI1NiIsIn ... etc. config’ field. The keyword customData# indicates that the value
of a variable unpacked using the ‘Custom payload config’ field
In the field ‘Content type’ enter ‘application/json’, which is to be inserted. This is how the variable names and values
indicates that the body of the message is in JSON format. are reformatted for transmission to thinger.io.
In the final step we specify exactly what will be sent to thinger. The last two lines are processed in the analogous way.
io. The entry (in JSON format) in the ‘Body’ field should be as Each line, apart from the last, must be terminated with a
follows. Again, it is essential that the text appears precisely comma.
as shown.
That completes the configuration of the callback in the Sigfox
{ backend to enable it to send the desired data to the ‘elektor’
"Device-ID" : "{device}", data bucket at thinger.io. When you have completed all the
"AtmPressure" : {customData#pressure}, above steps correctly, you can click on ‘OK’.
Now, when the MKR FOX 1200 sends a payload to the Sigfox
"Temperature" : {customData#temp},
backend, and assuming that no errors are encountered in recep-
"Light-Sensor" : {customData#ldr}
tion, the Sigfox backend callback will immediately forward
}
the data in the format specified above to thinger.io for further
processing.
The ‘Body’ is enclosed in curly brackets (‘{‘, ‘}’). But what
does the text in the body mean? The dashboard at thinger.io
Each line between the curly brackets begins with a double Now we come to the last piece of the puzzle, adding some
quotation mark; after that appears an freely-chosen (but polish to our project. We want to present the data in graphical
unique) variable name, followed by another double quotation form on a dashboard. In order to create a dashboard, go to
mark. There follows a space, a colon and another space. It the main thinger.io console (Figure 3) and on the left click on
is at this point that the value of the variable will be inserted ‘Dashboards’ and in the next screen on the ‘Add Dashboard’
by the Sigfox backend. The variable name and its value will button (see Figure 14).
subsequently be sent in this format to thinger.io, where it will You now need to fill in the fields in the ‘Dashboard details’
be stored in the appropriate data bucket. window (Figure 15). The ‘Dashboard id’ is an identifier unique
So we have across the entire account. The fields ‘Dashboard name’ and
‘Dashboard description’ can be filled in with any information:
"Device-ID" : "{device}", they are intended to be easily user-readable. Confirm the entries
by clicking on ‘Add Dashboard’. The new dashboard will be
which will give the unique device number of the Sigfox station added to the ‘Dashboard list’ which you will see whenever
(i.e., our MKR FOX 1200), which is known to the backend. This you click on the ‘Dashboards’ menu item in the main console
information is sent along with the measured data so that the window (as shown in Figure 16).
originating station can later be identified uniquely. If you click on the name of the dashboard, a design window
The line will appear displaying an empty dashboard (see Figure 17). At
the top right there is a small switch: slide this to green to enter
"AtmPressure" : {customData#pressure}, edit mode. There are also two buttons labelled ‘Add Widget’
not explore them further here. In the ‘Widget’ tab we again is shown in Figure 24. Note that in order to ensure that all
set the ‘Title’ field to ‘Atmospheric pressure’. We can leave the entries and modifications are stored in thinger.io, it is neces-
‘Subtitle’ field empty, as we have already arrange for the unit sary to exit editing mode and then re-enter it. More informa-
to be displayed next to the value. tion on designing dashboards on thinger.io can be found at [7].
That completes the configuration of the dashboard display Now we just need to enable access to the dashboard ‘from
elements for atmospheric pressure. The display for the other outside’. Back in the Dashboard menu click on the blue button
two readings are configured in a similar way: the final result labelled ‘Settings’, which will take you to the dashboard settings
Figure 26. Output from Sigfox-Demo.ino on the serial monitor and on the ePaper display.
page (see Figure 25). Here you can give your dashboard a Sigfox network, which corresponds to about one message every
name and a description (although in this case it is not necessary ten minutes. In view of that it is less critical that a free account
as we have already set this up). The switch labelled ‘Share’ at thinger.io only entitles you to write data to a bucket at most
enables the dashboard for external access: the (rather lengthy) once a minute. Figure 27 shows how natty the dashboard we
link required to access it will appear in the field labelled ‘Share have created looks on the screen of a smartphone.
URL’. Using this link it is now possible to access the dashboard
from anywhere in the world and examine the data it displays. In conclusion
Because of the length of the URL it is recommended to use a With that we come to the end of our short series of articles
URL shortener such as bitly.com to abbreviate it. The short- introducing the world of the Sigfox 0G network. The highly
ened URL can then be converted into a QR barcode that can flexible and versatile programming of the Arduino MKR FOX
be scanned by a smartphone: this avoids the bother of having 1200 enables the acquisition of a broad spectrum of types of
to tap in the long URL. data and their transmission over the Sigfox network all over
It is worth noting that when you enable public access to the the world. Meanwhile the simple yet powerful visualization
dashboard at thinger.io it is automatically write protected: possibilities offered by thinger.io allow the rapid and efficient
that is, it can only be read. Third parties cannot alter settings development of custom dashboards for communicating infor-
or make other adjustments: this is only possible after using mation to end users.
the appropriate credentials to log in to the thinger.io portal. We wish you every success on your forays into the exciting
We would now like to test the system as a whole. However, it is world of the Internet of Things!
somewhat annoying to use the Sigfox-3_0.ino Arduino sketch 190281-D-02
to do this, as it is necessary to press a button each time we
want to send a message. To help out there is another sketch,
called Sigfox-Demo.ino, included in the software download [8].
At ten-minute intervals this program automatically acquires
the three readings and transmits them (see Figure 26). The
4 sale @ www.elektor.com
interval between transmissions is determined by the value of ªArduino MKR FOX 1200
the global variable w_zeit and can be adjusted if desired, so www.elektor.com/19096
you can arrange to acquire and display readings over a long ªArduino Antenna 868 MHz
period of time. However, always keep in mind that you are only www.elektor.com/19095
allowed to send a maximum of 140 messages per day on the
Web Links
[1] Thinger: http://www.thinger.io/
[2] Sigfox backend: https://backend.sigfox.com/
[3] Information on configuring Sigfox callbacks: https://support.sigfox.com/docs/callbacks-documentation
[4] Information on creating custom Sigfox callbacks: https://support.sigfox.com/docs/custom-callback-creation
[5] Information on the Sigfox callback API: https://backend.sigfox.com/apidocs/callback
[6] Byte ordering when storing numeric values: https://en.wikipedia.org/wiki/Endianness
[7] Information on designing a dashboard: https://github.com/thinger-io/Docs/blob/gh-pages/console/dashboards.md
[8] Project web page: www.elektormagazine.com/190281-D-02
What is the Elektor Investment Program? We also aim to assist investors. We know that
As a start-up or scale-up, there comes a time when bootstrap- investors get dozens of pitch decks each year. And it takes a
ping is no longer an option. If you are lucky, you already have lot of time to read them all, and most of them are not good
some paying customers, but you will need money to take your enough. We realized that we could help investors save time by
business to the next level. Maybe you need to hire a team, connecting them with promising tech start-ups in our global
enter new markets, or extend your development. The most network that match their investment scope.
likely step is to talk with investors. As a founder, you might
ask yourself: Am I ready to pitch to them? Is my business Start-Up benefits
plan and pitch deck ready? Will investors take me seriously? Are you a member of a start-up or even scale-up in need of
Members of the Elektor Investment Program team will guide funding? By participating in the Elektor Investment Program,
you through this venture. We can help with your business plan, you can take smart actions to improve your chance of getting
assist you in preparing your pitch deck, and match you with funded. Sounds like a good deal, right? Here’s what we offer:
investors from our network. • Personal help to improve your pitch deck and business plan.
• Business analysis to make a profile of your company.
• The opportunity to be connected to matching investors
(based on your profile) from our network.
Investor benefits
The Elektor Investment Program can help investors find innova-
tive companies. In addition to running successful start-up
competitions, our professional start-up team scouts for promis-
ing companies around the world. Companies that join the
program are screened by our experts, so we assist investors
with promising leads. We provide:
• Access to high-potential technical start-ups and scale-ups
that match your investment scope.
• Proper documentation, professional business connections,
and a business analysis of your matches.
Since its introduction over 25 years ago the USB port has become the de-facto standard for communications
between a PC and its peripheral equipment. In the meantime, in an effort to reduce the plethora of non-
standard wall-wart mains adapters, most other devices with built-in rechargeable batteries like mobile
phones, tablets etc. use the 5 V supply pins of this port for charging. It’s even possible to fit a mains outlet
wall plate with a built-in 5 V supply and USB socket. With the introduction of Quick Charge the power supply
communicates with the device being charged to negotiate an output voltage. A compliant charger can output
a higher voltage and current beyond the typical 5 V / 2 A rating of the standard USB charger. With so many
essential devices relying on a fully-functioning charger and so many different fast-charge standards emerging
it is convenient to have a single unit that can quickly check that the charger is doing everything it should...
Figure 3. The USB load module in all its glory. It’s all there: three USB Figure 4. Underside of the USB load module (Image. Joy-IT).
inputs, fan, display, three LEDs, three pushbuttons (the third is under the
board) and a potentiometer.
already reviewed another USB test device from Joy-IT[1] called Unboxing
the UM25C — but this one here is a different kettle of fish with The load tester consists of a single board and is supplied in a
different capabilities. translucent plastic box (Figure 1) with the picture on the lid
showing what is inside. Apart from the USB load tester board
Features there is no documentation or links to any sites where the
The Joy-IT JT-HD35 is a compact, electronic USB load resistor documentation can be downloaded. The underside of the box
able to measure and display the output power up to 35 W from is printed with the main features of the load tester but again no
a USB port or charger. It can test the output of a standard 5 V links (Figure 2). This is no great loss because it’s no problem
USB charger as well as those compliant with some of the more to Google the company name and find the user manual for this
recent fast-charge standards. device in PDF format [2].
The key features of this unit are: I prefer to store this type of document in an ‘Instructions’
folder on my PC; it saves tedious searches by hand — and a
• Operating voltage: 4 to 25 V (DC) PDF is ideal as it can be searched for keywords in most cases.
• Load current: 0.25 to 5 A First of all, I was keen to see how far I could use the device
• Power: max. 35 W without resorting to the manual.
• Indicators: 3 status LEDs (green, blue, red) Figure 3 shows what’s in the small plastic box. The unit consists
• Display: 4-digit 7-segment display LED, red of an assembled PCB with a heatsink and fan fixed in place
• Operation: 3 buttons, 1 multiturn potentiometer (load using only two screws. On the underside shown in Figure 4 you
current adjust) can see the TIP122 power Darlington and an LM317 regulator
• Connections: USB 2.0, Micro-USB, USB-C which are mounted on the underside of the heatsink. The NPN
• Fan: 40 mm, 0 to 8000 rpm, temperature controlled Darlington transistor is rated at 65 W max. and is probably
• Dimensions: 84 x 41 x 28 mm used as the variable load to dissipate the power. Also on this
• Weight: 52 g side is a microcontroller labelled U1 = N76E003AT20, which is
Testing, testing…
I selected two power supplies/chargers with three cables as
guinea pigs (Figure 6) for the USB load tester. The little black
one on the right with the micro-USB to USB-A cable is a cheap
standard charger with 5.1 V and 1 A load capacity, as it used to
come with many (old) smartphones. It cannot deliver anything
much more than five watts. The white ‘smart’ power charger
from RAVPower is surrounded by a USB-A extension cable and
a USB-C cable. It supplies 5 V at 2.4 A from its USB-A socket
and not only 5 V at 3 A from the USB-C socket, but also 9 or
15 V at 2 A or 20 V at 1.5 A thanks to its compliance to QC
Figure 5. This close-up clearly shows the chip’s identification marks. 3.0. The total power output amounts to 36 watts, which ties in
nicely with the rated power handling of the JT-HD35.
After switching on, when connecting to the black charger, the
voltage is shown in two digits on the display, i.e. about ‘5.1 V’.
After a little erratic operation of all the pushbuttons, I think I
got some idea how this thing works: pressing the ‘SET’ button
cycles the display to show voltage, power (initially ‘0.0P’) and
current (here flashing ‘1.00A’). Now if you press the OK button
once, the current setting value stops flashing and remains
constant. Then after about 20 s the cooling fan kicks in. This
indicates that when the displayed current is flashing it shows the
required value of load current but without the load connected.
When the displayed current is continuous it indicates that the
load is connected. Another press of the ‘OK’ button removes
the load and sets the display value flashing again.
By adjusting the multiturn pot setting while testing the small
black charger under load I increased the load current to 1.1 A
and noticed that the output voltage dropped to 3.5 V. It was
reassuring to find that the charger has some built-in over-cur-
rent protection. It was also interesting to see that micro-USB
connector is unsuitable to deliver high levels of current. Even
Figure 6. These two power supplies are about to be put through their with a current limited to 1 A the voltage drop across the connec-
paces. tor resulted in a measured supply at the load of 4.9 V, whereas
the USB-A extension cable used with the same power supply
delivered 5.0 V.
And now?
After testing it with 5 V USB supplies I wanted to move on and
try various other voltages according to QC 2.0 or 3.0. At first
I wasn’t sure how I could change the mode but after search-
ing through the manual it became obvious I had overlooked a
pushbutton on the underside of the board. This is the ‘trigger’
button — used to activate the curiously named ‘trigger/decoy’
feature. I guess the JT-HD35 could be thought of as a kind of
Figure 7. Proof: The RAVPower QC 3.0 compliant charger can supply decoy device which sends appropriate acknowledgements to
3.88 A via USB-C at 5 V. the charger, to make it switch its output (surely ‘Mode’ would
Web Links
[1] Review: The Joy-It UM25C USB Tester:
www.elektormagazine.com/news/review-the-um25c-usb-tester-with-color-lcd-and-bluetooth
[2] JT-HD35 operating manual: https://www.joy-it.net/files/files/Produkte/JT-HD35/JT-HD35-Manual.pdf
image: Shutterstock
Why limit the use of the exquisite CAN bus to in-vehicle sensorics? That’s what the author thought when
customers, installers and authorities bickered about disappointing results from a 25 kW solar cell array on
commercial exploitation. Here’s how an electronics system got designed to read out the power yield of each
PV panel individually along with its number so the serviceman can pinpoint it and clear the source of the
problem (literally — read on).
The situation: a roof-mounted solar PV cell array comprising place which is thick with birds like crows and pigeons. The
55 panels, each generating 24 volts and up to 25 kilowatts droppings are so frequent that almost all PV panels get the
in total supplied to a large single-phase, 220-V out, inverter, complete share in about a fortnight’s time.
charging a large battery array well out of sight. The consumer: The remedy I suggested was to wash each panel with water
a conglomerate of shops requiring electricity for evening sales every alternate day, and as a long-term measure, to move
and other activities. The shops were supposed to get six hours the panels away to a place with fewer birds in the air above.
of lighting from 5:30 pm to 11:30 pm. The setup was inaugu- The regular cleaning restored the performance to the origi-
rated with a great fanfare in the presence of a big shot who nal level and after a while it turned out that only selective
came down from headquarters. cleaning was sufficient to maintain the performance, rather
than the alternate-day scheme. Still the washer person had
Wash & wipe to visually check all the panels first and then proceed to the
The solar PV array, inverter, and the battery system worked selective cleaning. The checking takes substantial time as the
fine for some time but slowly, over a couple of months, the worker has to go round all the panels to see which ones need
performance deteriorated such that even with charging periods cleaning. For the 55 panels involved this was rather easy but
of 10 to 12 hours, the ’evening’ power did not last for more for TAD’s next setup, a 100-kW PV panel array, a nightmare
than 3 to 4 hours. The brick batting started. The local Township loomed for the cleaning person or staff. In short, TAD wanted
Administration Department (TAD) started blaming the installers to know instantly which panel in the array needs cleaning so
for poor quality installation, cheap PV products etc. But a quick that the “bucket & mop” person can go straight to that panel
glance at the rooftop mounted PV panels revealed the mystery and do the surface cleaning in no time.
in no time. The 55 panels worth 500 watts each are spread
over three rooftops, and huge numbers of pigeons and crows Enter the CAN bus
were flying right above them. Most of the PV panels were dirty Control Area Network (CAN) using the cheap Arduino is a great
and covered in at least two major servings of bird dropping. solution for measuring the performance of the individual PV
The shopping complex is situated adjacent to the local market- panels. The CAN bus was invented by Bosch within the automo-
Solar PV
MCP2515 CAN
SCK
S0
H
SI
120
CS
GND
L
8
D13 VCC
IOREF
RES
ARDUINO
3V3
- +
5V
GND
+
D9
X
GND
VIN D7 X
ACS712
A0 Relay Board X
X
D0
X
Buck Charger X
+
(5V)
5V
GND X
- X
CAN1 X
X
X
X
X
Arduino Uno X
X
Solar PV
X
MCP2515 CAN X
SCK
S0
H
X
SI
CS X
GND
L X
8
D13 VCC
IOREF
RES
X
ARDUINO
3V3
- +
5V
GND
+ X
GND
VIN
D8
D7 X
ACS712
A0 Relay Board X
X
X
D0
X
+ Buck Charger 5V GND
X
(5V) X
Shielded twisted-pair cable
-
CAN254 X
X
X
X
Arduino Uno X
X
Solar PV
X
X
MCP2515 CAN X
SCK
S0
H X
SI
CS X
GND
L X
8
D13 VCC
IOREF
RES X
ARDUINO
3V3
- +
5V
GND
+
X
GND
VIN
D8
X
ACS712
D7
Relay Board X
A0
X
X
D0 X
Buck Charger
+ 5V GND
(5V)
-
CAN255
120
Figure 1: Block diagram showing the modules, devices and cables involved in making a CAN bus based monitoring system for a solar panel array with
up to 120 (!) PV panels (just 3 shown here). Each panel is individually monitored for failing output current due to whatever cause. One Arduino UNO is
assigned the CAN Bus Master level, the others are slaves.
120
CS
GND
VCC L
Solar PV
8
D13
D12
X
ARDUINO
D11
5V
GND
+
D9 X
D7
7 4 1 X
A0
A1
* X
X
- + 0 8 5 2
X
D0
# 9 6 3 X
X
D C B A X
Buck Charger 5V X
+
(5V) 4x4 Keypad X
- X
X
190035-006-94 KD
Figure 2: Schematic of the CAN Bus Master with a 4x4 keypad for use in control mode.
Web Link
Project on Elektor Labs: www.elektormagazine.com/labs/can-bus-for-solar-pv-cell-monitoring
If you are new to this series, reference should be made to the result in feedback from the loudspeaker to the microphone. This
previous installments [1],[2]. For all readers to benefit from, is a mechanical problem, because even the best loudspeaker
the circuit of the microphone preamplifier we’re about to discuss is not ideal and will distort the sound. In the case of the bat
was extracted from the Bat DetectorPLUS full schematic and is detector, there are of course no requirements for really small
shown separately in Figure 1. Flashlights on and let’s do some signals as with an audio amplifier. A signal-to-noise ratio of
more design analysis on it. 20 dB in the signal going to the comparator is likely to suffice.
4k7
R6 R9 R12
transistors, e.g. a pair of diodes K1 100k 100k 100k
C12
in anti-parallel or Zener diodes in 1n R4
2
C14 R7
6
C16 R10
2 C18
7k5 7k5 7k5
anti-series. Also, if the specifications D3 R5 IC2A
1
1n R8 IC2B
7
1n R11 IC3A
1
3V C11 3 5 3
are exceeded, the output voltage 0W5
10k 10k 10k
470p
MIC. 100n
can flip over. A problem with the
TL062 is its maximum input offset, IC2, IC3, IC4 = TL062CP
-4V5
which is up to 15 mV, even up to 200100-002-94 KD
10k
(S) (S) Audio
• Drive an electromotor
• Temperature control
• Motor speed controller
O W6 •
•
Web server with CGI
And more!
N 31,4 er
s Take your Raspberry Pi-based projects
€ fo
rm
emb to the next level.
lektor
Test drive
After everything was reassembled, I went
out into the street. In the YouTube video
[2] you can admire my first, still cautious
driving attempts. At first I only dared
to drive in eco mode, which goes up to
15 km/h. And rightly so!
To make the scooter accelerate, you must
first push it to a speed of over 2 km/h.
Figure 7: Front wheel with hub motor and solid Figure 8: Rear wheel with disc brake and This is no problem, one push is enough.
rubber tyres. locking device for the folded down handlebars.
This little inconvenience has the advan-
tage that the high power consumption
when moving off is reduced and the
batteries last longer. Here we go and the
aluminium tubes are neatly welded only a thicker plastic cover at the bottom 15 km/h did not feel unsafe despite the
(Figure 6). The mechanism for locking (Figure 9). Thirteen screws later you small wheels. But then came the revers-
the handlebars also looks very stable. have it in your hand. Figure 10 shows ing, and as we all know, you have to
Figure 7 shows the front wheel. Lidl that it is simply sealed with a foam tape. brake for that. First of all: I didn’t break
talks about “8.5” air chamber tyres No big problem, because eBay offers anything...
(Honeycomb)” but I am not convinced. such aluminium covers for little money Of course I tested the left red lever
It reminds me more of normal solid tyres. in different colours for the Xiaomi M365 with the recuperation brake first.
In any case you don’t have to fear any (search for “Bottom Battery Cover Xiaomi Unfortunately it has a rather digital
loss of pressure. Figure 8 shows the M365”) and they should fit. In general, behaviour and the scooter brakes
rear wheel with the oversized, perfo- there are a lot of matching accessories abruptly and strongly. Since I was not
rated brake disc, rear lighting and license under the keyword “M365”. prepared for this, I almost flew across
plate holder. The grey rubber nipple at the handlebars. So I accelerated again
the top is used to lock the folded-down Figure 11 shows the most important and then decelerated with the rear brake.
handlebars. So you can carry the scooter thing: the battery. It is built from round The too you have hardly any control in
comfortably despite its weight of around cells (type 10s3p) and looks quite decent. the lever. The disc brake is much too
15 kg. You can find more details in the The brochure information is also correct. violent for my taste. If there would be
Features box. The battery is screwed to the frame from foliage, the rear wheel would be gone.
below and is easy to replace if faulty. So far, so hard.
Inner life The second most important thing is the There’s hardly any feeling of accelera-
As always, the innards are particularly electronics: Figure 12 shows that it is tion in eco mode. I would have imagined
interesting for electronics engineers. extra protected from moisture by a trans- 350 watts differently. But maybe the
So the scooter had to be screwed open parent plastic case. The six MOSFETs for full power only comes in normal mode,
right away. That’s easy, because there is a three-phase bridge circuit are clearly I thought. So I stopped, pressed the
Figure 9: The underbody is made of plastic and can be dismantled. Figure 10: Unscrewed cover with foam seal.
Conclusion
In general I was positively surprised by
the quality of the e-scooter. It is really
neat and stable. The battery doesn’t
disappoint either and you can fully trust
it to have the 22 km range - I haven’t
tried it though as I don’t like pushing.
The electronics also look good and the
lighting is bright and sufficient. That a Figure 11: The battery. Looks pretty decent.
scooter like this can be made for this
price amazes me.
I didn’t like the acceleration so much
though. That should be 350 W, really?
There is no real electric feeling - except
when recuperating. So to the biggest
shortcoming: the brakes are just too
violent. While the disc brake certainly
gets a bit smoother over time, recuper-
ation is simply too aggressive. Whoever
designed this has only used a part of his
mental potential.
All in all, I would come to a positive
overall assessment despite the brakes
taking some getting used to. The price/
performance ratio is already very good.
Nevertheless, I would strongly advise you
to take a test drive if you want to buy
such an e-scooter for yourself or your
Figure 12: The six MOSFETs are clearly visible in the encapsulated electronics.
offspring.
A good friend of mine tried out if this
scooter fits into the frunk (coinage from
front and trunk) of his brand new Tesla
Model X. Figure 14 proves that it does.
Martin would like to drive around town
on the scooter in case his Tesla takes a
break at a charging station. A good idea
and the scooter is certainly cheaper than
a wing mirror of his new electric vehicle.
But the Tesla is 12.4 times faster and
offers 885 times more power.
191251-03
Figure 13: Charging socket on the left side of Figure 14: Scooter in the frunk of a Tesla Model
the scooter. X (Photo: Martin Jepkens [3]).
Web Links
[1] Xiaomi Scooter: www.mi.com/global/mi-electric-scooter
[2] Test drive (YouTube-Video): www.youtube.com/watch?v=9UNWDpAYAoU
[3] Martin Jepkens: www.me-marl.de
Lead-free baking with lead-free solder. Strictly speaking, you could still use
If you do soldering, make repairs or build prototypes as a lead-based solder for your prototypes, but to avoid the risk of
hobby, you need not read any further, and you should get contamination I use only lead-free solder.
down on your knees and thank the gods that you are allowed The period shortly after the first Restriction of Hazardous
to use lead-based solder. If like me you put together commer- Substances (RoHS) regulation took effect in 2006 was fairly
cial products, you are out of luck and condemned to working dramatic for the electronics industry. Some lead-free processes
Recycling
It’s also questionable whether banning lead from electron-
ics is really that much better for the environment. Instead of
the current cheap disposable electronics, it would have been
As far as automated better to aim for higher quality and more durable products.
soldering is concerned, This brings us to the recycling of products, and there as well
most of the problems the government busybodies and bureaucrats know how to
have been solved by now, make your life miserable. In most European countries there
and in practice the tin whiskers are organisations for recycling discarded devices and reusable
and other potential disasters have waste. In Belgium we have Recupel, Bebat and Fost Plus, among
turned out to be minor issues, although others. I am fully in favour of recycling, but association with
I have the impression that modern consumer the above-mentioned organisations is not only expensive but
electronics fails faster and more often than in the also involves a lot of paperwork. Fortunately, I’m not bothered
past. Of course, this could also be due to the quality of the much with this as long as I do not sell completely finished
components concerned. With the growing number of low-cost products or batteries and keep the use of plastic packaging
imports from Asia, it has systematically declined. within reasonable limits. From what I hear from colleagues
Unfortunately, manual lead-free soldering is still a bit of a and competitors in Germany, the situation in Belgium is not
challenge. And if we can believe the countless photos circu- so bad. Stiftung EAR, the German equivalent of Recupel, takes
lating on the Internet, soldering on computer motherboards is its role very seriously and has already imposed hefty fines in
very hard on the fingers, and the higher melting temperature of some cases. In Germany, rules are rules.
lead-free solder certainly doesn’t help. To see this for yourself, Despite all the regulations and prohibitions, components such as
just Google for pictures matching the search term “solder fail”, mercury switches and light-dependent resistors with cadmium
and be sure to have your burn ointment close to hand. sulphide (shiver!) are still readily available from Asian sources,
With my old soldering stations, soldering relatively large not to mention some potentially lethal products that do not
through-hole components on PCBs with plated-through holes comply with any standards but are still for sale in shops here.
was not exactly easy with lead-free solder, especially on solder Is this a sign of a double standard amongst our European
pads in or next to large copper planes. The irons were usually policy makers?
set to a temperature of 420 to 450 degrees C, and in some 200082-02
cases I needed two irons at the same time to get the solder
to melt. It’s hardly surprising that I went through solder tips
pretty fast. Although working with lead-free solder is a good
deal easier using modern soldering stations with interchangeable
active tips, my feeling is that soldering on large copper surfaces
is still not straightforward. Desoldering through-hole compo-
We Links
[1] Transistor Curve Tracer: www.elektormagazine.com/magazine/elektor-200902/18980
[2] HV Power Supply / Tube Curve Tracer:
www.elektormagazine.com/labs/hv-power-supply-with-tube-and-semiconductor-curve-tracer
[3] Electronic load for DC and AC: www.elektormagazine.nl/labs/electronic-load-for-dc-and-ac
[4] Video: www.youtube.com/watch?v=2f75lK12Wjo&list=PL2a34OA-WuybkArjgAnXiIFqUc3KYf19A&index=4
It’s well known that electronics engineers never have enough power supplies. I’m no exception to this rule,
as you can see from a photo of the home lab in my basement. The neat PeakTech 6080 A power supply is
unusual amongst all the PSUs on the market today. It has been designed using linear technology with a
traditional power transformer. The result is a quiet output voltage, highly accurate displays and all for not
much money at all...
It’s well known that electronics engineers never have enough Power Supply [1] from 1980! 40 years old and still accurate
power supplies. I’m no exception to this rule, as you can see to 0.1%, good design is the key. Next in line is a relatively
from a photo of the home lab in my basement. It all looks a high-impedance mains voltage source with safety insulation
bit squashed up but I’m sure I could make room for just one and a load capacity of around 60 W, it’s not beautiful, but it’s
more… The small PeakTech 6080 A lab power supply offers practical and saves lives.
power and accuracy for a very reasonable price. The digital lab power supply delivers a lot of power with a
Actually, the home lab is already quite well equipped with power maximum of 60 V at 8 A — this one is obviously not homemade!
supplies. A 12 V 9 A unit (far right) is ideal to power small Now the PeakTech 6080 A has been added to the lineup, it
low-voltage drilling/grinding machines such as a Dremel or only delivers 3 A at 15 V max, but stands out because of its
Proxxon etc. You can also see the homemade Elektor Precision other features.
Unboxing
The PeakTech PT 6080 A power supply did not reach me via the
normal route that other parcels have taken when they arrive
at my door. This time I got a call from a neighbour who lives a
few blocks away. He said his parents had seen some packages
fall from a passing mail van carrying parcels and my name and
address was on one of them. It was Christmas Eve so suspi-
cious of a prank I asked if it was gift wrapped and maybe,
was the van being pulled along by… reindeer? He remained
serious so I thought it would be best to go and investigate.
Sure enough it turned out to be the PT 6080 A power supply
unit I had recently ordered. The package was a bit scuffed but
not badly damaged.
You may well be wondering the significance of this anecdote: In
Figure 1: The lab power supply is protected by thick foam packing. fact it turned out to be a good drop-test for the power supply,
the packaging with its internal foam cushions (Figure 1) did Precision on display
an admirable job of protecting the unit. It survived unscathed What really interests me with regard to power supplies is the
and is fully functional. accuracy of the displayed voltage and current levels. I also have
a digital power supply unit, where the voltage and current are
The unit is 80 x 160 x 225 mm (W x H x D) and its layout is set digitally using two rotary encoders. This switch between
more ‘portrait’ than ‘landscape’ (Figure 2), which takes up coarse and fine adjustment (in a ratio of 1:10) can be toggled
less bench space. The thick, heavy heat sink on the back looks by pressing the knob. Budget priced digital power supplies
well proportioned to keep the power components cool. It is the usually only show the value of what has been setup, not what
first indication that this power supply unit is designed using is actually coming out of the sockets. As a result, there are
more traditional, linear technology. This type of supply needs always small discrepancies in the range of 100 mV or a few
to dissipate high levels of power when delivering high current tens of milliamps in the displayed value and the actual value.
at low output voltages. The second indication of the chosen Cheaper digital power supplies often cut costs by omitting the
technology is the unit’s weight: 2 kg is relatively heavy for a digital voltmeter chip thereby making the displayed values
45-W power supply. This indicates there is an iron or ferrite- less representative.
cored transformer inside running at mains frequency. Switched- The PT 6080 A is different. Instead of encoders, normal poten-
mode supplies will use smaller, lighter transformers switching tiometers are used here. The ‘gear ratio’ from coarse to fine
at a much higher frequency. adjustment is about 1:7. For me, the analogue setting adjust-
ments took some getting used to. Unlike digital power supplies,
The lab power supply has an output voltage range adjustable you do not immediately see what you are setting. The applied
from 0 to 15 V via its two safety 4-mm banana sockets on the voltage and current flow are measured digitally and average
front panel which accept shrouded or standard banana plugs. A/D converter chips can manage about three or four measure-
Output current limit can be set from 0 to 3 A using the ‘A’ coarse ments per second so there is always a slight delay between the
and fine adjustment pots. Output voltage can be set similarly pot movement and the displayed values. I wouldn’t say this is
using the ‘V’ coarse and fine pots. Two four-digit displays bad, just different from the digital lab power supply I’m used to.
show both the output voltage and current level. Two LEDs Figure 3 shows an impressive aspect of this power supply:
labelled ‘C.C.’ and ‘C.V.’ indicate whether the unit is operat- The displayed values are almost identical to those of shown
ing in constant current or constant voltage mode. Figure 2 on my multimeter. There is a discrepancy of 10 mV = 0.07 %
shows the C.V. LED lit. When the current limit is reduced from for the voltage and 0.3 mA = 0.08 % for the current (the
its maximum setting the C.C. LED will be lit instead. deviation is similar at 3 A). This is surprising, I calibrated the
a b
Figure 3: Displayed value vs DVM measurements (voltage above, current below). Figure 4: Maximum voltage (a, CV) and
maximum current (b, CC).
Noisy or quiet?
The next important aspect is the electrical ‘cleanliness’ of the
output voltage under load. A low-power linear lab PSU would
not be chosen to primarily power digital electronic circuits. It is
more suited as a power source for analogue, audio frequency
applications or RF circuits. For these applications it is import-
ant to provide a supply free from noise spikes and interfer-
ence. Except for very expensive laboratory equipment, the
output voltages supplied by digital lab PSUs are almost always
contaminated with interference and noise signals related to
the switching frequencies (and harmonics thereof) used by
the switched-mode controller. PSUs based on linear regulators
should fare better in this respect, is that true of the PT 6080 A?
The manufacturer states that the residual ripple of the voltage
is 0.5 mVrms. Figure 5 shows four screenshots of output voltage
waveforms under different load conditions. The sensitivity (2 mV/
graduation) and time base (10 ms/graduation) are the same for all
of the images. Noise and hum in CV mode are within the specified
range both under no load (a) and loaded (b) output conditions.
The output voltage is not quite as good when in CC mode. Here
the ripple is around 2 mVeff regardless of the load. The clearly
visible low-frequency 128 Hz (c) or 171 Hz (d) fundamental
is not a harmonic of the mains frequency so is not likely to be
mains hum.
To sum up
By choosing the PeakTech PT6080A (available from the Elektor
4 sale @ www.elektor.com
Store for less than €60) you will be getting a good quality, low
noise power supply with digital displays showing impressively ªPeakTech 6080 A DC Lab Power Supply
accurate output voltage and current readings. The electronic www.elektor.com/19111
components and PCB are of good quality and the unit layout is
6. Raspberry Pi 4 B (4 GB)
Harry Baggen (Elektor Labs) www.elektor.com/18964
NEW
The completely revised 3rd edition describes 45 exciting This bundle (available exclusively from Elektor) contains Spresense is a compact development board based on Sony’s
and compelling projects, such as a flashing lights, driving the programmable laboratory power supply JT-RD6006, an power-efficient multicore microcontroller CXD5602. It allows
an electromotor, processing and generating analog signals, industrial power supply unit (60 V, 6 A), a large aluminium developers to create applications in a very short time and is
a temperature control and a lux meter. More complicated housing and a plug-in WiFi module which enables the supported by the Arduino IDE as well as the more advanced
projects are also included, such as a motor speed controller, a JT-RD6006 to be controlled by other (mobile) devices NuttX based SDK. The main board uses a processor developed
web server with CGI (Common Gateway Interface), and client- via wireless connection. The bundle will be supplied in a by Sony for IoT and sensing applications. The main board can
server applications. practical hard case. be operated alone or with the extension board.
Programming NEW
with Node-RED
Produced by IBM, Node-RED is an open-source visual editor for
wiring the Internet of Things. Node-RED comes with a large number
of nodes to handle a multitude of tasks. The required nodes are
selected and joined together to perform a particular task. Node-RED
is based on flow type programming where nodes are configured and
joined together to form an application program. There are nodes
for performing complex tasks, including web access, Twitter, E-mail,
HTTP, Bluetooth, MQTT, controlling GPIO ports, etc. One particularly
nice aspect of Node-RED is that the programmer does not need to
learn how to write complex programs.
The aim of this book is to teach how Node-RED can be used in
projects. The main hardware platform used with most of the projects
in this book is Raspberry Pi 4. Chapters are included to show how
Node-RED can be also be used with Arduino Uno, ESP32 DevKitC, and
the ESP8266 NodeMCU microcontroller development boards.
Microcontroller Basics with PIC The State of Hollow State Audio Tactigon ONE – Gesture &
Motion Controller with AI
In this book the author presents all essential aspects of Audio tubes are currently experiencing a comeback, especially The Tactigon ONE is the ultimate wearable board,
microcontroller programming, without overloading the in the music and high-end audio industry. This new book programmable with Arduino IDE. It features GPIOs, UART, an
reader with unnecessary or quasi-relevant bits of information. provides answers to the following questions, among others: Do integrated battery recharge system, a fast microcontroller,
Having read the book, you should be able to understand as tubes produce better sound and how do hollow-state circuits and Bluetooth LE onboard! Measure linear and angular motion
well as program, 8-bit microcontrollers. The introduction work? How do you design hollow-state audio circuits? Can with a 3-axis gyroscope and 3-axis accelerometer. An extra
to microcontroller programming is worked out using you recreate some of the classic hollow-state audio devices 3-axis magnetic sensor provides more precision. The high-
microcontrollers from the PIC series. for modern listening rooms and recording studios? How can speed microcontroller unit and Arduino SDK allow for complex
you intelligently modify hollow-state amplifiers to your taste? sketches execution.
A Big Challenge
Safe products in the IoT era
By Tessel Renzenbrink (The Netherlands)
Seat belts, airbags, crush zones, speed limits and combatting drunk driving – over many decades,
technological innovations and regulations have made cars ever safer. The same applies to other consumer
products. We buy them with confidence and trust that they are safe. But the advent of the Internet of Things
(IoT) opens a new Pandora’s box. With more and more products being equipped with electronics, software
and network connectivity, we are exposed to new dangers and risks. There are plenty of examples, such as
networked toys that can be used to spy on children or vehicles with control systems that can be hacked and
taken over remotely.
Professor Ross Anderson and his colleagues have investigated of both worlds. For example, consider phones versus vehicles.
which measures are necessary to combine traditional product The firmware and operating systems of phones are typically
safety with the advent of the IoT. They did this on behalf of the supported for about three years. After the support period ends,
European Commission. The EU is working on new legislation a phone becomes unsafe because the vulnerabilities of the
to ensure product safety in the future. They asked Anderson software are no longer corrected. People are forced to replace
to identify what is necessary for this. Anderson, a profes- their phones, even though the hardware is still perfectly okay.
sor of security engineering at Cambridge University, carried We need to make sure that this approach is not followed in the
out the study with his colleagues Eirann Leverett, Senior Risk automotive industry in the future, says Anderson.
Researcher, and Richard Clayton, Security Researcher. The However, lifetime maintenance comes with its own challenges.
report with their findings was published in 2017 [1]. Suppose a manufacturer is required to support a particular
vehicle model for at least 20 years. A software engineer who
Trilemma writes a program for a vehicle with a planned market launch in
Anderson and his colleagues concluded that we still have a 2022 will have to take into account that the code must continue
long way to go. The crux of the issue is that the way we ensure working until 2042.
the safety of physical products is fundamentally different from Complexity is also a challenge. The idea of the IoT is that
how we ensure the safety of digital technologies. Products are devices can communicate with each other and take action
tested and inspected before they are put on the market, and independently. For example, autonomous vehicles that exchange
this is assured by a safety certificate or an approval mark. information with the road infrastructure or refrigerators that
If there are significant changes to the product, it must be do their own shopping. From a safety perspective, this means
certified again. By contrast, the safety of software is essen- that testing devices on their own is no longer sufficient. It is
tially dependent on changes. Software is constantly monitored also necessary to examine the risks arising from the interac-
and regularly revised with patches and updates. Anderson tion with other devices.
addressed this in more detail in a presentation on their study
at the Chaos Communication Congress (CCC) in December Recommendations
2019 [2]. He called this the ‘trilemma’ of IoT products. If Product safety in the IoT era is a complex issue that does not
you stick to pre-market certification, you cannot modify your have any simple solutions. In their report to the European
software, which means your product is unsafe. If you modify Commission, the three researchers made several recommenda-
your software, you lose your certification. And if you combine tions. The main recommendation is to establish a new European
certification with updating, which means going through the agency, dubbed the European Safety and Security Engineering
certification process again after each software update, the Agency (ESSEA). The ESSEA must have the technical exper-
costs go through the roof. tise necessary for tasks such as developing standards and
informing policy makers. In addition, it must house a central
Lifetime and complexity database holding information about software vulnerabilities,
Traditional products and digital services each have their own failing components and errors in system integration. Presently
characteristics, which are now being combined. According to this sort of information is held by a variety of agencies and
Anderson, we need to avoid ending up with the worst features companies. Bringing this information together would enable
The EU as a line of
defence against an
Internet of Trash
During the presentation at the
CCC, Anderson commented
that has proven difficult to
get the recommendations
implemented. There are many Photo: Gabor Kiss safety door. CC BY 2.0 https://www.flickr.com/photos/-nevi-/5404057758/
different parties involved, each
with their own interests. For
example, Facebook and Google
lobbied against the proposal to subject digital services to Union. However, in a related scientific article they write that
existing liability regulations. However, a number of things their hope is fixed on the EU: “The EU is already the world’s
have been achieved since the publication of the report. For main privacy regulator, as Washington doesn’t care and nobody
example, Regulation No. 2019/771 has been adopted, which else is big enough to matter; it should aim to become the main
stipulates that consumers of products with digital elements safety regulator too — or risk compromising the safety mission
have the right to updates for at least two years, or longer it already has.” [3]
if that can reasonably be expected. The latter means the 200066-02
products that are considered to last longer, such as washing
machines, should also receive updates for a longer period.
The enormous task described by Anderson, Leverett and Clayton
to ensure the safety of IoT products in the future contrasts
sharply with the slow decision-making process in the European
As with many instalments I’ve made so far for the Retronics taking a 10-foot flight out of the window and a hard landing,
series, the subject was not chosen randomly from the vast so no need for me to “dumpster dive” at that time.
Elektor archive stretching back to No. 1 from 1974. Rather,
it’s because the item has survived Elektor’s unstoppable Not lost in translation
custom of consigning “hardware” to the bin after a few years, The discrepancy between the working title of the project and the
especially lab prototypes. In this case, the bin was actually a actual magazine article title “1.2 GHz Multifunction Frequency
large dumpster placed under the lab windows at the former Meter” in Elektor magazine is indicative of the steadfastness of
Elektor Head Office in Beek, Holland, back in July 2006. As with the four ‘language groups’ working at Elektor HQ and always
a few more instruments I’ve been able to describe in Retronics bending over backwards to localize their ‘national’ edition on
articles, I was able to prevent the subject of this instalment from the basis of material supplied by predominantly Dutch and
Back in 1993
Almost 30 years ago, the basic
course a project would follow
towards final publication in Elektor
magazine and PCB sales was not
fundamentally different from today.
Authors would send project submis-
sions in a stamped envelope and
patiently await the Go/No-Go/Maybe
Later verdict from the editorial team,
given by post or telephone. After a
(negotiated) ‘Go’, the project would
be presented as an engineering draft
to the lab team who were supposed
to make the electronics repeatable
for home construction (or even
kitting), design a matching PCB,
and create a software product like an
EPROM. In the case of the 1992/93
frequency meter, the process took
approximately a year although Mr
Zschocke’s original material including
his writeup was quite good, requiring
little ‘post engineering’ and ‘editing’
in Beek.
According to part 1 of the article
series, the project was “a worthy
successor to our famous 1985 Figure 1: The schematic of the 1.2 GHz Multifunction Frequency Meter reveals a mid-1990s-style
microprocessor-controlled frequency marriage between a 40-pin DIP cased microcontroller (here, a 80C32) and discrete electronics. With
meter, thousands of which are in use so much functionality carried out by software, the resulting BOM was remarkably small. (scanned
all over the world”. That 1985 project reproduction)
The Full Monty Figure 5. Kit contents (1995). For the sake of authenticity, no attempt
About one and a half years after the magazine publications, the was made to empty all paper bags containing the electronic components
EPS board sales indicated further commercial potential of the inside.
Tantalum Tantrum
I tried to make the instru-
ment work by inserting
a fresh 9 V battery in the
holder at the underside,
and powering up with the
small slide switch. Nothing
happened and when I
probed the + supply wiring
at a few points with a DMM I
found about +3 V behind the
on/off switch. It was obvious
that something was loading
Figure 6. Alongside a description in words, a drawing was made back in 1993 of the counter’s impressive menu the battery excessively and
structure and user options. The original was sized at 40 × 26 cm and came as a foldout sheet. I immediately suspected one
or more of the electrolytic
capacitors on the supply
relive for a moment. The contents of the package I safeguarded rails, notably the tantalum ones C14 and C17. With hindsight
back in 2006 is untouched and I was delighted to even find a I was happy I used a battery for a few seconds only and not a
length of solid, bare “you-never-know” wire and pieces of sheet benchtop supply as it would have blown out a few componets.
metal to assemble the prescaler screening. Resistors, sockets, I intend to do the necessary repairs to see if the instrument
ICs, pushbuttons, the display, BNC sockets, the programmed actually works — I’m confident.
EPROM, it’s all there and neatly packaged mostly in small, The three instalments describing the 1.2 GHz Multifunction
white paper bags (Figure 5). Frequency Meter are in Elektor’s online archive and accessible
The book in the package is another perfect companion. It packs as pdf files to Green and Gold Members [1][2][3]. The article
all three instalments of the article (December 1992, January instalments are also on the Elektor 1990s DVD. Please note
and February 1993) into a size just over that of the actual that the project is no longer recommended for new construc-
counter once assembled in the Vero case. tion as several parts are no longer available.
190382-C-01
Menu please!
The copy preparation of part 2 of the article grinded to a halt
and ran into some delay when a desk editor of the Dutch
department at Elektor said that the instrument’s menu should
be elucidated and illustrated in proper detail. So far, most of
the lab staff had not selected much from the menu beyond
Retronics is a regular section
‘Press Enter to Continue’ let alone ventured into the myriad
covering vintage electronics
of options hidden deep in the software. So, Dick Lubben at his
including legendary Elektor projects.
quiet desk in Beek spent about two working weeks charting
Contributions, suggestions and requests for instalments are
and documenting the counter’s software structure to the finest welcome, please telegraph the Retronics Conservator on:
detail, culminating in an enormous sheet showing every option, [email protected], subject: Retronics (STOP).
display text and error code imaginable. It was a fantastic feat,
Weblinks
[1] 1.2 GHz Multifunction Frequency Meter, part 1. Elektor Electronics December 1992:
www.elektormagazine.com/magazine/elektor-199212/32728/
[2] 1.2 GHz Multifunction Frequency Meter, part 2. Elektor Electronics January 1993:
www.elektormagazine.com/magazine/elektor-199301/32787/
[3] 1.2 GHz Multifunction Frequency Meter, part 3. Elektor Electronics February 1993:
www.elektormagazine.com/magazine/elektor-199301/32787/
N 31,4
lektor
rs
€ fo
r mem
be
The Hexadoku puzzle employs numbers in the hexadecimal thicker black lines). A number of clues are given in the puzzle
range 0 through F. In the diagram composed of 16 × 16 boxes, and these determine the start situation.
enter numbers such that all hexadecimal numbers 0 through
F (that’s 0-9 and A-F) occur once only in each row, once in Correct entries received enter a prize draw. All you need to do
each column and in each of the 4×4 boxes (marked by the is send us the numbers in the gray boxes.
Participate!
Ultimately May 31, 2020, supply your name, street address
and the solution (the numbers in the gray boxes) by email to:
[email protected]
Prize Winners
The solution of Hexadoku in edition 2/2020 (March & April) is: 749DF.
The book vouchers have been awarded to: Etienne Guyot (France); Ria Van Broeck (Belgium);
Peter Tabatt (Germany) ; Tomas Bakke (Norway); Jose A. Gordo (Spain).
Congratulations everyone!
The competition is not open to employees of Elektor International Media, its subsidiaries, licensees and/or associated publishing houses.
LAUNCH
YOUR STARTUP AT
ELECTRONICA
2020
Is your electronics-related startup ready
to disrupt? It is time to introduce your
company’s solution to the global market!
FINALIST BENEFITS
First Prize = €75,000 marketing package from Elektor,
plus a booth at electronica 2022.
Second Prize = €50,000 marketing package from Elektor.
Third Prize = €25,000 marketing package from Elektor.
Get exclusive, specially priced (only €1,905!) booth
space (5 m²) at electronica 2020.
Get great exposure before, during, and after
electronica 2020. (10.-13.11.2020)
>Sign up
here
electronica Fast Forward is brought to you by
elektormagazine.com/fastforward