Solar Powered WiFi Weather Station

159,307

1,219

179

Published

Introduction: Solar Powered WiFi Weather Station

About: I am an Electrical Engineer. I love to harvest Solar Energy and make things by recycling old stuff. I believe, IF YOU TRY YOU MIGHT, IF YOU DON'T YOU WON'T. www.opengreenenergy.com

In this Instructable, I am going to show you how to build a Solar powered WiFi Weather Station with a Wemos board.The Wemos D1 Mini Pro have small form-factor and wide range of plug-and-play shields make it an ideal solution for quickly getting started with programming the ESP8266 SoC. It is an inexpensive way to build Internet Of things ( IoT ) and is Arduino compatible.

The new Weather Station have following features:

1. The Weather Station can measure :Temperature, Humidity , Barometric Pressure , Altitude

2. You can monitor the above weather parameters from your Smartphone or from the web ( ThingSpeak.com )

3. The whole circuit along with power supply is put inside a 3D printed enclosure.

4. The range of the device is enhanced by using an 3dBi external antenna .It is around 100 meter.

Step 1: Parts and Tools Required

1. Wemos D1 Mini Pro ( Amazon / Banggood )

2. TP 4056 Charging Board ( Amazon / Aliexpress )

3. Diode ( Aliexpress )

4. BME 280 sensor ( Aliexpress )

5. Solar Panel ( Banggood )

6. Perforated Board ( Banggood )

7. Screw Terminals ( Banggood )

8. PCB standoffs ( Banggood )

9. Li Ion Battery ( Banggood )

10. AA Battery Holder ( Amazon )

11. 22 AWG wire ( Amazon / Banggood )

12. Super Glue ( Amazon )

13. Duct Tape ( Amazon )

14. 3D printing filament -PLA ( GearBest )


Tools Used :

1.3D Printer ( Anet A8/ Creality CR-10 Mini )

2. Soldering Iron ( Amazon )

3. Glue Gun ( Amazon )

4. Wire Cutter / Stripper ( Amazon )

Step 2: Power Supply

My plan is to deploy the Weather station at a remote place ( my farm house).To run the Weather Station continuously, there must be a continuous power supply otherwise the system will not work .The best way to provide continuous power to the circuit is by using a battery.But after some days the battery juice will run out, and it is really difficult job to go there and charge it. So a solar charging circuit was proposed to user free energy from the sun to charge the batteries and to power the Wemos board.I have used a 14450 Li Ion battery instead of a 18650 battery because of its smaller size.The size is same as of an AA battery.

The battery is charged from a Solar panel through a TP4056 charging module. The TP4056 module comes with battery protection chip or without the protection chip.I will recommend to buy a module which have battery protection chip included.

About the TP4056 Battery Charger

The TP4056 module is perfect for charging single cell 3.7V 1 Ah or higher LiPo cells. Based around the TP4056 charger IC and DW01 battery protection IC this module will offer 1000 mA charge current then cut off when charging is finished. Furthermore when the battery voltage drops below 2.4V the protection IC will cut off the load to protect the cell from under voltage.It also protects against over voltage and reverse polarity connection.

Step 3: Measuring the Weather Data

In the earlier days weather parameters like ambient temperature,humidity and barometric pressure were measured with separate analog instruments: thermometer, hygrometer and barometer.But today the market is flooded with cheap and efficient digital sensors that can be used to measure a variety of environmental parameters.The best examples are sensors like DHT11, DHT 22, BMP180, BMP280 etc.

In this project we will use a BMP 280 sensor.

BMP 280 :

BMP280 is a sophisticated sensor that very accurately measures barometric pressure and temperature with reasonable accuracy. The BME280 is the next-generation of sensors from Bosch, and is the upgrade to the BMP085/BMP180/BMP183 - with a low altitude noise of 0.25m and the same fast conversion time.

The advantage of this sensor is that it can use either I2C or SPI for communication with microcontroller. For simple easy wiring, I will suggest to by I2C version board.

Step 4: Using an External Antenna ( 3dBi )

The Wemos D1 mini Pro board have a inbuilt ceramic antenna along with provision for connecting an external antenna to improve the range.Before using the external antenna, you have to reroute the antenna signal from the built-in ceramic antenna, to the external socket.This can be done by rotating the small surface mount (0603) Zero Ohm resistor (sometimes called a link).

You can watch this video made by Alex Eamesto rotate the zero ohm resistor.

Then snap the antenna SMA connector in to the Wemos Pro mini antenna slot.

Step 5: Solder the Headers

Wemos modules come with variety of headers but you have to solder it according your requirement.

For this project,

1. Solder the two male headers to the Wemos D1 pro mini board.

2. Solder a 4 pin male header to the BMP 280 module.

After soldering the headers the module will look as shown in the above picture.

Step 6: Adding Headers and Terminals

Next step is soldering the headers to the perforated board.

1. First place the Wemos board over the perforated board and mark the foot print.Then solder the two row of female headers over the marked position.

2. Then solder a 4 pin female headers as shown in the picture.

3. Solder a screw terminals for battery connection.

Step 7: Mount the Charging Board :

Stick a small piece of double sided tap on the back side of the charging module and then paste it on the perforated board as shown in the picture.During mounting care should be taken to align the board in such a way that the soldering holes will match with the perforated board holes.

Adding terminal for Solar Panel

Solder a screw terminal just near the micro USB port of the charging board.

You can solder this terminal in the earlier step also.

Step 8: Wiring Diagram

First I cut small pieces of different colors wires and strip out the insulation at the both ends.

Then I solder the wires according to the Schematic diagram as shown in the above picture.

Wemos -> BME 280

3.3 V - -> Vin

GND --> GND

D1 --> SCL

D2 --> SDA

TP4056 Connection

Solar Panel terminal -> + and - near the micro USB port

Battery Terminal -> B+ and B-

5V and GND of Wemos -> Out+ and Out-

Note :In the beginning , I forgot to solder the diode.Later I solder it near to the Solar panel terminal and connect it as per the wiring diagram.I have used a 1N4007 diode but I will recommend to use a low voltage drop schottky diode.

Step 9: Designing the Enclosure

This was the most time consuming step for me.I have spent around 4 hours to design the enclosure. I used Autodesk Fusion 360 to design it. The enclosure have two parts : Main Body and Front Cover

The main body is basically designed to fit all the components. It can accommodate the following components

1. 50x70mm circuit board

2. AA battery holder

3. 85.5 x 58.5 x 3 mm Solar Panel

4. 3dBi external antenna

Download the .stl files from Thingiverse

Step 10: 3D Printing

After completion of design, it is time to 3D print the enclosure.In Fusion 360 you can click on make and slice the model by using a slicer software.I have used cura to slice the model.

I used an Anet A8 3D printer and 1.75 mm green PLA to print out all the body parts. It took me about 11 hours to print the main body and around 4 hours to print the front cover.

I will highly recommend to use another printer for you that is Creality CR - 10. Now a mini version of the CR-10 is also available.The Creality printers are one of my favorite 3D Printer.

As I am new to 3D designing, my design was not optimistic.But I am sure, this enclosure can made by using lesser material ( less print time ). I will try to improve the design later.

My settings are:

Print Speed : 40 mm/s

Layer Height : 0.2

Fill Density : 15%

Extruder Temperature : 195 degC

Bed Temp : 55 degCr

Step 11: Installing the Solar Panel and Battery

Solder a 22 AWG red wire to the positive terminal and black wire to the negative terminal of the Solar panel.

Insert the two wires in to the holes in the roof of the main enclosure body.

Use super glue to fix the Solar Panel and press it some time for proper bonding.

Seal the holes from the inside by using hot glue.

Then insert the battery holder in to the slot at the bottom of the enclosure.

Step 12: Installing the Antenna

Unscrew the nuts and washers in the SMA connector.

Insert the SMA connector in to the holes provided in the enclosure.See the image above.

Then tighten the nut along with the washers.

Now install the antenna by properly aligning with the SMA connector.

Step 13: Installing the Circuit Board

Mount the standoffs at 4 corners of the circuit board.

Apply super glue at the 4 slots in the enclosure. Refer the above picture.

Then align the standoff with the 4 slots and place it.leave some to dry it out.

Step 14: Close the Front Cover

