Solar Weather Station With ESP32, SIM800L, ESP8266

Let's make small weather station, collect sensor data, setup web server, send and display data.

Public Chat
Similar projects worth following
Already existing weather station projects on the internet made me wanna build weather station for myself.
So I did it. Let me show you how.

This is mainly based on Solar Powered WiFi Weather Station project from OpenGreenEnergy.

For more information you can check video about this project.

I wanted to make as much as possible mobile and autonomous weather station. To realize that I will need constant power, anywhere I place and leave that weather station, so I decided to go with Lithium-Ion (3.7V, 2100 mAh, 18650) rechargable battery, small (6V, 1W, 166 mA) polycrystal solar panel and TP4056 module for battery charging and protection.

OK, power is solved. But what will be the brain of this operation? To satisfy my desire to have portable weather station I've decided to go with LILYGO T-Call version 1.3, later on version 1.4 module with ESP32 and SIM800L module. LILYGO module comes with antenna and wires for power. Espressif ESP32 will be the brain which will contain program code. In SIM800L communication module I'll add SIM card that will connect to GPRS mobile station with APN information and send collected data to a web server. Big note, if you are planning to use SIM800L module check that your mobile operators in your country are still supporting 2G, GSM, GPRS networks. This will not work with 3G and higher generations if GSM is not supported. I'll buy cheapest mobile data package for SIM because sending of weather data will need very little internet data. In one week this weather station should not create traffic more than 100MB if sending data in period of 15 to 30 minutes.

Which data will be collected? I decided to get the basic data for weather, like temperature, humidity and pressure. To collect that data BME280 sensor will be used and then get altitude value out of temperature and pressure data. I will also try to get UV index with SI1145 sensor. Later on I've also decided to add MAX17043 sensor to get battery percentage. All sensors should use I2C to send data to ESP32.

To connect all that components I'll need few more parts. And those are, some wires, breadboard, prototyping board, screw terminals, switch and battery holder.

I'm going to use my private website to store and pull data with PHP in MySQL database and then visualize that data with HTML, CSS and JavaScript.

On the end we are going to put all the electronics in nicely 3D printed case.

OK Let's start with the project.

gcode - 7.34 MB - 02/23/2021 at 20:17


gcode - 1.57 MB - 02/23/2021 at 20:17


Standard Tesselated Geometry - 126.55 kB - 02/23/2021 at 20:17


Standard Tesselated Geometry - 123.71 kB - 02/23/2021 at 20:17



PHP files and images for Web App

x-zip-compressed - 9.37 MB - 02/23/2021 at 20:17


View all 8 files

View all 16 components

  • 1
    Connect the Componentes

    For start, I will solder pins to LILYGO board and sensors.

    Once I saw sensor readings are working I've decided to transfer all this to perfboard, add all sensors that I mentioned before in this tutorial and let's connect everything to work as we want.

    Get all the components and wire them like I did on this scheme. Working with perfboard was so messy and often I connected 2 or more pins I shouldn't connect because they were so close to each other.

    Just to give you an example, I didn't see but I soldered SCL line of sensors to ground pin and I2C was not working. I spent day and a half looking and searching why I2C communication is not working until I saw those pins that should not be connected were connected. That was a reliving moment for me. :) So be careful if you are planning to use perfboard the same way I did. Other option, which would be better and cleaner, would be to make PCB board and then just solder pins that will hold module and sensors on it. Maybe I will make that in future. We will see.

    One very bad thing that happened in this process of making this weather station. In one point of making I wasn't careful and burned LILYGO module. No problem. I've ordered another one. But, to arrive, it will need more than a month. That's why I decided to include Wemos D1 Mini Pro module with ESP8266 in this project. I've prepared the connections for it and was planning to use it until new LILYGO module don't arrive. But on the end I decided to leave all the pins for Wemos so now, I have a option to switch between the two modules.

    With Wemos module, sending data to a web server was over Wi-Fi and not over GSM, as it is case with the LILYGO module.
    This is more appropriate if you want to use weather station let's say inside your home. Inside your LAN, where you have Wi-Fi coverage and you do not need to pay extra costs for mobile data, like I need for SIM card. But it's not too much.

    I noticed that MAX17043 sensor for battery percentage is not working as I though it will.
    Probably because of battery voltage that is sometimes higher than 3.7 volts, or some wrong connection. Somewhere I saw, it may be because of wrong resistor value on TP4056 module. I'm getting result over 100 percent which is not OK. This overcharging is not good for battery so I should find a solution for that. If you have an idea of how to fix that tell me in comments section bellow.

  • 2
    ESP32 and ESP8266 Program Code

    OK, anyway, let me add link to code.

    Again, in short, with this code we will connect to GPRS mobile station, send collected data from sensors to a WEB server and store it in MySQL database and then visualize data on a web app.

    Code is based on one from RandomNerdTutorials and modified a little bit. Check out awesome RandomNerdTutorials YouTube channel to see a lot of great stuff, mainly with ESP based modules. Code is excellently written and commented, so you shouldn't have any problems understanding it.

    Simply look for your mobile operator APN, GPRS info and fill them in and then also add your website domain or IP. If you don't have one, you can make a website locally, but then you will need to make it publicly available with some DynamicDNS solution or another option is, if you have static IP from your ISP you can try to port forward it. In case, that you know better ways of how to get website from local to public please add it in comments. This will maybe help someone. And that's basically everything to change about the code if you're following this project.

    Code can also be found on GitHub.

  • 3
    Setup Web Server

    Next to do. Setup your web server.

    You can use development environment like XAMPP or WAMP to create web app locally or buy public web server and domain from some hosting. As I mentioned before you can't send sensors data to local web server unless you setup DynamicDNS for it, or you have a static IP that is publicly available from internet. I will work with public web server in this tutorial.

    Let's prepare MySQL database and PHP files for web app. In database you want to create table with primary key, values for sensors and timestamp. Let me mention again that full code is available in tutorial description.

    As a base we have this code here, again from RandomNerdTutorials project. I've just added few more fields for all sensors data. I created index.php and added some cool stuff in there. I wont go through the code. Just replace this and add yours database information and API key same you have in C++ code. Then we will need to add database information to post-data.php file. Let me just mention that data is sent from ESP32 and SIM800L module with a HTTP POST request to post-data.php.

    OK. Web app is now ready. Our weather station should now be able to send data to a web server and we should see data in web app.

    If having website locally, check on localhost by typing or IP of your PC which you can find in terminal by typing ipconfig. I can show you that for me, web app works just as planned. Nice. On the first visit we see data from all the sensors. Here are visible parts for LILYGO module based weather station and also Wemos based ones. Bellow are graphs with history readings of data that are quite interesting. I've used Bootstrap with already made HTML and JavaScript parts.

    Code can also be found on GitHub.

View all 4 instructions

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates