Alvaro Morales
Published © GPL3+

Solar Weather Station

This weather station is based on the esp8266 microcontroller and sends all the data to Thingspeak.

IntermediateWork in progress2 hours782
Solar Weather Station

Things used in this project

Hardware components

Adafruit Feather HUZZAH with ESP8266 WiFi
Adafruit Feather HUZZAH with ESP8266 WiFi
×1
Li-Ion Battery 1000mAh
Li-Ion Battery 1000mAh
×1
Battery charger tp4056
×1
Adafruit Solar Panel 6V 5W
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
SparkFun Atmospheric Sensor Breakout - BME280
SparkFun Atmospheric Sensor Breakout - BME280
×1
PTS 645 Series Switch
C&K Switches PTS 645 Series Switch
×1

Software apps and online services

Arduino IDE
Arduino IDE
ThingSpeak API
ThingSpeak API

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

Schematics

Code

Code

Arduino
#include <Wire.h> 
#include <ESP8266WiFi.h> 
#include <WiFiClient.h>
#include <ThingSpeak.h>
#include "cactus_io_BME280_I2C.h" //Presin

const char* ssid = "***********";  
const char* password = "**********";  
WiFiClient client;  
unsigned long myChannelNumber = *********;  
const char * myWriteAPIKey = "**********"; 

float rocio = 0;

const int analogInPin = A0;
float sensorValue = 0;
float voltaje = 0;


//BH1750 lightMeter;
BME280_I2C bme(0x76);  

void setup(){

  Serial.begin(115200);

// Connect to WiFi network  
  Serial.println();  
  Serial.println();  
  Serial.print("Connecting to ");  
  Serial.println(ssid);  
  WiFi.begin(ssid, password);  
  while (WiFi.status() != WL_CONNECTED)  
  {  
   delay(500);  
   Serial.print(".");  
  }  
  Serial.println("");  
  Serial.println("WiFi connected");  
  // Print the IP address  
  Serial.println(WiFi.localIP());  
  ThingSpeak.begin(client);

  //Activar luxmetro
  Wire.begin(D2,D1);
 // lightMeter.begin();
  Serial.println(F("BH1750 Test begin"));

  //Iniciamos sensor de presin
  Serial.println("Bosch BME280 Barometric Pressure - Humidity - Temp Sensor | cactus.io"); 
  if (!bme.begin()) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }
  bme.setTempCal(-1);
  Serial.println("Pressure\tHumdity\t\tTemp\t\tTemp");
  
}

void loop() {

/*VOLTAJE*/
  Serial.print("Voltaje: ");
  Serial.print(voltaje);
  Serial.println(" V");
  delay(1000);

/*Voltaje placa solar*/
sensorValue = analogRead(analogInPin);

  Serial.print("sensor = ");
  Serial.println(sensorValue);

  voltaje = (sensorValue*4.12)/666;
  Serial.println(voltaje);
  Serial.println("V");

  
/*SENSOR DE PRESION*/
   bme.readSensor(); 
   float presion = bme.getPressure_MB();
   float humedad = bme.getHumidity();
   float temperatura = bme.getTemperature_C();
    Serial.print(bme.getPressure_MB()); Serial.print("\t\t");    // Pressure in millibars
    Serial.print(bme.getHumidity()); Serial.print("\t\t");
    Serial.print(bme.getTemperature_C()); Serial.print(" *C\t");

    // add a 5 second delay to slow down the output
    delay(5000);
    rocio=((pow(humedad/100,0.125)*(100+temperatura)-100));

/*THINGSPEAK*/
  ThingSpeak.setField(1,voltaje);
  ThingSpeak.setField(2,presion);
  ThingSpeak.setField(3,humedad);
  ThingSpeak.setField(4,temperatura);
  ThingSpeak.setField(5,rocio);
  ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
  delay(5000);
   
   //Deep Sleep
   client.stop();
 
          Serial.println("Sleeping... 20 minutes");
          //SleepMode
          ESP.deepSleep(1.08e9,WAKE_RF_DEFAULT);
          delay(1000);

}

Credits

Alvaro Morales
4 projects β€’ 3 followers

Comments