0% found this document useful (0 votes)
200 views14 pages

ESP8266 Weather Station

This document describes the software for an ESP8266 weather station project with Arduino. The software is divided into two parts - the ESP8266 runs on NodeMCU and handles internet connectivity and communication with ThingSpeak, while the Arduino handles sensors and sends data to the ESP8266. The ESP8266 configuration includes WiFi and ThingSpeak parameters, while the Arduino configuration includes sensors and timing parameters. The ESP8266 and Arduino communicate serially, with the Arduino sending measurement data and commands to update ThingSpeak and the ESP8266 responding with status updates.

Uploaded by

VELAKITO
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
200 views14 pages

ESP8266 Weather Station

This document describes the software for an ESP8266 weather station project with Arduino. The software is divided into two parts - the ESP8266 runs on NodeMCU and handles internet connectivity and communication with ThingSpeak, while the Arduino handles sensors and sends data to the ESP8266. The ESP8266 configuration includes WiFi and ThingSpeak parameters, while the Arduino configuration includes sensors and timing parameters. The ESP8266 and Arduino communicate serially, with the Arduino sending measurement data and commands to update ThingSpeak and the ESP8266 responding with status updates.

Uploaded by

VELAKITO
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

22/1/2019 ESP8266 Weather Station With Arduino – #2 Software: 4 Steps

ESP8266 Weather Station With Arduino – #2


Software
By ohneschuh in TechnologyArduino 46.391 169 2

Download Favorite

By ohneschuh

Follow
More by
the
author:

This instructable is for the software of my Weater Station Project. Please read
it first to understand all explanations.

Because of the both MCUs the software concept is based on two parts:
The ESP8266 runs on Nodemcu and does the Internet connection and thingsp
eak.com related parts. The Arduino does all the sensor related things. The
https://www.instructables.com/id/ESP8266-Weather-Station-with-Arduino-2-Software/ 1/14
22/1/2019 ESP8266 Weather Station With Arduino – #2 Software: 4 Steps

communication between Arduino and ESP8266 is via serial connection


whereby the Arduino uses the SoftwareSerial Library on pins D2 (RX) and D3
(TX).

The configuration is divided into the both units:

All wifi and thingspeak.com relevant parameters are stored in the ESP8266
in a config file.
All sensor and measuring related parameter are set in the Arduino.

Why? I build up a lot of different units which only differ in


the thingspeak.com and wifi parameters. And I build a neat programmer
(image) for the ESP01. So I only have to save the new config file to the ESP01
and keep all other things same. And can easily change the thingspeak channel
by changing only the ESP01 config.

There's two modes in the Arduino software: standard and low power. The
standard version powering the ESP01 once and sends data regularly (short
periods) to thingspeak.com. The low power one sends the date also regularly
but within longer periods. Between two sendings the ESP01 is powered down.
Why using the standard version and not always save power? If you want a
more reliable, equidistant time stamp on thingspeak.com reconnection to wifi
takes too long and is not equal from one reconnection to the other. And if you
don't run the system on battery, power saving is not the most important aspect.

Add Tip Ask Question Comment Download

Step 1: The ESP01 Software

https://www.instructables.com/id/ESP8266-Weather-Station-with-Arduino-2-Software/ 2/14
22/1/2019 ESP8266 Weather Station With Arduino – #2 Software: 4 Steps

If not already done, flash the Nodemcu firmware to the ESP01. For flashing
see this other ESP01 project (link).

Extract all file from the the attached archive. To upload and communicate with
the ESP01 I use ESPlorer.

First, change the Wifi and thingspeak.com parameters in config.lua to yours:

wifiStation = "yourssid"
wifiPW = "yourwifipw"
devName = "name_of_your_device"
thingsSpeakKey = "ts_write_key"
tsChannel = "ts_channel_nb"

Save localServer.lua, tempArduino.lua, wifiConfig.luaand init_real.luaand


compile them. After compiling you can delete the *.lua files.
Save the config.lua and init.lua to the ESP01. Do not compile these files.
Restart the device.
Test the connection with ESPlorer: Wait until Wifi settled down and
send sendData() via serial to the ESP01. This should do an update of the
thingspeak.com channel. If no positive return check your config.

LEDs
https://www.instructables.com/id/ESP8266-Weather-Station-with-Arduino-2-Software/ 3/14
22/1/2019 ESP8266 Weather Station With Arduino – #2 Software: 4 Steps

The both LEDs show the status of the ESP01:

RED on: ESP01 is running, looks for Wifi connection


GREEN on: Wifi connected
RED blinking: No Wifi connection found. Module uses AP mode:
SSID: ESP+ DeviceID
PW: DeviceID
IP address: 192.168.1.1

If red and green are reversed reverse the LEDs in the header.

weatherstation.zip Download

Add Tip Ask Question Comment Download

Step 2: The Arduino Software

https://www.instructables.com/id/ESP8266-Weather-Station-with-Arduino-2-Software/ 4/14
22/1/2019 ESP8266 Weather Station With Arduino – #2 Software: 4 Steps

The Arduino is the measuring device. It reads all sensor values and calculates
the average over a specific time period (moving or rolling average).It also sets
the ESP01 to sleep and wake it up again.

There are few things to setup in the header individually. First the working
mode:

// ------------- mode setup ------------------


#define lowPowerMode 1 // lowPower = 1, standard = 0

Second different times:

