This is only a preview of the April 2025 issue of Silicon Chip. You can view 45 of the 104 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. Items relevant to "Discrete 555 timer":
Items relevant to "The Pico 2 Computer":
Articles in this series:
Items relevant to "Weather monitor":
Articles in this series:
Articles in this series:
Items relevant to "Rotating Light for Models":
Articles in this series:
Items relevant to "433MHz Transmitter Module":
Items relevant to "Power LCR Meter, Part 2":
Purchase a printed copy of this issue for $13.00. |
Mini Projects #025 – by Tim Blythman
SILICON CHIP
Weather
Monitor
Our WiFi Weather Logger Mini Project from
last December has been handy for keeping
track of temperature and humidity. However,
it isn’t always convenient to use a computer to
check on its status. This Mini Project that makes it easy to monitor
the Logger’s temperature and humidity without needing to open up a web browser.
T
he WiFi Weather Logger Mini Project (December 2024; siliconchip.
au/Article/17315) is a compact unit
consisting of a WiFi Mini processor
module, a DHT11 temperature and
humidity sensor and board that interfaces to a microSD card.
It monitors the temperature and
humidity by reading the sensor and
makes that data available as a web page
via WiFi. It also records the data to the
card, and that data can be downloaded
as a simple yet flexible CSV (comma
separated variable) file.
CSV files can be opened by many
spreadsheet programs, so it is easy
to analyse the data and create charts
and the like.
We often found ourselves using the
interface to simply check the temperature and humidity. That means
opening up the web page on a computer or smartphone screen and viewing the data. It is not difficult, but we
realised that it would not take much
hardware to create a simple, standalone monitor.
The result is this Weather Monitor.
It consists of an Arduino Uno R4 WiFi
board attached to a liquid crystal display (LCD) shield to provide a clear
and simple readout of the current temperature and humidity.
Since the Weather Logger keeps
track of time, the Weather Monitor
can also display that time. Handily,
Hardware
The hardware is little more than an
Uno R4 WiFi with an XC4630 Colour
LCD Shield plugged into it. You’ll also
need a suitable USB-C cable to power
the Monitor, since the Uno R4 WiFi
has a USB-C socket.
Screen 2:
you need to
edit the WiFi
network
security
settings (SSID
and password)
and set the
IP address
of the Logger
so that the
Monitor can
communicate
with it. You
can also
change the
colour scheme
at the same
time.
Screen 1: the WiFi Weather Logger
serves up a web page that looks like
this. By looking for key character
sequences, the Monitor can extract
the information to reformat it for its
screen.
siliconchip.com.au
the Monitor also displays the status
of the Logger, so you can quickly see
if it is having problems, such as an SD
card problem or lost WiFi connection.
The Uno R4 WiFi is much more
powerful than the older R3 Uno, so
this simple combination of hardware
could have many other handy uses,
as a simple internet-connected display device.
Australia's electronics magazine
April 2025 45
The LCD Shield just plugs into the
headers for the Uno R4 WiFi. The stack
is around 20mm deep, and the two
boards are about the same width. Thus,
the assembled stack will rest neatly on
its edge, as you can see in our photo.
The orientation we have chosen
allows the USB cable to attach near
the Monitor’s lower edge (on the righthand side), meaning the cable does not
hang awkwardly. This can be changed
if you like.
Software
Web pages are requested and
received using the hypertext transfer
protocol (HTTP). The WiFi Weather
Logger works as an HTTP server, offering web pages via its WiFi interface.
Thus, the Weather Monitor needs to
use an HTTP client to access those
web pages.
Interestingly, it’s a lot easier to write
an HTTP server program than an HTTP
client with the Arduino IDE. That’s
because there are Arduino libraries for
creating HTTP servers, included with
most WiFi-capable board profiles. So
implementing an HTTP server is easy
to do with the Arduino IDE.
Downloadable HTTP client libraries
exist, but a client must handle all the
possible server options, while a server
gets to choose which options it offers.
Also, a client may have to deal with
a large amount of data if the server
delivers a large file.
Because of this complexity, our
Monitor software has been specifically
written to handle the server protocols
used by the Logger. It should work fine
if you want to customise the software
to work with other Arduino HTTP
servers, but it may not work with other
server types.
The software connects to a pre-
programmed WiFi network and
attempts to download the web page
from the Logger using its IP address.
This means you should ideally set
your router to allocate the Logger a
fixed IP address. This might be called
something like address reservation in
your router settings.
Otherwise, you might find your
router allocates a different IP address
to the Logger at some point and the
Monitor can’t find it. This could happen if, say, the power goes off, or the
router is reset.
The Logger and Monitor must be on
the same network, such as the same
home WiFi network. There are ways
to make the Logger accessible from
the wider internet, but these are well
beyond the scope of this article as they
require a good knowledge of network
security principles.
When the Monitor downloads the
web page, it scans the contents for key
sequences to locate necessary information. For example, once it finds the
text “Temp: ”, it knows that the temperature reported by the Logger will
follow. Screen 1 shows a typical page
served up by the Logger.
The web page is a HTML (hypertext markup language) document that
Parts List – Weather Monitor (JMP025)
1 assembled WiFi Weather Logger (see our December 2024 issue)
1 Arduino R4 Uno WiFi main board [Jaycar XC9211]
1 2.5in colour LCD shield [Jaycar XC4630]
1 USB-C cable to suit the Arduino Uno R4 WiFi [Jaycar WC7900]
Screen 3: the Serial Monitor output
should look like this for a normal
startup. We found that our unit took
up to 20 seconds to connect to a WiFi
network (when it waits to receive the
IP address), plus another five seconds
to access the web page.
contains so-called tags that are not
visible in a web browser, although
they change how the web page is rendered on the screen. For example, the
title is extracted by looking for the
“<title>” tag.
Apart from the raw information on
the page, the Monitor also records a
timestamp (using its internal milliseconds counter) of when the web page
was retrieved. From that information,
it can show an updating time display
without having to continually load
data from the Logger.
The Monitor tries to load a page
from the Logger every minute, and
updates its displayed information
when it does so; the time and date display is updated continuously. If there
have been no successful updates for an
hour, the screen reports this instead of
repeating stale data.
Assembly for this project is literally plug and play! The shield
simply plugs into the main board and then it is ready for
programming.
46
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
Screen 4: while starting up, you will see a screen like this
on the LCD. It also might appear if the Logger is offline and
the Monitor can’t communicate with it.
While the display shield has a
touch sensor, we do not use it. It’s
easy enough to display all the available information, so there are no selections that need to be made. The WiFi
interface is also blocking, meaning that
whenever it is busy, we wouldn’t be
able to check for a touch input anyway.
Uno R4 board profile
Assuming you have completed construction by plugging the LCD shield
into the Uno R4 WiFi board, you can
start the programming process. You
will need the Arduino IDE with the
Uno R4 Boards profile installed. The
sketch itself includes some library
files, but there are no external libraries needed. The Arduino IDE can be
downloaded from www.arduino.cc/
en/software
To install the Uno R4 Board profile,
open the Boards Manager, search for
“R4” and install the “Arduino Uno R4
Boards by Arduino” option. We used
version 1.3.2; other versions should
work fine, but if you have problems
with the sketch compiling, try changing to this version.
Programming
There are some customisations
that you will need to apply to the
sketch before uploading it. Open
the WEATHER_LOGGER_MONITOR
sketch and switch to the WEATHER_
LOGGER_MONITOR.ino tab, as
shown in Screen 2.
Lines 2, 3 and 4 contain the WiFi
network settings and IP address of the
Weather Logger (which you should
have built previously). Change these
siliconchip.com.au
Screen 5: if you see this screen then all is well. The remote
temperature, humidity and time are reported; the time is
kept current using an internal timer on the Uno R4 WiFi.
to suit your network and the Weather
Logger that is connected to it.
You can set the display’s colour
scheme on lines 14 and 15. FGC is the
foreground (text) colour, while BGC is
the background. BLACK, WHITE, RED,
BLUE, GREEN, CYAN, MAGENTA,
YELLOW and GREY are available
#defines that are set in the XC4630d.c
file; you can also use 16-bit RRRRRGGGGGGBBBBB format colour values.
Lines 8-11 of the XC4630d.c file also
set the version of the XC4630 LCD
shield; the most recent V4 is enabled
(by not being commented out with
“//”). If you find this version does
not work, you can try the other versions. You can flip the orientation of
the display by changing the command
XC4630_rotate(4) to XC4630_rotate(2)
in the setup() function.
After these changes, the sketch is
ready to upload. Make sure to choose
the Uno R4 WiFi board and its correct
serial port (eg, COM port on Windows).
Open the serial monitor to 115,200
baud and be ready to view the startup
messages as seen in Screen 3. If the
Monitor does not connect to the WiFi
network within 30 seconds, it will
reset itself to try again.
We found that even with the correct settings, the Monitor sometimes
failed to access the Logger’s web page.
You can either wait 60 seconds for it
to try again or use the reset button on
the Uno R4 WiFi. The LCD should
show information similar to that in
Screens 4 & 5, depending on its phase
of operation.
The software can be downloaded
from siliconchip.au/Shop/6/1836
Australia's electronics magazine
You can see a video of the Weather
Monitor booting up and then displaying the weather & time at siliconchip.
au/Videos/Weather+Monitor
Summary
If you see something like Screen
5, then everything is working as
expected. The status line at the bottom
of the page will report when the Monitor is trying to download fresh data,
while the clock may occasionally stall
for a few seconds due to the blocking
nature of the WiFi interface.
We considered adding charts to
the Monitor by having it download
the CSV files from the Logger, but the
amount of RAM on the Uno R4 WiFi
is not enough to allow this.
If you are a dab hand with Arduino,
you might like to try customising the
Logger or Monitor sketches to report
different data. Changing the title of
the Logger’s web page, for example,
should change the title displayed on
SC
the Monitor.
This Weather
Monitor uses
a wireless
connection to
our previous
WiFi
Weather
Logger to
collect data.
The Logger
is built
using just
an ESP8266,
DHT11 and
microSD
card shields.
April 2025 47
|