Setting up a weather station (by Martin Lörcks)

Setting up a weather station

Welcome to this guide to building your own weather station! In this project, we will build a fully functional weather station step by step, as we did in the

vetskilling.

With this weather station you can measure different weather conditions, such as ...

  • Temperature,
  • humidity,
  • air pressure,
  • air quality and
  • air quality.

measure.

The aim of this project is not only to give you an insight into how a weather station works, but also to develop your technical skills in electronics, programming and data analysis.

We start by collecting the required materials and then assemble and program the weather station step by step.Welcome to this guide to building your own weather station! In this project, we will build a fully functional weather station step by step, as we did in the

Erasmus+ project vetskilling.

With this weather station you can measure different weather conditions, such as ...

  • Temperature,
  • humidity,
  • air pressure,
  • air quality and
  • air quality.

measure.

The aim of this project is not only to give you an insight into how a weather station works, but also to develop your technical skills in electronics, programming and data analysis.

We start by collecting the required materials and then assemble and program the weather station step by step.

 

What is a weather station

A weather station measures various meteorological data in order to monitor and predict the weather. Among other things, it records temperature, humidity, air pressure, wind speed and direction as well as precipitation. This data is collected by sensors and often transmitted in real time to weather services or end users to improve weather forecasts or monitor local weather conditions. Weather stations can be either manually operated or automated and are used in agriculture, environmental monitoring or in the private sector.
 

Aim of the project

The aim of the vetskilling project is to install small, simple weather stations at many schools in Europe and send the weather data to a shared server via the Internet. The weather data from the individual weather stations is displayed on a website, allowing the weather at many locations in Europe to be viewed live.

 

 

 

Which weather data is measured

The following data is measured with the two sensors BME 280 and ENS160:

  • Air temperature
  • Air humidity
  • Air pressure
  • Air quality
  • Equivalent carbon dioxide content
  • eCO2
  • Volatile organic compounds in the air
  • TVOC

 

 

 

Materials required

List of required materials

Materials required:

  • one Raspberry Pi Pico (H) with Baseshield

+ =

  • one BME280 sensor ...

.. for measuring air temperature, humidity and air pressure

  • one ENS160 sensor ....

.. for measuring the air quality (AQI), equivalent CO2 value, ...

  • Lora-E5 module ...

. for sending measurement data via radio

  • batteries

.. for the power supply of the weather station

  • TPL5111 Nano Board

.. to save energy

  • Housing

... to protect the electronics and for hanging up

  • Plastic plate + screws

+

... for mounting the components in the housing (plate: 160mm x 56mm x 3 ~ 5mm)

 

  • Cable for connecting the sensors and the baseshield

 

Materials required:

  • one Raspberry Pi Pico (H) with Baseshield

+ =

  • one BME280 sensor ...

. .. for measuring air temperature, humidity and air pressure

  • one ENS160 sensor ....

. .. for measuring the air quality (AQI), equivalent CO2 value, ...

  • Lora-E5 module ...

.. . for sending measurement data via radio

  • batteries

. .. for the power supply of the weather station

  • TPL5111 Nano Board

. .. to save energy

  • Housing

... to protect the electronics and for hanging up

  • Plastic plate + screws

+

... for mounting the components in the housing (plate: 160mm x 56mm x 3 ~ 5mm)

 

  • Cable for connecting the sensors and the baseshield

or

 

 

 

Tools

The following materials / tools are also required to set up the weather station:

  • a computer with the Thonny software for programming the Rasperry Pi Pico (H)

 

+ =

 

 

  • additional tools, such as a soldering station or pliers

 

                

 

 

Software requirements

A computer with the Thonny software environment is required to program the Rasperry Pi Pico (H).

 

+ =

 

 

Access to the THE THINGS NETWORK is required to transmit the measurement data via radio.

This is a LoRaWAN network that enables local measurement data to be sent wirelessly to a server and retrieved from there via the Internet.

 

 

Step-by-step instructions

Step 1: Install software

Installing the programming environment

The Raspberry Pi Pico (H) can be programmed in various programming environments (IDEs).

A very well-known and widely used programming environment is the Arduino IDE.

In this project, we will program the Raspberry Pi Pico (H) in MircoPython.

The Thonny development environment is ideal for this.

It can be found on the website:

https://thonny.org/

for different computers.

For Thonny to work properly, the programming language Python must be installed on the computer.

 

 

Preparation of the Raspberry Pi Pico (H)

In order to program the Raspberry Pi Pico (H) in MicroPython, the compiler must be flashed to the Raspberry Pi Pico (H).

You can do this using the Thonny IDE or download the corresponding firmware file .uf2 from the download page

https://micropython.org/download/RPI_PICO/

download.

 

 

Step 2: Preparing the components

Connecting the sensors


The first step is to connect the two sensors to the Raspberry Pi Pico (H). Both sensors use the I2C protocol and can therefore be connected very easily.

 

The simplest way to connect the two sensors is with a qwicc cable, as shown in the following picture.

Alternatively, the connection can also be soldered. To do this, we solder connecting cables between the contact points of the two circuit boards:

  • VIN - positive power supply
  • GND - Ground (negative power supply)
  • SCK - Clock signal of the I2C bus
  • SDI - data signal of the I2C bus

 

The connection to the Baseshield can be made using a qwicc Grove adapter cable.

Alternatively, this connection can also be soldered if we cut off the plug at one end of a Grove cable and solder the cable on like a sensor board:

  • VIN - red cable
  • GND - black cable
  • SCK - yellow cable
  • SDI - yellow cable

The sensors can be plugged into the following connections on the base shield:

Anschließen der Sensoren


Im ersten Schritt schließen wir die beiden Sensoren an den Raspberry Pi Pico (H) an. Beiden Sensoren benutzen das I2C-Protokoll und können somit sehr einfach angeschlossen werden.

 

Die einfachste Verbindung der beiden Sensoren geschieht,  wie im folgenden Bild dargestellt mit einem qwicc-Kabel.

Alternativ kann die Verbindung auch gelötet werden. Dazu löten wir Verbindungsleitungen zwischen die Kontaktepunkte der beiden Platinen:

  • VIN - positive Spannungsversorgung
  • GND - Ground (negative Spannungsversorgung)
  • SCK - Clocksignal des I2C-Buses
  • SDI - Datensignal des I2C-Buses

 

Die Verbindung mit dem Baseshield kann mittels einem qwicc-Grove-Adaperkabel erfolgen.

Alternativ kann auch diese Verbindung gelötet werden, wenn wir an einem Ende eines Grove-Kabels den Stecker abschneiden und das Kabel wie eine Sensorplatine anlöten:

  • VIN - rotes Kabel
  • GND - schwarzes Kabel
  • SCK - gelbes Kabel
  • SDI - gelbes Kabel

Am Baseshield können die Sensoren an folgende Anschlüsse eingesteckt werden:

Software test of the sensors

We can easily check the correct connection of the sensors to the Raspberry Pi Pico (H) by searching the I2C bus.

If the Raspberry Pi Pico (H) finds sensors on the I2C bus, the program outputs the corresponding device addresses.

The BME280 sensor has the addresses 0x76 or 0x77.

The ENS160 sensor has the addresses 0x52 or 0x53.

 

If the Raspberry Pi Pico (H) does not find any sensors on the I2C bus, this is also output by the program.

A common mistake is to mix up the SCK and SDI cables!

 

Connection of the LoRaWAN radio module

A LoRaWAN radio module is connected to the serial port of the Raspberry Pi Pico (H) to transmit the measurement data. With this radio technology, data can be sent over a greater range and with lower power consumption than with WLAN, for example.

The radio module is programmed via the serial interface using AT commands.

A description of the individual commands can be found in the Lora-E5 command specification.

 

 

 

 

Power consumption of the radio module

The power consumption of the radio module is by far the highest for the weather station. It therefore makes sense to keep the transmission and reception time as short as possible.

You should therefore think carefully in advance about what you send and how often!

Power consumption of the radio module

The power consumption of the radio module is by far the highest for the weather station. It therefore makes sense to keep the transmission and reception time as short as possible.

You should therefore think carefully in advance about what you send and how often!

 

 

Preparation of the timer board

A TPL5111 board from Adafruit is installed to save energy. After a measurement has been carried out and sent via radio, the Raspberry Pi Pico (H) sends a signal to the TPL5111 board. This then switches off the power supply for a set time. After this time has elapsed, the TPL5111 board switches the power supply back on and a new measurement is carried out.

In order for the control between the Raspberry Pi Pico (H) and the TPL5111 board to work, the two parts must be connected as follows:

 

TPL5111 board   ->   Rasberry Pi Pico (H)   cable color
VDD   ->   VSYS (PIN 39)   red
GND   ->   GND (PIN 38)   black
delay   ->   not connected    
ENout   ->   3V3EN (PIN 37)   orange
DONE   ->   I/O-PIN (PIN 34)   brown

 

The adjustable resistor can be used to change the time for which the TPL5111 board interrupts the power supply.

To make it easy to set the switch-off time, Texas Instruments (manufacturer of the TPL module) provides the following information in the data sheet:

The resistance can be measured between the DELAY and GND connections on the TPL5111 board.

 

The battery connections (+) and (-) can be soldered to the back of the TPL5111 board.

 

 

 

 

 

 

Step 3: Assembling the weather station

To assemble the weather station, the individual components are screwed onto the plastic plate.

Front page

 

Rear side

 

When mounting, make sure that deep elements such as the Raspberry Pi Pico (H) and the batteries are mounted on the front.

To assemble the weather station, the individual components are screwed onto the plastic plate.

Front page

 

Rear side

 

When mounting, make sure that deep elements such as the Raspberry Pi Pico (H) and the batteries are mounted on the front.

 

 

Once the weather station has been assembled, we can carry out a first comprehensive test. To do this, we load the Micropython program

  • Sensortest_BME280_ENS160.py

and the corresponding libraries

  • PiicoDev_BME280.py
  • PiicoDev_ENS160.py
  • PiicoDev_Unified.py

on the Raspberry Pi Pico (H) and start it.

If everything is wired correctly, current sensor data will appear in the output every five seconds.

 

 

 

 

 

But not only the data from the sensors is sent by radio, but also a country/city ID and which weather station it is! Each school can operate several small weather stations.

As already mentioned in the description of the radio module, an attempt is made to make the data to be transmitted as small as possible due to the energy consumption of the radio module.

The sensor data is therefore processed before it is sent, for example the commas are removed from the sensor data.

Finally, all the data is combined into one large string variable and passed to the radio module for sending.

 

The following image shows how the Raspberry Pi Pico (H) processes the data and finally forwards it to the radio module as a string variable.

The Cleaned Data is the data string that the radio module sends to the TTN.

Here as an example starting with

  • 2 as the country code Germany,
  • 1 as identification of the first weather station
  • 11843 Temperature value without dot
  • the other sensor values (air pressure, humidity, ...)

 

 

 

 

The Things Network

TTN - The Things Network

The Things Network (TTN) is a global, free wireless network based on the LoRa wireless standard. One of its aims is to provide all interested parties with an infrastructure for IoT applications without them having to invest a great deal of hardware themselves.

In many cases, it is sufficient to have a TTN gateway, i.e. a base station, within range. This receives the data to be measured and forwards it independently to a TTN server. From there, the measurement data can be accessed worldwide via the Internet.

If no gateway is available, you can install one yourself and thus increase TTN's coverage.

 

You can find out whether a TTN gateway is available in your area via the website:

 

https://ttnmapper.org/

to find out.

 

