Skip to main content

DIY Wireless based Weather Station Project by using Nextion LCD

Project Abstract:

A Wemos D1 Mini is constantly receiving weather information from the internet for your city and sends it over to the display. Simultaneously, an RTC Module sends the current date and time to the Wemos D1 Mini to also display it on the display. Additionally, a BME280 temperature and humidity sensor send the corresponding values to the Wemos and it sends the data over to the display, to show it beside the data from the internet. For the communication between the Wemos, RTC Module and BME280 Sensor we will be using the I2C protocol. The display uses a serial interface for communication. 

Software necessities

Now in order to complete this project, you need to make sure that you have the ESP8266, as well as the SparkFun BME280 libraries installed in the Arduino IDE. You also need the Nextion Editor software(free).

Circuit diagram

Given this functioning principle, I designed a schematic for this circuit.

PCB Gerber View – PCBGOGO Online Gerber Viewer



How to add PCB Gerber File to View Online | Video Demonstration 

The PCBs Arrived For Our Project :

PCBGOGO is a very qualitative Chinese PCB manufacturer with very fast shipping time. we received our PCBs in 2 (!!!!) days, which is awesome.  PCBGOGO provides amazing work on PCB manufacturing and as well as PCB assembling. This website can really help you guys, to place your orders. PCBgogo promises its’ customers to provide them with a fast delivery service and to place their order as soon as possible.

Watch PCBGOGO Package Unboxing Video:

Final Look of PCB After the Assembling of Components :

Final Video of the Project Demonstration


Arduino Source code Explanation:

In the Arduino code, you need to set the I2C address of your BME sensor. What happens in the following line:

You also need to select the Wemos D1 board from the board manager, as shown below.

Data readings

You get the actual weather readings from these 2 lines:

For the WiFi part, you need to fill out the following parameters:

For displaying the date and time, I had to do some workarounds to have them properly shown on the display. The GUI doesn’t automatically add a 0 if the time has 1 letter, for example, it will show 8:30, which doesn’t look that good. In the following lines, I made sure that when the date/hour consists of 1 number, the code adds a 0 in front of the number. Additionally, I had to subtract 1 from the hour value because of the wintertime.

In the following lines, I convert the string readings for the date/time in integer.

As explained beforehand, here I add a 0 to the numbers with an IF statement, if the date/time only consists out of 1 number.

Transmitting data to display

In order to transmit the data/time values, this is how you need to send the values over to the display.

The variable “data” consists of the hours + : + minutes, in order to achieve the format 08:56 for example. The same goes for the date.

The temperature and humidity are transmitted with the following lines:

Online weather data

The display needs to get 4 hexadecimal 0xFF in order to process the data packet. For the weather values from the internet, I used to get the local weather from my city.

You need to register yourself for free in order to get your API Key.

After searching for your city, you can copy the city ID from the link.

A place for Adding API and City id into Source Code


This is how the GUI looks like. we designed it by using the Nextion Editor software.

Complete Source Code: 

#include <ESP8266WiFi.h>
#include <ArduinoJson.h>
#include <Wire.h>
#include <DS3231_.h>
#include "SparkFunBME280.h"
BME280 mySensor;
float temps;
float hums;
String data;
float tempitod;
float humitod;
String result;
DS3231 clock_ds;
RTCDateTime dt;

String string1;
String string2;
String string3;
String string4;
String string5;
int hour_int;
int minute_int;
int day_int;
int month_int;
String string_h;
char ssid[] = "type your wifi name";
char pass[] = "type your wifi password";
String APIKEY = "a3b00f5ba21ccc4fedf1b1846b3f37b0";
String CityID = "2778067";

WiFiClient client;
char servername[] = "";

