This is only a preview of the December 2024 issue of Silicon Chip. You can view 40 of the 112 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 "Capacitor Discharger":
Articles in this series:
Items relevant to "Compact HiFi Headphone Amp":
Articles in this series:
Items relevant to "WiFi weather logger":
Items relevant to "The Pico Computer":
Items relevant to "Variable Speed Drive Mk2, Part 2":
Purchase a printed copy of this issue for $13.00. |
SILICON CHIP
Mini Projects #016 – by Tim Blythman
WiFi Weather
Logger
This simple but incredibly useful project can put the
weather at your fingertips. It monitors and logs temperature
and humidity. You can download the logs and see all the
important statistics from a web browser on any device
connected to your WiFi network.
Y
ou can buy all manner of wireless
weather stations but this one is
simple and easy to build. Because it’s
programmed using the Arduino IDE,
you can customise it as you wish.
The hardware assembly is simple
as it consists of just three pluggable
boards. You might need to do some
soldering if the headers are not already
attached when you buy them, but that’s
about it.
We’re using a WiFi Mini board,
which sports an ESP8266 processor.
A module based on the DHT11 sensor
measures the temperature and humidity. Finally, a microSD card module is
used to save the data.
Fig.1 shows the circuit for the Logger, with the three boxes showing the
contents of each of the peripheral modules. The WiFi Mini board has a few
niceties that aren’t shown, such as a
USB-serial converter and voltage regulator, while the other modules are
quite minimal.
The processor on the WiFi Mini
board connects to the DHT11 sensor
using its D4 digital input/output pin.
It uses a simple bidirectional one-wire
protocol, so only one pin is needed,
along with the included 5.1kW pullup
resistor. You’ll note that the onboard
LED of the WiFi Mini also uses the D4
pin. It doesn’t interfere, and we know
communication is occurring when the
LED flashes.
The SPI pins of the WiFi Mini board
connect to their respective pins on the
microSD card socket.
siliconchip.com.au
If you don’t have the exact DHT11
module or microSD card shield, then
you should be able to work out the
connections using Fig.1.
The software library we are using
also supports the similar DHT22 sensors without requiring any changes.
However, note that we have not tested
this.
Construction
Ensure that the three boards are fitted with suitable headers. We used
stackable headers on all of them for
flexibility, but you could use male or
female headers for some to make the
stack more compact. Simply plug the
boards together, being sure to match
their orientation to our photos!
We placed the DHT module at the
bottom so it wouldn’t be affected by
any heat rising from boards below it.
We put the WiFi Mini board at the top
to keep it free from radio interference,
meaning the microSD card module
ended up in the middle.
If you don’t have the shields, a
breadboard or prototyping board
might help to make the connections,
although you might need a few jumper
wires to complete the circuitry.
Fit a microSD card to the socket,
Fig.1: the circuit consists of three shield boards that we plugged together,
although you could use different modules/components and jumper wires if you
already have them. The coloured boxes show the contents of the two peripheral
boards and how they connect to the processor board.
Australia's electronics magazine
December 2024 59
freshly FAT-formatted if possible.
FAT16 and FAT32 are supported;
usually, FAT16 is used for cards up
to 2GB. The fewer files on the card,
the less processing the WiFi Mini will
have to do to read it. The Logger generates less than 1MB of data per year,
so even a low-capacity card should
be sufficient.
Parts List – Weather Logger (JMP016)
1 WiFi Mini ESP8266 Main Board (MOD1) [Jaycar XC3802]
1 microSD card shield (MOD2) [Jaycar XC3852]
1 DHT11 temperature and humidity shield (MOD3) [Jaycar XC3856]
1 FAT-formatted microSD card
1 micro USB cable for programming and power
The WiFi Weather Logger uses just these three modules, a microSD card and
a micro USB cable.
Add http://arduino.esp8266.com/
stable/package_esp8266com_index.
json to the Additional Board Manager
URLs list, then search for and install
“esp8266” from the Board Manager.
You’ll also need the DHTNEW
library. We’ve included a copy of version 4.3.1 (the one we used) in the software download package at siliconchip.
au/Shop/6/512
You can also search for DHTNEW
in the Library Manager to install the
library named DHTNEW, or download
it from https://github.com/RobTillaart/
DHTNEW
If you haven’t used the WiFi Mini
before, your computer may need drivers. These can be found in the download section of the Jaycar WiFi Mini
product page at www.jaycar.com.au/p/
XC3802
Open the WIFI_WEATHER_LOGGER sketch from the software download package. You will have to edit
the sketch to include your WiFi name
(SSID) and password, which are set by
#defines at the very start of the sketch.
The NORMAL_OFFSET #define can
be altered to set your local timezone
offset in minutes. The default of 600
minutes (+10 hours) is correct for Sydney, Melbourne, Hobart and Canberra.
You can see these in Screen 1.
Select the serial port of the WiFi
Mini and choose “D1 R2 & Mini” for
the board type, then upload the sketch
to the board. When this completes,
open the serial monitor at 115,200
baud and check that everything is
working as expected, as shown in
Screen 2.
The WiFi Mini will reboot after 30
seconds if it does not successfully connect to WiFi. Otherwise, it will report
its progress in initialising the hardware. Typing ‘~’ followed by Enter in
the Serial Monitor will run the card
contents listing seen at the bottom of
Screen 2.
If you have a problem, trying resetting the WiFi Mini with its RESET button. Check that the card is correctly
inserted if it is giving an error. Typing ‘s’ followed by Enter in the Serial
Monitor will show its status, while
Australia's electronics magazine
siliconchip.com.au
Software
The Logger’s software will connect
to the internet and fetch the time using
NTP (network time protocol). It will
then get temperature and humidity
data from the DHT11 sensor hourly
and log them to the microSD card. It
also presents an HTTP server that can
be used to check the status and download data using a web browser.
You’ll need to install the Arduino
IDE (if you don’t already have it, you
can download it from siliconchip.au/
link/aatq) and the ESP8266 processor
board add-on. The add-on is installed
from the Preferences menu of the IDE.
Screen 1: make sure to update your WiFi network settings here so that the
Logger can connect to your WiFi network. Adjust the time zone offset (in
minutes) relative to UTC to suit your location.
Connecting to Tim.
................
Connected! IP address: 192.168.xxx.xxx
Getting time from NTP
sending NTP packet...
48 bytes received.
NTP is 0xEA5C1453
Time is 13:17:39 on 06/08/2024 (local time)
SD card initialised
Root directory found
STATUS: IP=192.168.xxx.xxx, Card OK, NTP OK
Card listing:
0
System Volume Information
[FOLDER]
1
202404.csv
29541 bytes
2
202405.csv
30525 bytes
3
202406.csv
29541 bytes
4
202407.csv
30525 bytes
5
202408.csv
5516 bytes
Screen 2: The Arduino Serial Monitor should show something like this if all is
working well. The serial port is set to 115,200 baud.
60
Silicon Chip
typing a number followed by Enter (as
per listing on Screen 2) will show the
corresponding file contents.
If you see the LED flashing briefly,
about once every two seconds, most
likely everything is working as
expected. If you have the necessary
experience, you can modify the Arduino software to collect and log other
data.
Web interface
Note down the IP address from the
Screen 2 status report and type that
into a web browser’s address bar. This
will only be accessible from your local
network (eg, devices that are on the
same WiFi network).
This should show a web page like
the one shown in Screen 3. Your values and the files may be different.
Check that the time is correct and
that you are getting reasonable readings for temperature and humidity.
You can refresh the page to get the
latest data.
The Logger will record data to the
microSD card once per hour, on the
hour, so let it run for a while to accrue
some data. After that, refresh the page
and see that you can download the
CSV data files by clicking on the links.
One file is generated for each month;
each will grow to about 30kB.
Screen 3: the Logger’s web page shows the current status and lists any files that
can be downloaded from the microSD card.
CSV files
You can open the CSV files in a
spreadsheet program like Excel or
LibreOffice Calc. The leftmost column
is a so-called ‘date serial number’. If
you change this column to a date or
time format, it will show as such and
should match the date and time text
in the second column.
You can see this in Screen 4, along
with the actual temperature and
humidity readings, which can now be
charted or converted to another data
format as needed.
Completion
You can now install the Logger in its
final location. You’ll need power, and
you should make sure that the Logger
and its wiring are protected from the
sun and rain if it is outside.
The shelter used to protect meteorological instruments is called a Stevenson screen (instrument shelter). We
had no trouble finding versions online
that could be 3D-printed. Otherwise,
an inverted plastic container should
do the trick.
SC
siliconchip.com.au
Screen 4: CSV files from the Logger can be viewed in a spreadsheet program.
You can change the format of column A to a suitable date or time format.
Australia's electronics magazine
December 2024 61
|