This is only a preview of the November 2021 issue of Silicon Chip. You can view 45 of the 96 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "USB Cable Tester – Part 1":
Articles in this series:
Items relevant to "R80 Synthesised Aviation Band Receiver Kit":
Items relevant to "Pocket Weather Station":
Items relevant to "Model Railway Carriage Lights":
Items relevant to "Two- or Three-Way Stereo Active Crossover – Part 2":
Purchase a printed copy of this issue for $11.50. |
POCKET
WEATHER
STATION
By Aarav Garg
We’re often describing how you can buy and use very low-cost electronic
modules. They’re great because they save you a lot of assembly time and
soldering work, and they usually cost less than the parts you would need
to build them! Here is an excellent beginners’ project that uses five such
modules to make something useful – a mini weather station you can
carry everywhere with you.
I
s it hot in here, or just me? That’s a
question you don’t have to ask anymore with this Pocket Weather Station.
It is a compact device, powered by
an Arduino Nano board, that you can
carry anywhere, right in your pocket.
It displays the current temperature and
humidity on its OLED screen. Sure,
you may have the local weather report
on your phone, but it’s amazing how
much local temperatures can vary from
those recorded elsewhere in your area.
Plus, knowing the indoor temperature and humidity can be pretty
helpful, as how hot or cold it ‘feels’
is strongly affected by humidity, not
just temperature. Even with moderate
temperatures, high humidity can make
you sweat more than a more intense
dry heat!
One reason it’s so portable is beacuse of its integrated, rechargeable
160mAh LiPo battery.
It is an excellent project for learning
and is also really fun to make. It even
comes in handy sometimes!
56
Silicon Chip
Sound interesting? Then let’s dive
right in!
First steps
The first thing to do when beginning with any project is gathering the
required components. The required
components are listed in the Parts List.
They are mostly available from online
marketplaces like eBay, AliExpress
and Amazon.
While they are inexpensive, chances
are they will come from overseas, so
allow a few weeks (or even months)
for delivery.
By the way, the DHT11 is a smaller,
less accurate version of the DHT22
temperature/humidity sensor that we
have used in the past and described in
the February 2017 issue (siliconchip.
com.au/Article/10529). Its small size
is useful in a pocket device.
As it incorporates both temperature
and humidity readings, we only need
the one sensor. The other parts are the
Arduino board to query it, the display
Australia’s electronics magazine
to show the readings and the charger
to keep the battery topped up.
You need a few basic tools to build
the Pocket Weather Station: a soldering iron, hot glue gun (or even better,
a tube of neutral-cure silicone sealant
and a caulking gun) and, if you’re going
to make the optional case, a 3D printer.
Preparation
Now we need to plan the position of
all the components inside the enclosure. I wanted to keep the device as
thin as possible, so it is actually convenient to carry in a pocket. Thus I
spread all the components out and did
not go with a layered structure. That
would decrease the width and height,
but increase the thickness.
Fig.1 shows how I stacked the components inside my Pocket Weather Station. I used an Arduino Nano board
because of its size, which is perfect for
this project. You could also come up
with your own method of stacking the
components in ways that reduce the
siliconchip.com.au
►
►
Fig.1: this is how I laid out the
components so that they would fit
inside a custom-made case.
Fig.2: this diagram serves as both the wiring diagram and a form of circuit diagram; it shows all the connections
necessary to turn the separate modules into a Weather Station. You don’t need to use the same colour coding as we did,
but we strongly advise that you stick to the red/black colours for the power wires, and make sure that black only goes to
ground or negative pads, and red to positive pads. Take note that different DHT11 modules may have different pin-outs.
size of the device even further!
After you have planned your preferred arrangement, refer to Fig.2, the
wiring diagram. This shows how all
the modules need to be connected.
It’s relatively simple, as there are few
modules and none of them need to be
modified.
Wiring it up
Before you build the Pocket Weather
Station, you might like to watch
my YouTube video showing how
I assembled it, at https://youtu.be/
ZhOhBuKC80M
There are two types of connections
to be made: power (red/black wires)
and signal (green/orange/yellow
wires). The charger board connects
to the battery as well as all the other
modules, to power them.
The only other connections required
are for the I2C serial bus between the
Arduino Nano and the display and
one signal wire from the DHT11 to the
Nano, so it can get readings.
Start by connecting the battery to
the battery charging module. We aren’t
connecting any wires to the switch yet,
because that has to be done once everything is installed in the case. You can
connect the power supply wiring of the
Arduino, OLED and DHT11 modules
to each other, and the ground back to
siliconchip.com.au
the charger module; leave the wires
for the switch loose for now.
Try to keep the wire lengths just long
enough to prevent a mess of wires later
on. For all the power supply connections, make sure you get the polarity
correct, with black wires to the GND
pins only and red wires to the positive
pins. If you connect them the wrong
way around, chances are that some of
the modules will be damaged.
Also, try to solder everything accurately to prevent any kind of short circuit. It might be a tedious process, but
believe me, later on it will feel worth
the effort. After you have finished soldering all the components (excluding
the switch), it should look something
like Fig.3.
I am sure we can’t carry it around
like this, so clearly we need an enclosure for our Pocket Weather Station
to give it that professional look. And
the best option that we have here is
3D printing.
I don’t have a 3D printer, so I used
an online 3D printing service based
locally in India (www.iamrapid.com).
I uploaded my .stl files to get an instant
quote and ordered the parts right away.
The enclosure
I designed the enclosure in Tinkercad, which is a fantastic CAD software
package. It supports all skill levels,
so even if you are a beginner, you can
still use it. You can download my 3D
files (.stl format) from the Silicon Chip
website.
Australia’s electronics magazine
Fig.3: once you have finished wiring
nearly all the components together, it
should look like this.
November 2021 57
The 3D-printed case for
the Pocket Weather Station.
There are a few 3D printing
services around Australia
which can process the supplied
STL file for you.
The enclosure they delivered to me has
a great build quality.
Chances are you will find a similar
local service. Do a web search for “3D
printing service” or go to your nearest
Jaycar Maker Hub, which offers a 3D
printing service (see our June 2020
issue for details; siliconchip.com.au/
Article/14472). You might also find a
nearby maker space (see https://wiki.
hackerspaces.org/australia).
Fortunately, all the cutouts that I
had made in the design were in the
exact spots I needed them, so I didn’t
have to get a second prototype made.
Putting it all together
Now, we need to place the whole
circuit inside the enclosure that we
designed earlier and 3D printed. It
is vital that all the parts go in their
respective cutouts to give the device
the much-needed professional look.
It is also important that all the components are firmly fixed in their place
and do not move inside the enclosure,
to ensure proper and smooth functioning of the device.
I used hot melt glue to fix the parts
inside the enclosure. However, while
this is convenient, it can fail if exposed
to enough heat (eg, if it’s left exposed
in direct sunlight inside a car). For
this reason, you could instead use
the slightly more permanent neutral
cure silicone sealant. It takes longer
to cure, but it’s not going to fall apart
if it gets hot.
As you fix the components in the
case, make sure the two USB sockets
line up with their access holes around
the edges, as you will need to connect
to both of them later.
Now it is time to add the slide switch
in its dedicated slot. We did not connect the switch previously because the
switch needs to be inserted into the
enclosure from the outside.
After putting the switch into its slot,
use two small screws to fix it in place.
Then connect the two wires to it, one
from the Vcc pad of the Arduino board
At left is
the (nearly)
completed
project, it just
needs the wires
soldered to the
switch at lower
right. Hot melt
glue was used to
make sure the
components were
secure. Note that
this glue can fail
if exposed to
enough heat.
58
Silicon Chip
Australia’s electronics magazine
siliconchip.com.au
and one wire from the positive output
of the battery charging module.
If it has three terminals, make sure
to connect those wires to two adjacent
terminals. This way, the circuit will
be completed with the switch slid to
that end.
Now we need to complete the enclosure. I used screws to fix the lid in
place. I had already made screw holes
in the design, so that was easy. Just
make sure that the cover is securely
in place so it looks professional and
is convenient to carry. I have put my
logo on the lid design to give it a more
aesthetic and customised look.
After closing it up, all that’s left is
to program the Arduino.
Programming
We need to upload some code to
our Pocket Weather Station. Without
code in the Arduino, our device is just
a plastic box with no functionality.
First, download my Arduino sketch
from the Silicon Chip website. It is
a zipped directory containing a file
with a .ino file extension. Unzip the
package, install the latest Arduino IDE
(integrated development environment)
and open the .ino file.
If you wish to, you can get your
hands dirty and write the code yourself. But if you’re a beginner (and even
if you aren’t), it’s best to start with my
version since we know it works. You
can always modify it once you get it
working. See the panel if you are interested in how the software works; that
information could come in handy if
you plan to make changes to it.
Once you have the code open in the
Arduino IDE, plug the Arduino Nano
into your computer’s USB port (don’t
plug into the USB charger port as it
does not pass data to the Arduino).
Then press CTRL+U (or select Sketch
→ Upload) to compile the code and
load it into the Arduino.
Check the output at the bottom of
the window for error messages. Compilation takes a few seconds, and if it
finds a problem with your code, it will
tell you there. Otherwise, you should
get an “Upload successful” message,
and your Pocket Weather Station will
be fully operational.
Don’t forget to charge the cell (via
the other USB port) so it is ready for
use. The cell charge lasts quite a long
time, so you will barely need to charge
it. Now, you can proudly carry the
device wherever you go and flaunt
siliconchip.com.au
Parts List – Pocket Weather Station
1 Arduino Nano or equivalent board
1 USB cable, to suit the Nano
1 DHT11 temperature sensor module
1 0.96in OLED screen with I2C interface and SSD1306 controller
1 TP4056 li-ion battery charging module (Silicon Chip Cat SC4305)
1 small 1S LiPo cell (eg, 160mAh)
1 slide switch
1 set of 3D printed case pieces (optional)
6 small self-tapping screws (two for mounting the switch, four for the lid)
various lengths of light-duty hookup wire
How the software works
The software for this project is relatively simple. Don’t be daunted by the length
of the code; half of it is simply the bitmap graphics for the splash screen!
The first few lines include all the libraries we will need: the graphics libraries, humidity/temperature sensor interface library, fonts etc. It then creates
the object to communicate with the DHT temperature sensor using pin D4 and
another object to drive the screen with a resolution of 128x64 pixels.
Following this is the logo bitmap, then below that the main body of the code,
which comprises three functions: setup() (for initialisation), loop() (the part
which runs continuously after setup) and testdrawbitmap(), which draws the
logo on the screen.
The setup() function starts the serial port and DHT temperature sensor
communications, then initialises the display, draws the logo and pauses for
one second. Once the setup() routine has finished (ie, after that one-second
delay with the logo on the screen), the loop() function is repeatedly called as
long as the unit has power.
Each time the loop() function runs, it starts by acquiring temperature and
humidity readings from the DHT11 sensor, then prints that data to the serial
console. It follows by clearing the screen, then printing the same information
on that screen, including what the temperature ‘feels like’ based on the combination of temperature and humidity. It then pauses for two seconds before
the process repeats.
As this code is all relatively straightforward, you should be able to modify it
(eg, to change the way the readings are displayed on the screen) should you
wish to do so.
your creation (or maybe actually use
it as a weather station).
Troubleshooting
If you are here, that probably means
that you have built the project, and
it didn’t work. Don’t worry, you will
get it working and you will learn a lot
from troubleshooting it:
1. The OLED screen is blank
You might have damaged your
OLED display due to an incorrect connection, but more likely, you haven’t
connected the signal wires properly,
so re-check them.
There might also be an error in your
code (for example, if you have forgotten to initialise the display). Try using
my code first as we know it works,
then modify it from there once you
it working.
Australia’s electronics magazine
2. All readings are “NA”
This will happen if it can’t communicate with the temperature sensor. You might have a problem with
the connection between the temperature sensor to the Arduino board. Just
re-check the connections. If they are
correct, you might have a problem
with the sensor itself; try replacing it.
3. It works when the USB cable is
plugged in, but not from the battery
If this happens, there is a problem
with your battery or perhaps the connections between the battery and the
rest of the circuit.
Links
This project on the Instructables
website: siliconchip.com.au/link/ab9r
This project on the HackSpace website: siliconchip.com.au/link/ab9s SC
November 2021 59
|