void setup() {

  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {


void loop() {
  dt = clock_ds.getDateTime();

 string1 = (dt.hour)-1;
 hour_int = string1.toInt();

 if((dt.hour) == "00" ){

 string2 = dt.minute;

string3 =;
string4 = dt.month;
string5 = dt.year;

minute_int = string2.toInt();

day_int = string3.toInt();
month_int = string4.toInt(); 

if (hour_int < 10)
  string1 = "0" + string1;

if (minute_int <10)
  string2  = "0" + string2;

 if (day_int <10)
  string3  = "0" + string3;

if (month_int <10)
  string4  = "0" + string4; 

 hums = mySensor.readFloatHumidity();
 temps = mySensor.readTempC();


void getWeatherData()
  if (client.connect(servername, 80)) { 
    client.println("GET /data/2.5/weather?id=" + CityID + "&units=metric&APPID=" + APIKEY);
    client.println("User-Agent: ArduinoWiFi/1.1");
    client.println("Connection: close");
  while (client.connected() && !client.available()) delay(1); 
  while (client.connected() || client.available()) { 
    char c =;
    result = result + c;
  result.replace('[', ' ');
  result.replace(']', ' ');
  char jsonArray [result.length() + 1];
  result.toCharArray(jsonArray, sizeof(jsonArray));
  jsonArray[result.length() + 1] = '\0';
  StaticJsonBuffer<1024> json_buf;
  JsonObject &root = json_buf.parseObject(jsonArray);
  String location = root["name"];
  String country = root["sys"]["country"];
  float temperature = root["main"]["temp"];
  float humidity = root["main"]["humidity"];
  String weather = root["weather"]["main"];
  String description = root["weather"]["description"];
  float pressure = root["main"]["pressure"];
  tempitod = temperature;
  humitod = humidity;

void NextionData() {

  data = "time_h.txt=\"" + string1+ ":" + "\"";

  data = "time_m.txt=\"" + string2 + "\"";

  data = "day.txt=\"" + string3 + "\"";

  data = "month.txt=\"" + string4 + "\"";

  data = "year.txt=\"" + string5 + "\"";

  data = "temps.txt=\"" + String(temps, 1) + "\"";
  data = "hums.txt=\"" + String(hums, 1) + "\"";

  data = "tempitod.txt=\"" + String(tempitod, 1) + "\"";
  data = "humitod.txt=\"" + String(humitod, 1) + "\"";

Click Here To Download Nextion Source Code File | Human Machine Interface (HMI)

A sponsor of this project

The sponsor of this project is PCBGOGO which delivered us 10 PCB’s for this project. PCBGOGO produces high-quality PCBs in a very short time and delivers them very quick too. So, if you are thinking of making your project professional, don’t hesitate to upload your Gerber files to PCBGOGO to receive 10 PCBs for a very low price.

Placing Your Order Made Easy at PCBGOGO 

The post DIY Wireless based Weather Station Project by using Nextion LCD appeared first on Electronics Lovers ~ Technology We Love.

from Electronics Lovers ~ Technology We Love


Popular posts from this blog

TE Connectivity Announced Ultra Small Spring Fingers

TE Connectivity (TE)’snew ultra small spring fingers have one of the smallest footprints in the market to save valuable PCB space, allowing for use in a broad range of applications with space constraints across various industries.TE’s ultra small spring fingerscan save valuable PCB space with one of the smallest footprints in the market. Closed-loop contact design ensures reliable connection to the PCB, better normal force and higher current capacity (1.5A). Robust side wall minimizes over- compression. Special anti-lifting design can improve assembly e ciency by locking the tip of the contact within the sidewall of the spring  nger, which helps prevent the contact from getting caught on an operator’s glove during assembly. Pick-and-place area supports auto-assembly processes. It also offered in different heights and styles.As an authorized distributor for TE Connectivity, Heilind Asia provides TE’s products and also value added services. Heilind Asia supports both original equipment …

Hanwha TechwinCollects Two NPI Awards for Its Cutting-Edge Modular Mounter and Screen Printer at APEX

Hanwha Techwin Automation Americas, formerly Samsung C&T Automation, today announced that it has received two 2019 NPI Awards in the categories of Component Placement – High-Speed for its HM520 Cutting-Edge Modular Mounter and Screen/Stencil Printing for the ESE US-2000XF. The awards were presented to the company during a Tuesday, Jan. 29, 2019 ceremony that took place at the San Diego Convention Center during the IPC APEX EXPO.With the HM520 Modular Mounter, actual productivity is highest among machines of the same class and is optimized to high quality production. The system configures a flexible production line by applying a modular head and various production modes. The HM520 realizes unmanned, non-stop, and zero-defect production using the Smart Factory S/W Solution.The high performance HM520 offers a compact foot print, auto-calibrating maintenance free feeders, and modular heads. The HS(High Speed) Head offers a 20 Spindle x 2 Gantry, 80,000 CPH, ±25 μm @ Cpk ≥ 1.0, 0201 ~ …

Mornsun Concludes its Last Power Supply Seminars of 2019

Mornsun illustrated EMC diagnostic skills through some case analysis to help engineers with identifying common pitfalls It shared the breakthrough achievements of Mornsun’s new generation DC/DC power supply modules It also explored some latest issues in the power solutions field and discussed approach to achieve reliable power performance Mornsun Guangzhou Science & Technology Co., Ltd., […]The post Mornsun Concludes its Last Power Supply Seminars of 2019 appeared first on Electronics For You.

from Electronics For You