TIMOTHY MWALA
Published © GPL3+

Build Your Own Wireless Mini-Weather Station.πŸŽ‰

The beauty of local, self-contained communication systems in which Boards, whisper secrets to each other, without an internet connection.

BeginnerFull instructions provided1 hour547
Build Your Own Wireless Mini-Weather Station.πŸŽ‰

Things used in this project

Hardware components

Adafruit 0.66 OLED Display
×1
Wemos D1 Mini
Espressif Wemos D1 Mini
×2
Bosch Wemos Bmp180
×2
96Boards wemos dual board adapter
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

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

Story

Read more

Schematics

set up

Code

Server Code

C/C++
Flash this sketch to the board containing the sensor (BMP180)
#include <ESP8266WiFi.h>
#include "ESPAsyncWebServer.h"
#include <Wire.h>
#include <Adafruit_BMP085.h>  // BMP180 library

// Set your access point network credentials
const char* ssid = "BMP180";
const char* password = "12345678";

Adafruit_BMP085 bmp;  // BMP180 sensor

// Create AsyncWebServer object on port 80
AsyncWebServer server(80);

String readTemp() {
  return String(bmp.readTemperature());
}

String readPres() {
  return String(bmp.readPressure() / 100.0F); // Convert pressure to hPa
}

void setup(){
  // Serial port for debugging purposes
  Serial.begin(115200);
  Serial.println();
  
  // Setting the ESP as an access point
  Serial.print("Setting AP (Access Point)...");
  // Remove the password parameter, if you want the AP (Access Point) to be open
  WiFi.softAP(ssid, password);

  IPAddress IP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(IP);

  server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", readTemp().c_str());
  });

  server.on("/pressure", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/plain", readPres().c_str());
  });
  
  if (!bmp.begin()) {
    Serial.println("Could not find a valid BMP180 sensor, check wiring!");
    while (1);
  }
  
  // Start server
  server.begin();
}
 
void loop(){
  // Your loop code, if needed
}

Client Code

C/C++
flash this code to the board that has the display
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h> // Updated HTTPClient library for ESP8266

const char* ssid = "BMP180";
const char* password = "12345678";

const char* serverNameTemp = "http://192.168.4.1/temperature";
const char* serverNamePres = "http://192.168.4.1/pressure";

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64 // Update this to match your display resolution
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

String temperature;
String pressure;

unsigned long previousMillis = 0;
const long interval = 5000;

void setup() {
  Serial.begin(115200);

  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);
  }

  display.clearDisplay();
  display.setTextColor(WHITE);
  display.setTextSize(1);

  WiFi.begin(ssid, password);
  Serial.println("Connecting");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to WiFi network with IP Address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    if (WiFi.status() == WL_CONNECTED) {
      temperature = httpGETRequest(serverNameTemp);
      pressure = httpGETRequest(serverNamePres);

      display.clearDisplay();
      display.setCursor(35, 18);
      display.print("Temperatur");
      display.setCursor(40, 30);
      display.print(":" + temperature + "*C");// temperature in degree symbol
      display.setCursor(35, 42);
      display.print("Pressure");
      display.setCursor(35, 55);
      display.print(":" + pressure + "Pa");

      display.display();

      previousMillis = currentMillis;
    } else {
      Serial.println("WiFi Disconnected");
    }

Credits

TIMOTHY MWALA

TIMOTHY MWALA

24 projects β€’ 14 followers
I am an Embedded engineer who like prototyping

Comments