After printing the front cover, it may be not perfectly fit to the main enclosure body.If it is the case, just sand it at the sides by using a sand paper.

Slide the front cover in to the slots in the main body.

To secure it, use duct tape at the bottom.

Step 15: Programming

To use Wemos D1 with the Arduino library, you'll have to use the Arduino IDE with ESP8266 board support. If you haven't already done that yet, you can easily install ESP8266 Board support to your Arduino IDE by following this tutorial by Sparkfun.

Following settings are preferable :

PU Frequency:
80MHz 160MHz

Flash Size: 4M (3M SPIFFS) – 3M File system size 4M (1M SPIFFS) – 1M File system size

Upload Speed: 921600 bps

Arduino Code for Blynk App :

Sleep Mode :

The ESP8266 is a pretty power hungry device. If you want your project to run off a battery for more than a few hours, you have two options:

1. Get a huge battery

2.Cleverly put the Thing to sleep.

The best choice is the second option.Before using the deepsleep feature, Wemos D0 pin must be connected to the Reset pin.

Credit : This was suggested by one of the Instructables user " tim Rowledge ".

More Power Saving Option :

The Wemos D1 Mini has a small LED that lights when the board is powered.It consume lot of power.So just pull that LED off the board with a pair of pliers. It will drastically drop the sleep current down .

Now the device can run for long time with a single Li Ion battery.

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space<br>#include < ESP8266WiFi.h>
#include  <BlynkSimpleEsp8266.h ></p><p>
#include "Seeed_BME280.h"
#include < Wire.h>
BME280 bme280;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "3df5f636c7dc464a457a32e382c4796xx";// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "SSID";
char pass[] = "PASS WORD";
void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  Serial.begin(9600);
  if(!bme280.init()){
  Serial.println("Device error!");
  }
}

void loop()
{
  Blynk.run();
  
  //get and print temperatures
  float temp = bme280.getTemperature();
  Serial.print("Temp: ");
  Serial.print(temp);
  Serial.println("C");//The unit for  Celsius because original arduino don't support speical symbols
  Blynk.virtualWrite(0, temp); // virtual pin 0
  Blynk.virtualWrite(4, temp); // virtual pin 4
  //get and print atmospheric pressure data
  float pressure = bme280.getPressure(); // pressure in Pa
  float p = pressure/100.0 ; // pressure in hPa
  Serial.print("Pressure: ");
  Serial.print(p);
  Serial.println("hPa");
  Blynk.virtualWrite(1, p); // virtual pin 1
  //get and print altitude data
  float altitude = bme280.calcAltitude(pressure);
  Serial.print("Altitude: ");
  Serial.print(altitude);
  Serial.println("m");
  Blynk.virtualWrite(2, altitude); // virtual pin 2  //get and print humidity data
  float humidity = bme280.getHumidity();
  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.println("%");
  Blynk.virtualWrite(3, humidity); // virtual pin 3
  ESP.deepSleep(5 * 60 * 1000000); // deepSleep time is defined in microseconds.
}

Step 16: Install Blynk App and Library

Blynk is an app that allows full control over Arduino, Rasberry, Intel Edision and many more hardware.It is compatible for both Android and IPhone.Right now the Blynk app is available with free of cost.

You can download the app from the following link

1. For Android

2. For Iphone

After downloading the app, installed it on your smartphone.

Then you have to import the library on to your Arduino IDE.

Download the Library

When you run the app for the first time, you need to sign in – so enter an email address and password. Click the “+” at the top-right of the display to create a new project.Then name it.

Select the target hardware " ESP8266 "Then click “E-mail” to send that auth token to yourself – you will need it in the code

Step 17: Make the Dash Board

The Dashboard is consists of different widgets.To add widgets follow the steps below :

Click “Create” to enter the main Dashboard screen.

Next, press “+” again to get the “Widget Box”

Then drag 4 Gauges.

Click on the graphs,it will pop up a settings menu as shown above.

You have to change the name "Temperature",Select the Virtual Pin V1, then change the range from 0 -50.Similarly do for other parameters.

Finally drag a graph and repeat the same procedure as in gauge settings.The final dashboard picture is shown in the above picture.

You can change the color also by clicking the circle icon on the right side of the Name.

Step 18: Uploading Sensor Data to ThingSpeak

First create an account on ThingSpeak.

Then create a new Channel on your ThingSpeak account.
Find How to Create a New Channel

Fill Field 1 as Temperature ,Field 2 as Humidity and Field 3 as pressure.

In your ThingSpeak account select “Channel” and then “My Channel”.

Click on your channel name.

Click on “API Keys” tab and copy the “Write API Key”

Open the Solar_Weather_Station_ThingSpeak code .Then write your SSID and Password.

Replace the “WRITE API ”with the copied “Write API Key”.

Required Library : BME280

Credit : This code is not written by me .I got it from the link given in a YouTube video by plukas.

Step 19: Final Test

Place the device on sunlight, the red led on TP 4056 charger module will lit up.

1. Blynk App Monitoring:

Open the blynk project.If everything is Ok,you will notice the gauge will live and the graph stat to plot the temperature data.

2. ThingSpeak Monitoring :

First open your Thingspeak Chanel.

Then go to “Private View” tab or “Public View” tab to see the Data Charts.

Thanks for reading my Instructable.

If you like my project, don't forget to share it.

Microcontroller Contest 2017

First Prize in the
Microcontroller Contest 2017

8 People Made This Project!

Recommendations

  • Clocks Contest

    Clocks Contest
  • Casting Contest

    Casting Contest
  • Planter Challenge

    Planter Challenge
user

We have a be nice policy.
Please be positive and constructive.

Tips

10 Questions

0

Hello !

I tried to make your project, but I have a problem with deepsleep. It only wakes up once and immediatly hangs... I also tried wiring GPIO16 (D0) to RST, as shown on other tutorials, with always the same result. Please help me !

0

Hello and thank you for your answer. I added \n to the serial println command, but on first wake, I dont't see it. Just junk characters. But don't worry, I'll keep on my project with the Lolin Nodemcu wich is working fine ! Have a good day.

3 more answers

Hi johweb, I have not had problems with using deep sleep on various instances of Wemos D1 mini pro. Your problem may be in the particular instance of the Wemos you are using - ie a hardware problem. However I am a bit puzzled by your latest message.

You say you have added "Serial.println("pass here!") in the setup() section.

My question is do you get this message printed on the serial monitor when the WeMos first starts, but not when it wakes up after deep sleep, when you just get junk characters?

One possibility is that the junk characters are disguising the message from your software. I suggest you modify your added statement to include a new line, so it reads:

"Serial.println("\npass here!")

Good luck,

Keith

0

Hi famerkeith and thanks for your answer.

Well, no, I'm not using Blink but my own code. I already added

Serial.begin(9600);

Serial.println("pass here !");

on my setup. But I never had the message. It always hangs on boot (after junk characters). Anyway, I bought the Wemos D1 from a cheap AliExpress shop, and I'm not sure what model it is exactly (nothing written on it). It seems Wemos are not appropriates for deepsleep. I uploaded my code on a Lula Nodemcu, and it's working great, so the code is not guilty.

The hardware seems guilty... What a pity, I must use the Wemos for my project.

Hi johweb, You are right it is necessary to connect D0 to RST (which I forgot about in my answer to the question under Comments below (from PitrP).

Are you using Blynk? If so, it may be that it is taking a long time to re-start the Blynk process. Two suggestions to get started:
a) in the setup() section, just after Serial.begin(9600) line, add a new line such as:
Serial.println("\n Solar Powered Weather Station");
This will tell you whether the software is getting to that point, or getting stuck before that.

b) In the early part of the software, there is a line that looks like this:
// #define BLYNK_PRINT Serial // debug printing from library enabled

Just delete the first two characters (the //) which will make the line active and give you some print outs of how the Blynk connection is proceeding. It seems likely to me that this is where your problem is.

Please report back with the results.
Keith

So if i see this right. The Thingspeak Sketch has no Deepsleep. I'm no Programmer, but is it possible to get a Deepsleep Feature in there too? I'm using Thingspeak for some other things and would like to use it for my solar Weatherstation. But i am not shure if the ESP8266 would discharge the Battery too fast without the deepsleep feature.

Hi th.deppe. I have not been using the Thingspeak version, but I am sure it is possible to add the Deep Sleep feature to it. Some other users may know it Thingspeak requires a new login at every wake up.

Please see my answer to comments below to PitrP with a bit of discussion about the deep sleep options.

Also you need to connect the D0 pin to RST on the Wemos board, which is how the sleep timer is able to wake up the processor.

If you need more guidance on the details, please reply with your question(s).

Keith

1

Hello, first of all thank you for this interesting project. I builded the solar weather station as you suggested and all the electronics seems to work fine. I'm writing to you beccause I've encountered some practical issues during the daily utilization and I would receive some suggestions in order to improve the measurements. My station is located on the balcony and it receives direct sunlight only in the afternoon. I've added the possibility to monitor the battery charge and and I've noticed that the solar panel is able to charge the battery only during the hours with direct sunlight. In this few hours the temperature measure raises quickly becaming useless (for example: from 20°C without direct sunlight they can be reached 38°C when the house is fully illuminated).
I would like to know if that is a common situation and if it is normal that the solar panel is able to charge the battery only with direct sunlight. I can see that the the red led on the charging circuit turns on even without direct sunlight.
Thank you.

Hi mauber, I think that the only real solution is to separate the solar panel and the temperature sensor physically. For example, put the solar panel away from the enclosure, connected by wires.

If you just put the complete enclosure, with solar panel, in a shady place, you may get enough light to charge the battery provided you have the sleep time long enough.

2 more answers

The radiation energy (read: current) received from the indirect sunlight is not enough to charge the battery.(Although, it is enough to light up the LED). Temperature is increased because the radiation is absorbed by the house.

0

Thanks for the reply. I imagined that the reason for the anomalous reading was due to the radiation absorbed by the house. I was trying to confirm that this experience was not an isolated case. Do you have any idea to solve this problem? It would be nice if the sensor could read an useful temperature even when the house is completely exposed.
Thank you.

Mauro

Hello, and thank you for the great instruction. I build the solar-weather-station with the parts you suggested, but have a broblem with the TP4056 or the solar panel. With little sunlight the TP4056 has a red light, so it is loading the battery, but in direct sunlight the red light turns of. While this the D1 mini is in sleep mode. I messured the the output of the solar panel and got 4V with little sun and 8V with full sun. So I gues with full sun the input current is too hight. Is it unsefull to add an LM2596 DC-DC Step down between solar panel and TP4056 or is there another problem? thank you.

Try to limit the voltage across the input terminal(pad) to 5V. In one of my project, this solved the problem as TP4056 has internal circuitry to cut out charging if high voltage is detected. Check if lower voltage helps.

Hello bishaldutta, i use the solar from this instruction and already tried another one with the same result. Today I did some tests by only conecting the solar panel + tp4056 and the battery. As soon as the panel gets the full sun the tp4056 shuts down, i messured 6,25 V at the panel. Today i ordered a new tp4056, maybe the one i got has some issues.

Hi allesreiniger, I do not think it is useful to add a DC-DC step down between the solar panel and the TP4056.

I think you need to check the voltage on your battery both in full sun and in shade. If the battery is working well, it should be at least 3.7V.

On my implementation, I am using Blynk and sleep mode with the WeMos waking up every 10 minutes to send a report, and then going badk to sleep. The WeMos is reporting the battery voltage as well as the temperature and pressure. The battery voltage rises to a maximum of 4.1 Volts during the morning, then drops over night to a minimum up 3.8V.

If the sleep part of the cycle is too short, the battery discharges too much, the panel cannot recharge it during the day, and the battery is likely to fail.

0

Hello, I made this wonderful project and it worked, but i got it offline for a while and now it connects, write one line of something and then doesnt work anymore.. any help?

https://ctrlv.cz/3MDM

Hi Flexomat, I think you need to figure out where the problem is.

Two suggestions to get started:

a) in the setup() section, just after Serial.begin(9600) line, add a new line such as:

Serial.println("\n Solar Powered Weather Station");

This will tell you whether the software is getting to that point, or getting stuck before that.

b) In the early part of the software, there is a line that looks like this:

// #define BLYNK_PRINT Serial // debug printing from library enabled

Just delete the first two characters (the //) which will make the line active and give you some print outs of how the Blynk connection is proceeding. It seems likely to me that this is where your problem is.

Please report back with the results.

Keith

0

I keep getting the error missing wire.h? Am I missing a certain library I am not aware of?

-------------------------------

Arduino: 1.8.5 (Windows 10), Board: "WeMos D1 R1, 80 MHz, 4M (3M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 921600"

C:\Users\Athruz\Desktop\sketch_apr09a\sketch_apr09a\sketch_apr09a.ino:4:19: fatal error: Wire.h: No such file or directory

#include < Wire.h>

^

compilation terminated.

exit status 1

Error compiling for board WeMos D1 R1.

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

179 Comments

Has anyone tried to add wind and rain measurements?

Cool project by the way:)

Hello, I built this project and it's measuring data perfectly but i have problems with charging the battery. At first everything was working properly, data was sent to Blynk and I could see it on my phone. But then battery got under some voltage and weather station died. I measured voltage with multimeter and it looks like output of solar panel is somewhere between 4 and 5.5 V depending on level of brightnes. Red LED on TP4056 is on and I thought that battery is charging but after half day on my balcony, voltage of battery didn't get higher than 3V. When I measured OUT pins of TP4056 there were no curent. Can you please sugest somthing that could be problem?

3 replies

Hello PitrP, I had similar problems myself. Are you using sleep mode for the WeMos board? If not, I think that the solar panel may not be able to keep up with the power consumption of the WeMos.

For a start, I think you should try plugging in a USB cable with mains power into the TP4056 and leave it for at least a few hours (maybe a day). That should get your battery fully charged. It would be worth while to measure the battery voltage as well as the output voltage of the solar panel.

I have been running my implementation with a 10 minute sleep cycle for several months now with no battery problems. I found that with a 1 minute sleep cycle the panel could not keep up with the power usage. I have not tried periods in between 1 and 10 minutes.

I am also using the WeMos to measure its own Vcc (effectvely the battery voltage) and reporting that to Blynk, so that I can see how the voltage varies through the day. Typically the daily cycle goes from 3.8V early in the morning to 4.1V when the full sun is on the panel.

Hi farmerkeith,

Can you please share the implementation with a 10 minute sleep for the WeMos board? I am having the same issues like PitrP and can't figure out how to enable the sleep mode of the Wemos board.

Thank you in advance :)

Hi ПреславВ,

Yes I am happy to share all that I have on this topic.

In the hardware you need to connect pin D0 to the RST pin. On the WEMOS D1 mini pro it is just a short link. This is to allow the timer that counts the sleep time to wake up the processor when the time has expired.

Then in the software there are (at least) three levels.

"Basic" sleep:

To put your WeMos D1 mini Pro to sleep, you use the instruction

ESP.deepSleep(sleepTime);

In this instruction, sleepTime is a long integer in microseconds. You can define the value in a const declaration at the beginning of your code, or just type a number into the instruction. You just put the instruction in your code at the point where you want the microcontroller to go to sleep.

For example to sleep for 1 second you type:

ESP.deepSleep(1000000); // sleep for 1 second

You should be aware that when the microcontroller wakes up at the end of sleepTime, it starts from the beginning. It has no memory of what happened before it went to sleep. If you want to carry information from one cycle to the next, you need "Advanced" sleep (the last one I mention below).

"Improved" sleep: the instruction is the same, but what I do is a bit of arithmetic to make the wake times line up with a given period. Like this:

// declaration before setup() section:
const long reportingTime=60000 ; // 60 seconds in milliseconds
// code at the point of going to sleep:
long sleepTime = reportingTime - millis(); // in milliseconds
if (sleepTime <1000) sleepTime = 1000; // set minimum sleep of 1 second
ESP.deepSleep(sleepTime * 1000); // convert to microseconds

With this code, the period of the sleep (sleepTime) is reduced by the awake time, so that the total of sleep and awake stays the same, provided awake time is not longer than the reportingTime value.

Using Blynk, the microcontroller has to log in to Blynk every time it wakes up. This time is variable, which is why adjusting the sleep time becomes relevant if you want a fixed reporting interval.

"Advanced" sleep

You can use "Improved" sleep as above, together with some way of storing data while the ESP8266 is asleep. Various possibilities are explained in my Instructable on the BMP280, which you can find at

https://www.instructables.com/id/Library-for-BMP280

As an example, I put the code for 2 functions into my sketches as follows:

void saveCounter(byte counter){ // write value of counter into bmp1
bmp1.updateF4ControlSleep(counter&0x3F); // store counter
bmp1.updateF5ConfigSleep((counter/64)&0x3F); // store counter
}

Calling this function just before going to sleep saves the value of counter in the BMP280 memory.

byte recoverCounter(){ // read value of counter back from bmp1
byte bmp1F4value= bmp1.readF4Sleep(); // 0 to 63
byte bmp1F5value= bmp1.readF5Sleep(); // 0 to 63
return bmp1F5value*64+bmp1F4value; // 0 to 4095
}

Calling this function in setup() recovers the value of counter from the BMP280 memory.

To make these work, you need the BMP280 library that I have written. There is a link in the Instructable (as well as a lot more explanation) and also here:

https://github.com/farmerkeith/BMP280-library

Back to your original question: How to do a 10 minute sleep?

// declaration before setup() section:

const long reportingTime=60000 * 10 ; // 10 minutes in milliseconds

// code at the point of going to sleep:

long sleepTime = reportingTime - millis(); // in milliseconds

if (sleepTime <1000) sleepTime = 1000; // set minimum sleep of 1 second

ESP.deepSleep(sleepTime * 1000); // convert to microseconds

I keep getting the error missing wire.h? Am I missing a certain library I am not aware of?

2 replies

Hi JohnG591, Yes you are missing the library wire.h. Normally it is included by default in your IDE, but there is a different version needed for the ESP8266 which you can get from here:

https://github.com/esp8266/Arduino

Arduino: 1.8.5 (Windows 10), Board: "WeMos D1 R1, 80 MHz, 4M (3M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 921600"

C:\Users\Athruz\Desktop\sketch_apr09a\sketch_apr09a\sketch_apr09a.ino:4:19: fatal error: Wire.h: No such file or directory

#include < Wire.h>

^

compilation terminated.

exit status 1

Error compiling for board WeMos D1 R1.

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

Good afternoon . How are you? Forgive my limited knowledge of English. I have soldered the components on the PCB board, I have installed the codes of the following programs:

Solar_Powered_Weather_Station.ino -> Here I put the Token of the Blynk application.

Solar_Weather_Station_ThingSpeak.ino -> Here I put the api_key that I get from the page thingspeak.com

I have entered the two schedules and I have not had any problems ... But I can not get the weather station to detect me in the Blynk program. And the thingspeak page does not register the data. That is, I have put the programming to the station but I can not read the data anywhere.

Could you help me please?

Thank you very much

3 replies

Hi brosvv1, Maybe I can help you best with the Blynk version.

I think you should try removing the comment-out slashes in line 28, so as to enable serial printing from the Blynk library. So this line will now read

#define BLYNK_PRINT Serial // Comment this out to disable prints and save space

If you can't work out what is the problem, please post the output from the serial monitor here so that I can look at it, and may be able to give further advice.

Good afternoon, how are you?I tried to make the weather station work but I have not succeeded, I have deleted the line that you mention to me but it does not do anything to me, I have looked through the serial monitor and it does not show me any information. The station shows the red light blinking, but I can not gather any information. Could you help me? Thank you very much

Best regards

Hi borsvv1, I am sorry about the delay I must have missed your reply.

Do you mean, the serial monitor is blank (no content at all) or do you mean there is nothing useful there? If it is showing nothing at all, it is probably because its settings are different from the software. If it is showing something, anything at all, please post it in your reply.

Hi all, I have build it and have a working prototype with the Blynk and Thingspeak. My question is what kind of distance can I expect for the wireless connection with the external antenna.

Regards Geoff

1 reply

I have been getting about 50 metres with the external antenna and about 20 metres with the built-in antena. It depends a lot on the local conditions, including the base station that you are using and obstacles in between the base and your project hardware.

