Things used in this project

Hardware components:
DFRobot FireBeetle ESP32 IOT
×1
DFRobot Gravity - I2C BME280
×1
DFRobot 3.7V Polymer Lithium Ion
×1
DFRobot Solar Lipo Charger
×1
6V 1W Solar Panel
×2
Perfboard
×1
Female Header
×1
Software apps and online services:
Enclosure
Hand tools and fabrication machines:
Hy gluegun
Hot glue gun (generic)
09507 01
Soldering iron (generic)

Schematics

Schematic
More info in the tutorial
Sch 1 go2se2oopv

Code

IoT Weather StationArduino
#include <WiFi.h>
#include <WiFiMulti.h>

WiFiMulti WiFiMulti;

const char* ssid     = "YOUR_SSID"; // Your SSID (Name of your WiFi)
const char* password = "YOUR_WIFI_PASSWORD"; //Your Wifi password

const char* host = "api.thingspeak.com";
String api_key = "YOUR_API_KEY"; // Your API Key provied by thingspeak

//Library for BME280 Sensor
#include <DFRobot_BME280.h>

#define SEA_LEVEL_PRESSURE  1013.25f

DFRobot_BME280 bme; //I2C

float temp, pressure, hum, alt; //Variables for the BME280 Sensor

//Library for ESP Sleep
#include "esp_deep_sleep.h"

#define uS_TO_m_FACTOR 60000000   // Conversion factor for micro seconds to minutes
#define TIME_TO_SLEEP  1        // Time ESP32 will go to sleep (in minutes)


void setup() {

  Serial.begin(115200);
  delay(10);

  Connect_to_Wifi();

  // I2c default address is 0x77, if the need to change please modify bme.begin(Addr)
  if (!bme.begin()) {
    Serial.println("No sensor device found, check line or address!");
  }

  delay(100);

  Get_Values();

  Send_Data();


  esp_deep_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_m_FACTOR);

  Serial.println("Going to sleep now");

  esp_deep_sleep_start();


}

void loop() {
  // put your main code here, to run repeatedly:

}


void Get_Values()
{

  temp = bme.temperatureValue();
  delay(100);

  pressure = bme.pressureValue() / 100.0F;
  hum = bme.humidityValue();
  alt = bme.altitudeValue(SEA_LEVEL_PRESSURE);

  delay(100);

  Serial.println("Collect data");

  Serial.print("Temperature :");
  Serial.print(temp);
  Serial.println(" C");

  Serial.print("Pressure:");
  Serial.print(pressure);
  Serial.println(" hPa");

  Serial.print("Humidity :");
  Serial.print(hum);
  Serial.println(" %");

  Serial.print("Approx. Altitude:");
  Serial.print(alt);
  Serial.println(" m");

  Serial.println("------END------");

  //Place BME280 into sleep mode
  BME280_Sleep();

}


void Connect_to_Wifi()
{

  // We start by connecting to a WiFi network
  WiFiMulti.addAP(ssid, password);

  Serial.println();
  Serial.println();
  Serial.print("Wait for WiFi... ");

  while (WiFiMulti.run() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

}

void Send_Data()
{

  Serial.println("Prepare to send data");

  // Use WiFiClient class to create TCP connections
  WiFiClient client;

  const int httpPort = 80;

  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
    return;
  }
  else
  {
    String data_to_send = api_key;
    data_to_send += "&field1=";
    data_to_send += String(temp);
    data_to_send += "&field2=";
    data_to_send += String(hum);
    data_to_send += "&field3=";
    data_to_send += String(pressure);
    data_to_send += "\r\n\r\n";

    client.print("POST /update HTTP/1.1\n");
    client.print("Host: api.thingspeak.com\n");
    client.print("Connection: close\n");
    client.print("X-THINGSPEAKAPIKEY: " + api_key + "\n");
    client.print("Content-Type: application/x-www-form-urlencoded\n");
    client.print("Content-Length: ");
    client.print(data_to_send.length());
    client.print("\n\n");
    client.print(data_to_send);

    delay(1000);
  }

  client.stop();



}

void BME280_Sleep()
{

  //Serial.println("BME280 to Sleep mode");

  Wire.beginTransmission(0x77);
  Wire.write((uint8_t)BME280_REGISTER_CONTROL);
  Wire.write((uint8_t)0b00);
  Wire.endTransmission();
}

Credits

Me
Hugo Gomes

http://www.hugogomes.net

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Happy Plant Notifier
Intermediate
  • 299
  • 5

Full instructions

Get a text or call if your plant is getting too dry, along with a nice LCD display giving information regarding your plant's health.

How to Make a Temperature Gun With ESP32
Intermediate
  • 98
  • 2

Full instructions

What a hot day it is! Too hot to drive and ride and I am thinking of making a temperature measurement sensor.

Lattepanda Weather Bot - Weather API & Google Cloud Service
Intermediate
  • 125
  • 2

Full instructions

This project shows you how to make a weather bot using python to get real-time weather data, and use DFrobot Lattepanda as SBC.

Arduino IR Universal RX/TX, but Different
Intermediate
  • 79
  • 1

Work in progress

Universal IR receiver and transmitter for home automation and replica of any IR remote control (air conditioners included); uses WAMP.

Distance Measurement Vehicle via Websocket
Intermediate
  • 9,206
  • 59

Full instructions

A vehicle measures distance with an encoder on its wheel. It is remotely controlled and transmits the distance via Websocket.

Otto DIY+ Arduino Bluetooth robot easy to 3dprint
Intermediate
  • 12,587
  • 59

Work in progress

"Otto DIY with steroids" + Bluetooth + APP + switch + sensors + strength +...

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog