In this tutorial we are going to build a WiFi enabled weather station project.
The target is to design Weather station with almost all possible feathures:
I can't add more and not more imagination what else must or can be
First step is assembling of station powers.
I have divided plastic case on two pars, one of them used for battery, switch, USB charger, and DC-DC step out Into this part i put battery holder and make windows for the switch and usb charger. Be aware usb charger module quite heting therefore i have used alluminium plate and put USB charger onto this using Star 922 glue.
Second step is assembling controllers part.
See wiring diagram how it should be connected
I have used Bread board for this purpose with the following steps
Third step is prepare mounting of bread board to the second part of the plastic case. I have printed on my 3d printer two bars, mount them to bredboard by screws and make rectangular cutting for the display screen.
I glued plastic bars supports to the body of plastic case. Now when glue is dry, the bread board cab be unmount by screws.
Next step is :
Final step:
For the motion detector and button i have done an additional holes on the face side .
For this project I have used universal software, developed by myself
Please have a look github page ESPHomeController .This contains full instruction how to compile and setup.
! If you are not familiar with compilation and Arduino have a look step Uploading ready firmware
As soon as you upload firmware first time the ESP32 will start in configuartion mode (Access Point mode)
You should configure them. For this purpose open in any device list of available WiFi. Find HomeController and connect to it. Captive portal should start automatically. If not enter in your browser url: 192.168.4.1 and you will see configuration screen
Follow instruction and configure WiFi credentials to your WiFi network.
The ESP will restart after that as WiFi client and will connect to your Wifi.
As sson firts connection happens it will automatically mount Spiffs file system and downloads required files for the web portal:
Download happens from the https://github.com/Yurik72/ESPHomeController/tree/... folder
Now you can see file content via web browser. for this you should now ip address of your ESP32
You can find it by one of the following ways:
Put into browse http://192.168.0.XX/browse and you will see a file list of the your ESP
(192.168.0.XX is IP address of your device
For the final tuning you need to prepare configuration files.
This section is specially for auditory who is not going to produce firmware by yourself. You just need to upload "ready" firmware
1. Donwload flash upload tools from this page
2. Download attached (extract from archives) files HomeController.bin and bootloader_qio_80m.bin to your hard drive
3.Start ESP32 download tool and enter values according screenshot
4. Press start
Before starting preparation of configuration you need:
Thingspeak are needed to upload your data and monitor trends and values
Weather are neccessary to get forecast data.
Ok, finally you need create services.json file with the following content
[{"service":"TimeController","name":"Time","enabled":true,"interval":1000,"timeoffs":7200,"dayloffs":3600,"server":"pool.ntp.org","enablesleep":true,"sleeptype":1,"sleepinterval":900000,"restartinterval":18000000},<br>{"service":"BME280Controller","name":"BME","enabled":true,"interval":900000, "i2caddr":118,"uselegacy":true,"temp_corr":-3.0,"hum_corr":10.0}, {"service":"WeatherClientController","name":"WeatherForecast","enabled":true,"interval":500000,"uri":"https://api.weather.com/v3/wx/forecast/daily/5day?geocode=50.30,30.70&format=json&units=m&language=en-US&apiKey=weatherapi"}, {"service":"WeatherDisplayController","name":"WeatherDisplay","enabled":true,"interval":500}, {"enabled":"true","interval":600000,"pin":36,"service":"LDRController","name":"LDR","cvalmin":0.0,"cvalmax":7.2,"cfmt":"%.2f V","acctype":10}, {"service":"ThingSpeakController","name":"ThingSpeak","enabled":true,"interval":1200000,"value":[1,1,1,1,0,0,0,0],"apiKey":"thingspeakapi"}, {"enabled":true,"interval":1,"pin":"","service":"ButtonController","name":"Button","pins":[27]}</p></p><p>]</p>
!Please replace
Than prepare second file triggers.json
[{"type":"BMEToWeatherDisplay","source":"BME","destination":"WeatherDisplay"},<br>{"type":"TimeToWeatherDisplay","source":"Time","destination":"WeatherDisplay"}, {"type":"WeatherForecastToWeatherDisplay","source":"WeatherForecast","destination":"WeatherDisplay"}, {"type":"BMEToThingSpeak","source":"BME","destination":"ThingSpeak","t_ch":1,"h_ch":2,"p_ch":3}, {"type":"ButtonToWeatherDisplay","source":"Button","destination":"WeatherDisplay"}, {"type":"LDRToThingSpeak","source":"LDR","destination":"ThingSpeak","ch":4} ]
Both files has to be uploded to the root of esp.
You can do this via browser http://192.168.0.XX/browse , where http://192.168.0.XX is IP adress of your device
After uploading the ESP must be restarted and everything was done right. Esp will show the proper screen as on the photo and video above
I'm using my device with the connection to Solar Panel and to be sure that it can work "infinitely"
power consumptions is important and after several experiment i have used two major tricks
According measurement it's eating 15-20 mA (a lot) therefore i have used tactics with Motion detector. It works perfectly Motion detectors able to recognize any detection up to 8-10 meters and raise voltage on the signal cable. This is openings a transistor and backround Led receive a power. Usually detector keep this state up to 10 sec which is more than enought to see monitor, but if you continue movements the signal is still high and LED is lighting.
Such approach give me a big economy, without additional effects, I do not meet with any problem to see my screen when i want
2. Reduce power consumption by ESP32
When ESP is connected to WiFi , it's constantly eatinmg 7-10 mA, I'm talking about constant time, not startup and first connection. This is can be acceptable if you have always see actual date and time, access your system from the Apple home kit
For my solar power in winter time as well it was to match to works without addiiotnal power sources,
Therefore i decided periodically put ESP32 on the sleep mode (eating is less than 1 mA) . This is Ok to me, for instance ESP is sleeping 20 minutes, than wake up, refresh screen (actual data and forecast) sends data to the thingspeak and back to sleep mode again
Minuses are:
It's up to you to decide what is more important, you can simple reconfigure that.
Please have a look services.json file and line
[{"service":"TimeController","name":"Time","enabled":true,"interval":1000,"timeoffs":7200,"dayloffs":3600,"server":"pool.ntp.org","enablesleep":true,"sleeptype":1,"sleepinterval":900000,"restartinterval":18000000}</p>
"enablesleep":true enables sleep at all, if put there false or remove paramater (false is default) ESP will never sleep
"sleepinterval":900000 this is millis, or 15 min, means every 15 min ESP will wake up and doing neccessary staff
So, now everybody can easylly play according neccessity
To minimize impact of internal heating to BME280 temperature sensor
Firts I did some tube around sensor and holes. Hovewer in my mode when LED normally is turned off and ESP is sleeping is not so importnat. In other cases BME280 sensor should move somewhere to exclude influence of internal heating. Any how small influence i found therefore there are two parameters to compensate
<p>{"service":"BME280Controller","name":"BME","enabled":true,"interval":900000, "i2caddr":118,"uselegacy":true,"temp_corr":-3.0,"hum_corr":10.0},</p>
temp_corr":-3.0
"hum_corr":10.0
which are means those values will be added after measurment
Second is calibrate battery voltage measurement,
<p>{"enabled":"true","interval":600000,"pin":36,"service":"LDRController","name":"LDR","cvalmin":0.0,"cvalmax":7.2,"cfmt":"%.2f V","acctype":10},</p>
"cvalmin":0.0
"cvalmax":7.2
are for this purposes, becasue voltage is measured after resistors dividers and compared with 3.3 V ,playing with cvalmax value you can reach exact voltage tuning with your multimetr value
Finally when your device is working properly it can be added to Apple Home Kit and you will be able to see
sensors values on the Apple home screen.
First you need restart device, as ssoon as device started it will not go to sleep 20 minutes is more than enought
Than open Home Kit App on your iOS device , and select or create new Home
1. Press Add (+)
2. Select Add accessory.
3. Press I don't have a Code or Cannot scan (further on scanning will be added)
4. if everything going fine you should see your new esp device in a list (see picture)
5. Select device and confirm adding without official certification
6. Type password 11111111
7. That All ! You should see that device paired succesfully, otherwise start pairing process again..
Based on thid setting you will see two devices on the Apple
1. Temp sensor & Hum sensor , going deep it will display values on full screen
2. Light sensor :) Actually Apple is able to show ligth Ambience, but not Voltage, therefore battery voltage is showing in Lux
Before start any updating is better to reboot ESP32, as mentioned before it will not go to sleep first 20 minutes
There are two possibilities to update