As this project involves collecting weather data from many different vocational schools in numerous European cities, it made sense to include TTN in the data transfer.

 

 

 

 

Step 4: Log in to TheThingsNetwork

To send and receive sensor data via the TTN, you must register once with the TTN and create an account.

https://www.thethingsnetwork.org/

A valid e-mail address is required for free registration. During the registration process, you create your own user name and password.

 

 

Create application

DO NOT CREATE A NEW APPLICATION YOURSELF. FOR THIS STEP CONTACT MARTIN LÖRCKS TO JOIN THE "SHARED APPLICATION". WE USE THIS FOR COLLECTING THE DATA! SKIP THE TEXT BELOW!

In order to receive data via the TTN, you must first create an application and then assign the physical device that sends the data to it.

 

To do this, press the +Add button at the top and select that you want to create a new application. In the following window, give the application a meaningful name.

 

 

Click on the Create application button at the bottom to create the application and add new devices.In order to receive data via the TTN, you must first create an application and then assign the physical device that sends the data to it.

 

To do this, press the +Add button at the top and select that you want to create a new application. In the following window, give the application a meaningful name.

 

 

Click on the Create application button at the bottom to create the application and add new devices.

 

New device - Register weather station

You can now add physical devices, e.g. our weather station, to the created application. To do this, click on the + Register end device button in the middle of the window.

 

 

In the following window, we select to enter the end device manually:

 

The manufacturer has already stored a JoinEUI with additional IDs in the module. With a simple AT command (see LoRa-E5 AT command specification), we can read them out of the module and change them if necessary!

 

 

 

 

 

 

 

 

 

 

With the JoinEUI read out, then entered and activated, the DevEUI read out at the same time is entered directly afterwards.

After entering the DevEUI, an AppKey is generated. This key, generated in the TTN, is later entered in the Raspberry Pi Pico (H) program and is used to authenticate that the weather station is allowed to send data to the TTN.

It is therefore important to copy or make a note of the AppKey!!!

After entering an End Device ID, the device / weather station can be registered in the TTN.

 

 

 

Testing the weather station

In order for the weather station to authenticate itself to the TTN, the generated AppKey must be entered in the main.py program of the Raspberry Pi Pico (H).

 

Once this has been done, you can test whether data is being transmitted from the weather station to the TTN .In order for the weather station to authenticate itself to the TTN, the generated AppKey must be entered in the main.py program of the Raspberry Pi Pico (H).

 

Once this has been done, you can test whether data is being transmitted from the weather station to the TTN .

 

If the weather station has sent sensor data to the TTN, you can log in to TTN and see in the application window whether the data has been received.

 

 

The Forward uplink data message lines show the data received.

If the weather station has sent sensor data to the TTN, you can log in to TTN and see in the application window whether the data has been received.

 

 

The Forward uplink data message lines show the data received.

 

 

Decode data at TTN

It is not possible to read directly from the data received where it comes from or what the temperature was at that location. The data must first be decoded.

 

To do this, the Payload formatters item must be selected on the left-hand side of the TTN application.

We then select the UPLINK item, as we want to decode the data that we receive.

 

 

The data packet from the Raspberry Pi Pico (H) was converted into a string variable (character) for sending. In order to generate a decimal number from the transmitted data stream, we have to convert the characters from the individual data bytes back into decimal numbers.

We can now program the decoder by comparing the transmitted data and the data received in the TTN.

Transmitted data:

Received data:

 

Comparison:

  • Sent: 2 (decimal)
  • Received: 32 (hexadecimal)

 

A possible decoding can now be carried out with the aid of an ASCII table.

A 32 in hexadecimal notation is a 50 in decimal notation.

To get from 50 to 2, we now subtract 48.

Using this procedure, we now process all bytes of the received data packet.

Furthermore, we divide the data packet back into the previously known structure

  • country code
  • Weather station number
  • and then the sensor data

on.

 

 

Using the decoder

In order to read the received data in TTN directly, we can also use the decoder directly within the TTN application.

To do this, we copy the created decoder ...

 

and add it to the application

  • select End Devices on the left and then
  • above Payload formatters.

in the Formatter code field.

 

To test it, we can insert the byte stream we have received and test the decoder.

 

Congratulations - your weather station is ready and is sending data to TheThingsNetwork!

 

In further tutorials we will show you how to retrieve the data from there and process it graphically!

 

Thingsboard step by step

As part of this project, each team will create their own interactive dashboard to visualize weather station data using ThingsBoard, a powerful open-source IoT platform for data collection, processing, visualization, and device management.

 

Open the manual

 

 

Testplan Weatherstation

Conclusion

What has been achieved?

Congratulations - your weather station is now ready and sending data to TheThingsNetwork!

 

In further tutorials we will show you how to retrieve the data from there and process it graphically!

 

What have we achieved?

  • we have successfully connected the electronic components of a weather station - microcontroller, sensors and a radio module
  • we programmed the microcontroller, a Raspberry Pi Pico (H), to read the sensors, process the data and forward it to a radio module
  • we have successfully registered with TheThingsNetwork (TTN), created an application and added our weather station
  • we have written a decoder for the TTN to display our data in a readable form again

 

 

Possible extensions

There are now many interesting ways to expand the weather station.

For example, you can equip the power supply with a small solar module or add further sensors for rain or wind speed.

Just give it a try ....There are now many interesting ways to expand the weather station.

For example, you can equip the power supply with a small solar module or add further sensors for rain or wind speed.

Just give it a try ....

 

  • Het arrangement Setting up a weather station (by Martin Lörcks) is gemaakt met Wikiwijs van Kennisnet. Wikiwijs is hét onderwijsplatform waar je leermiddelen zoekt, maakt en deelt.

    Auteur
    Vetskilling
    Laatst gewijzigd
    2025-06-04 10:27:10
    Licentie

    Dit lesmateriaal is gepubliceerd onder de Creative Commons Naamsvermelding 4.0 Internationale licentie. Dit houdt in dat je onder de voorwaarde van naamsvermelding vrij bent om:

    • het werk te delen - te kopiëren, te verspreiden en door te geven via elk medium of bestandsformaat
    • het werk te bewerken - te remixen, te veranderen en afgeleide werken te maken
    • voor alle doeleinden, inclusief commerciële doeleinden.

    Meer informatie over de CC Naamsvermelding 4.0 Internationale licentie.

    Aanvullende informatie over dit lesmateriaal

    Van dit lesmateriaal is de volgende aanvullende informatie beschikbaar:

    Toelichting
    Setting up a weather station
    Eindgebruiker
    leerling/student
    Moeilijkheidsgraad
    gemiddeld

    Gebruikte Wikiwijs Arrangementen

    Vetskilling. (z.d.).

    Aufbau einer Wetterstation

    https://maken.wikiwijs.nl/209388/Aufbau_einer_Wetterstation

  • Downloaden

    Het volledige arrangement is in de onderstaande formaten te downloaden.

    Metadata

    LTI

    Leeromgevingen die gebruik maken van LTI kunnen Wikiwijs arrangementen en toetsen afspelen en resultaten terugkoppelen. Hiervoor moet de leeromgeving wel bij Wikiwijs aangemeld zijn. Wil je gebruik maken van de LTI koppeling? Meld je aan via info@wikiwijs.nl met het verzoek om een LTI koppeling aan te gaan.

    Maak je al gebruik van LTI? Gebruik dan de onderstaande Launch URL’s.

    Arrangement

    IMSCC package

    Wil je de Launch URL’s niet los kopiëren, maar in één keer downloaden? Download dan de IMSCC package.

    Voor developers

    Wikiwijs lesmateriaal kan worden gebruikt in een externe leeromgeving. Er kunnen koppelingen worden gemaakt en het lesmateriaal kan op verschillende manieren worden geëxporteerd. Meer informatie hierover kun je vinden op onze Developers Wiki.