https://www.instructables.com/id/ESP8266-Weather-Station-with-Arduino-2-Software/ 5/14
22/1/2019 ESP8266 Weather Station With Arduino – #2 Software: 4 Steps

// ------------- time setup ------------------


#define wifiSendPeriod 300000 // send data every x ms to thingspeak
#define meanPeriod 300000 // calculate the average of the sensor values of the last
x ms
#define avAnzDef 60 // number of values within the meanPeriod for averaging

And also the data of your thermistor:

// ------------- thermistor setup ------------------


float thermr = 10000; // reference resistance of the thermistor
int beta = 3950; // beta value
float t0 = 298.15; // reference temperature of the thermistor
float pad = 10000; // balance/pad resistor value

That's all!

tempArduino_low_04.i… Download

Add Tip Ask Question Comment Download

Step 3: Communication Between ESP8266 and Arduino


Direction:

A→E: Send command from Arduino to ESP01


A←E: Answer from ESP01 to Arduino
E→A: Send status from ESP01 to Arduino
E←A: Answer from Arduino to ESP01

Send data to thingspeak.com:

A→E:

sendData()

A←E:

D0 // not successful
D1 // successfully send to thingspeak.com
https://www.instructables.com/id/ESP8266-Weather-Station-with-Arduino-2-Software/ 6/14
22/1/2019 ESP8266 Weather Station With Arduino – #2 Software: 4 Steps

Update values on the ESP01:

A→E:

field01=<value> // temperature from thermistor


field02=<value> // temperature from DHT11
field03=<value> // humidity
field04=<value> // illuminance
field05=<value> // resistance of the thermistoir
field06=<value> // temperature from BMP180
field07=<value> // pressure from BMP180

A←E:

no answer

Wifi Status

E→A:

WS1 // Wifi on and connected

Add Tip Ask Question Comment Download

Step 4: Stability
To see the stability of the system here's the link to a chart from my
thingspeak.com account showing the temperature and the illuminance
somewhere in Germany:

https://thingspeak.com/plugins/13247

Actually it shows a one week overview. The system runs since mid of August
without a break.

So, if there are any questions ask them in the comments.

And for further instructables follow me.

Add Tip Ask Question Comment Download

https://www.instructables.com/id/ESP8266-Weather-Station-with-Arduino-2-Software/ 7/14
22/1/2019 ESP8266 Weather Station With Arduino – #2 Software: 4 Steps

2 People Made This Project!

MicahD1 made it! BookwormZero made it!

Did you make this project? Share it with us!

I Made It!
https://www.instructables.com/id/ESP8266-Weather-Station-with-Arduino-2-Software/ 8/14
22/1/2019 ESP8266 Weather Station With Arduino – #2 Software: 4 Steps

Recommendations

Portable Indoor Light With 100W LED Chip


by diyperspective in Technology

https://www.instructables.com/id/ESP8266-Weather-Station-with-Arduino-2-Software/ 9/14
Moving and Talking Giant Lego Hulk MiniFig (10:1 Scale)
22/1/2019 ESP8266 Weather Station With Arduino – #2 Software: 4 Steps

by TechMartian in Arduino

Spaceship Control Panel - Laser Cut Arduino Toy


by Nilfisken in Arduino

Arduino Class
https://www.instructables.com/id/ESP8266-Weather-Station-with-Arduino-2-Software/
76,411 Enrolled 10/14
22/1/2019 ESP8266 Weather Station With Arduino – #2 Software: 4 Steps

https://www.instructables.com/id/ESP8266-Weather-Station-with-Arduino-2-Software/ 11/14
22/1/2019 ESP8266 Weather Station With Arduino – #2 Software: 4 Steps

Add Tip

Ask Question

Post Comment

We have a be nice policy.


Please be positive and constructive.

Add Images Post

2 Discussions

Reply Upvote
MicahD1 2 years ago Cool project!, i'm 90% the way there I've
made the hardware got the esp online with
thingspeak but, i've just been spending a
while trying to get the library's right and i'm
just having a bit of trouble with the Average
library namely the running average function,
i've tried older versions of the arduino ide
and eclipse, including all average.h libraries i
could find with still no luck, are you using
your own altered library?
This is the error i'm getting in the Arduino Ide
and eclipse using the standard Average
library from Majenko.
tempArduino_low_04.ino: In function 'void
setup()':
tempArduino_low_04:119: error:
'rollingAverage' was not declared in this
scope
tempArduino_low_04.ino: In function 'void
loop()':
tempArduino_low_04:147: error:
'rollingAverage' was not declared in this
scope
'rollingAverage' was not declared in this
scope
https://www.instructables.com/id/ESP8266-Weather-Station-with-Arduino-2-Software/ 12/14
22/1/2019 ESP8266 Weather Station With Arduino – #2 Software: 4 Steps

Any help would be great, otherwise in any


case appreciate the effort you've gone
through to post this project to get me this far!
1 reply

Post Comment

https://www.instructables.com/id/ESP8266-Weather-Station-with-Arduino-2-Software/ 13/14
22/1/2019 ESP8266 Weather Station With Arduino – #2 Software: 4 Steps

Categories About
Us
Technology
Workshop Who
Craft We Are
Home Why
Food Publish?
Play Jobs
Outside Contact
Costumes
Resources Find
Us
Residency
Program
Community
Sitemap
Help

https://www.instructables.com/id/ESP8266-Weather-Station-with-Arduino-2-Software/ 14/14

You might also like