Hello, i know this error was here countless time but i tried all the tips below and didnt work.. so if you have some new tip i would be gratefull..

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

4 replies

Hi Rengatharu, Can you post a more complete version of the output, going from the time compilation is finished to the end?

Have you tried uploading your sketch multiple times and it fails every time?

What are the settings you are using in the Tools menu?

I hope we can help you. Keith

Hello, sorry for late answer, i didnt notice your response. I tried multiple times, i even installed 1.6.5 ide version as someone suggested me on reddit.

Here is more complete version, i hope this is what you ment:

sptool v0.4.12 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
setting board to nodemcu
setting baudrate from 115200 to 921600
setting port from to COM1
setting address from 0x00000000 to 0x00000000
espcomm_upload_file
espcomm_upload_mem
SetCommState call failed
setting serial port timeouts to 1000 ms
opening bootloader
resetting board
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
read 0, requested 1
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
read 0, requested 1
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
read 0, requested 1
resetting board
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
read 0, requested 1
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
read 0, requested 1
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
read 0, requested 1
resetting board
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
read 0, requested 1
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
read 0, requested 1
trying to connect
flush start
setting serial port timeouts to 1 ms
setting serial port timeouts to 1000 ms
flush complete
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
read 0, requested 1
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed

I used to use same settings in tools as shown in the project, in 1.6.5 version there are more options but i tried to keep it same.

Should i try to solder GPIO0 and GPIO15 pins to GND?

Hi Rengatharu,

I think the first thing you should do is unplug the WeMos from the circuit board and try the upload to it, without anything connected to its pins. If that fails as above, you almost certainly have a faulty WeMos.

Try the same thing with another WeMos - that is, upload not plugged in to anything. If that fails as well, you may need to try different hardware combinations - eg a different USB cable, a different USB port on your computer.

For example, here is what I see in the bottom window of my IDE (v1.8.5) when I open a brand new (blank) sketch and upload it to a WeMos D1 mini pro. The big different occurs on about line 8 of what you sent, including the word "failed".

Good luck!

Keith

Archiving built core (caching) in: /tmp/arduino_cache_624375/core/core_esp8266_esp8266_d1_mini_CpuFrequency_80,UploadSpeed_921600,FlashSize_4M3M_5599fd7b37e9acceacc41dbccdf043b5.a
Sketch uses 221919 bytes (21%) of program storage space. Maximum is 1044464 bytes.
Global variables use 31484 bytes (38%) of dynamic memory, leaving 50436 bytes for local variables. Maximum is 81920 bytes.
/home/guy/.arduino15/packages/esp8266/tools/esptool/0.4.9/esptool -vv -cd nodemcu -cb 921600 -cp /dev/ttyUSB0 -ca 0x00000 -cf /tmp/arduino_build_451683/sketch_jan13a.ino.bin
esptool v0.4.9 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
setting board to nodemcu
setting baudrate from 115200 to 921600
setting port from /dev/ttyUSB0 to /dev/ttyUSB0
setting address from 0x00000000 to 0x00000000
espcomm_upload_file
espcomm_upload_mem
opening port /dev/ttyUSB0 at 921600
tcgetattr
tcsetattr
serial open
opening bootloader
resetting board
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: receiving 2 bytes of data
espcomm_send_command: receiving 2 bytes of data
espcomm_send_command: receiving 2 bytes of data
espcomm_send_command: receiving 2 bytes of data
espcomm_send_command: receiving 2 bytes of data
espcomm_send_command: receiving 2 bytes of data
espcomm_send_command: receiving 2 bytes of data
espcomm_send_command: receiving 2 bytes of data
Uploading 226064 bytes from /tmp/arduino_build_451683/sketch_jan13a.ino.bin to flash at 0x00000000
erasing flash
size: 037310 address: 000000
first_sector_index: 0
total_sector_count: 56
head_sector_count: 16
adjusted_sector_count: 40
erase_size: 028000
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
setting timeout 15000
setting timeout 100
espcomm_send_command: receiving 2 bytes of data
writing flash
................................................................................ [ 36% ]
................................................................................ [ 72% ]
............................................................. [ 100% ]
starting app without reboot
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: receiving 2 bytes of data
closing bootloader