LoRaWAN Automatic Weather Station



Introduction: LoRaWAN Automatic Weather Station

About: I'm undergraduate student doing Computer Engineering and making my final paper graduation about a LPWAN weather station!

It is very common in embedded circuits scenario you find people building weather stations systems. A very easy way to connect sensors, microcontrollers and network protocols like Wi-Fi is building a weather station. The IoT (Internet of Things) field is increasing very fast nowadays, and new technologies regarding network protocols are getting requested.

The main idea of this project is firstly: build an automatic weather station that uses a LPWAN network protocol. The LPWAN (Low Power Wide Area Network) network offers possibilities to create low power consumption systems over a long-range transmission.

You might had seen the ESP32 Weathercloud Weather Station built by Jakub_Nagy and this project it's very similar! I've some exceptions, but check out Jakub's work too!


  • Seven (7) environment measures: temperature, humidity, atmospheric pressure, UV radiation intensity, precipitation, wind direction and wind speed.
  • Autonomous system with photovoltaic panels and batery.
  • LoRaWAN infraestructure (long-range transmission).
  • Watherproof.

This is a project built for my college graduation on University of Itajaí Valley - UNIVALI in Brazil :)

My English is a little bit rusty, I'm trying though 😊


I've made it the essencial components list to build this project. There are some tools that you can build this easly:

  • Multimeter.
  • Screwdriver, pliers, insulating tape, metric phyto.
  • Waterproof box to insert the components.

Software is an optional tool. I’m using the PlatformIO extension from Visual Studio Code for code development (C++ language). You can set up this code on Arduino IDE as well. The AutoDesk Eagle software is used to design the circuit schematic and board draw. 

Step 1: Overview


Let’s explain how a LoRaWAN network works: the End-Device function is sending a data package; in this case it is a weather station reading environment variables. The Gateway is responsible for receiving this package called “payload” and translate this package in a JSON format. The Gateway resends the translated information to a Network Server by using TCP/IP protocol. Then, the network server is capable to store this data or sending to an Application Server which shows to the user all data traffic.

Embedded System

The project was split in three systems: sensors system, communication system and the power system. The sensors system includes all sensors integration between the MCU (ESP32). The communication system includes the LoRaWAN transceiver module and the ESP32. The LoRaWAN gateway settings are also included on the communication system. The power system includes the photovoltaic system, that contains a battery, power charge controller and the solar panels.

Step 2: Design

The most important on designing part is design even what you don’t expect. I’ve built the embedded system in a protoboard firstly. After checking all the system stability, I started designing a PCB project.

Before designing a PCB for the system, I’ve firstly built on a protoboard. Checking sensor’s operation and checking the LoRaWAN module connection between ESP32.

Step 3: Integration

The software-hardware integration is important for all system running and reliability. I’ve firstly integrated the microcontroller and the sensors, tested, and then started the transceiver module integration.

The chart shows how I connected all pins on ESP32. It’s always better checking the component datasheet before connecting (you might be using a different model).

Ps. I honestly don't understand how the Wind sensor (WHSPxx) works, even changing pins connection, IT WORKS. (How come?).

Step 4: Testing

The mainly purpose of the project is the: power consumption decrease. The LPWAN protocol helps doing this task by the low operation frequency, the low-cost sensors are helpful by not being that accurate and I’ve done some software modifications to decrease more.

Consumption tests were made it by using a multimeter, so I could measure the total power consumption of the system and build the photovoltaic system.

Step 5: Coding

Coding is a hard step when you need to zoom out and see all the system working well. I've been using VS Code with PlatformIO extension to develop the C++ code.

You can checkout the whole code on my Github ;) I'll explain the main idea in the implemented code but the comments.


  1. Define all ESP32 pins, sensors settings, LoRaWAN settings and auxiliar variables.
  2. Insert the time of measurement and sending time.
  3. On setup I'm setting the modem sleep (turning off WiFi and Bluetooth).
  4. Setup of LoRaWAN parameter as: DEVEUI, APPEUI, DEVADR, APSKEY, NWSKEY, Region (Brazil), ADR (ON), and the Join Mode (ABP).
  5. The loop function reads the sensors data and send to the gateway by LoRaWAN.

Step 6: Photoltaic Supply

I've decided 2 days of full battery supply, this means if for any reason the sun doesn't appears the system will be functional for 2 days long. This plan needs some math to calculate how much charge do you need to supply your system.


Firstly you should test with a multimeter or amperimeter all components amperage when reading and processing data. I've got 48,24 mA. When I multiplicate this value by 3.3V (components supply voltage, except for the ESP32 that is 5V) I got 192.1 mW. So, thats the value that I need to supply.

The solar panel provides energy by sun radiation. I bought 2 solar panels with 2W each one (6V) and decided to put on a serial arrangement. So, if I multiply the total power provided by the solar panels with the amount of solar hours in a day (I guessed 5h) I have the followed value:

Produced Energy = 4W x 5 hours = 20 Wh

The system consumed energy in a day is valuable being calculated aswell :

Consumed Energy = 192.1mW x 24 hours = 4.61 Wh

So, with these 2 calculation we can choose a battery amperage doing:

Charge Capacity = (4.61Wh x 2 days) / (12V x 20%) = 3.84 Ah

Then, you can choose the battery that you needs. I've chosen the following items:

  • 1x 7AH Estacionary Battery with 12V.
  • 1x Charge Controller.
  • 2 x 2W Solar Panels with 6V (Serial Arrangement)

Step 7: Assembly

After testing that all system works, you can try the assembly part.

  • Structure/Tripod: I bought a banner tripod. It works when you don't have much weight.
  • Eletronic Components Box: I bought a box that is watherproof like these box you use outside a house for circuit breaker (at least we have in Brazil).Inside you can check the embedded system, the battery, and charge controller for the solar panel. All sensor wires comes from outside the box.
  • Sensors Placement: That is a boring part... I've bought a pipe to place the sensors a few centimeters long. The Radiation Shield in bottom left and the rain gauge at the bottom right (all tied with some zip locks). The wind sensor was easy, just putting in the highest part with a nail for locking them.

Ps. The Radiation Shield was modified putting a transparent platic over. The porpuse of this is for the UV sensor.

Step 8: Gateway

The LoRaWAN gateway is an entity on LoRaWAN network. The gateway porpuse is receiving the end-device data and processsing for send to the Network Server. It's really important looking for the LoRaWAN local range at your device location, in Brazil there is the American Towers that provides LoRaWAN gateways in a fair rental cost.

The requested LoRaWAN gateway service includes 5000 uplinks, 200 downlinks and 100 sendings to external services (e.g. Google Firebase, The Things Network). The image shows the location where the weather station is placed, the city of Itajaí in Santa Catarina province.

Step 9: Network Server

A LoRaWAN network needs a gateway to receive the data and a interface to show to the user. I’ve chosen not building a LoRaWAN gateway. Instead of spending money and much more time building one, I’ve decided paying rental charges for a gateway use in my region.

The ProIoT platform has available services that offers 5000 uplinks, 200 downlinks and you have 100/month "resends" to external services. You might have different views/interface, but in all LoRaWAN networks you have the same steps.

  • Device EUI: The Device Extended Unique Identifier could be found over the LoRaWAN module.
  • Security Activation: I opted using ABP because it power consumption is lower and wider range. (but is less safe). You can check the difference between ABP and OTAA at here.
  • Cryptographic: NS.
  • Device Adress, Application EUI, Application Session Key, Network Session Encryption Key: These are your credentials that should match with you LoRaWAN module. You have to check these credentials because if they don't match, wouldn't have connection.
  • Frequency Operation: Check your region frequency. Brazil (South America) uses 915 ~ 928 MHz.

After setting the credentials and other options, you're able to test a connection. I've been testing just uplink messages, because I don't need a gateway confirmation, or even receive anything on my LoRaWAN module.


For instance, you have to configure the receiving "payload". I'm sending the data in a JSON format like that:

{"T": "23", "H": "78", "P": "1018", "U": "2", "S": "7", "D": "270", "R": "4"}

This payload is giving an "alias" for each readable variable (e.g. "T" means "Temperature"). I'm using just integers numbers because using float values could overflow the payload capacity.

ProIoT interface includes a "Dashboard". You can include some variables that you are receiving in you "Home Interface", and you can attach plots, gauges, timelines.

Step 10: Applitacation Server

It's very useful reading the data in public interfaces, because it helps everyone with trustful data. Unfortunatly in this applitaction I didn't integrate the network server with a public application server. Instead of publishing the data, these data is stored on ProIoT platform and you can see the data requesting permission in private (https://app.proiot.com.br/login) or you can try on: app.proiot.com.br/public/dashboard/6127da5fe274c300163258af to check the data dashboard.

Step 11: Results

There are three steps I've prepared to show in results.

  1. Location: It's important the right placement of a weather station because it can affect data acuracy. Mine weather station is located at the top of building (at least 12 meters high) and outside. The exact location is: 26º55'08.5"S 49º06'23.2"W (https://goo.gl/maps/pqnzKmH7BkNMj6yY6).
  2. System Autonomy: The photovoltaic system should be functional 24/7, but there are some cloudy days that makes hard for the system. I've simulated a shadow over the solar panels by disconnecting them. The system kept sending data for over 50 hours after discharging all battery energy. Then unfortunately the system just recovered after leaving just the solar panel connected on the battery (without the embedded system consuming energy).
  3. Validating Data: A weather station should give trustful data. I've requested for government entities some meteorological data of some near weather stations.

Step 12: Validation

The given meteorological variable validation are from the Defesa Civil de Blumenau - AlertaBlu. The comparison time was between 10/31/2021 and 11/09/2021.

The validated meteorological variables are: Temperature, Humidity, Atmospheric Pressure and Precipitation. In this period 240 packages were given by AlertaBlu (1 per hour). Using this amount, it was possible to calculate the receive rate comparing my weather station.

The first image shows the data receive rate is 69% and just this data was validated. At the second image you can check the relative error and standard deviation of each variable. The average relative error of all comparated data is 14.37%.

You can check all these data on: https://github.com/Lucasgb7/Weather_Station/tree/master/data. (Portuguese content).

So, the validation resulted on 85.63% of data reading accuracy ;)

Step 13: Conclusion

This work was really really hard to think, designing, buy the right component and the whole integration. Of course there are issues, so I'll list what I didn't fixed at the time I'm writing this:

  • The LoRaWAN module looks insuficient for long range tranmission, because the data receive rate was just acceptable.
  • The sensors location on the weather station are not perfect and some accurarcy was deviated by this fact.
  • I coudn't make possible the Application Server integration between a public server for data monitoring.

I spent more less $220 dólars to build this project. (I think it's a fair price for a first try). BUT there are some ways to improve this project:

  • Including a RTC module, having a better control of the time you could control the transmission rate better.
  • Look better for a LoRaWAN module. Yes, it's a shame having a weather station to send data in long range, and having a LoRaWAN module that don't make it.
  • Development AI algoritm to make weather forecast.

You can check everything in this work at my Github. I'm working on a article publish, so it might be useful one day.

I wish you good luck and please comment, make questions, everything I'll be replying :)

Be the First to Share


    • For the Home Contest

      For the Home Contest
    • Big and Small Contest

      Big and Small Contest
    • Make It Bridge

      Make It Bridge