How to Make Pocket Sized IoT Weather Station
COPIA DA PAGINA
How to Make Pocket Sized IoT Weather Station
https://www.instructables.com/How-to-Make-Pocket-Sized-IoT-Weather-Station/
How to Make Pocket Sized IoT Weather Station
24.710
315
32
Featured
Introduction: How to Make Pocket Sized IoT Weather Station
Hello reader!
In this instructable you will learn how to make small Weather Cube using the D1 mini(ESP8266) which is connected to your home WiFi, so you can look at it's output anywhere from earth, of course as long as you have internet connection. Overall making this project isn't too difficult nor resource heavy, so it will be perfect as your first IoT project. So let's get started.
PS: Keep in mind that this is my first Instructable so not everything will be perfect. :)
Step 1: Resources
As I mentioned in the introduction, this project is very easy to construct and doesn't require too much components. Here is the parts list:
Electronic Components:
WeMos D1mini
BME280
I2C OLED Display(128x64)
1.5mm Brass Rod or Iron Rod
NOTE: If you want more info about theese parts for ex. where to get them, you can look into Step 7!
Tools for prototyping and testing the circuit:
Breadboard
Jumper wires
USB wire - Micro USB Type B to USB Type A
Tools:
Soldering iron
Bench vice - not mandatory
Small hammer - not mandatory
Step 2: Prototyping on Breadboard (Skip to Step 3 If You Want to Go Straight to Code and Assembly)
If you don't have your pins soldered on your D1mini/OLED/BME280, now is the time to do it!
First of all lets place all our components on the breadboard. We will start by placing the D1mini on 2 separate rails(picture no.1). After that we will place the BME280 fair distance from it(picture no.2). And finally we will place the OLED on the opposite side of the BME280(picture no.3). Now, let's connect them together.
Here are all the connections:
D1 pin to SCL/SCKpin on the OLED and SCL/SCK pin on the BME280
D2 pin to SDA pin on the OLED and SDA pin on the BME280
G pin to GND pin on both, the OLED and BME280
3.3V pin to BME280 VCC pin
And finally 5V pin to OLED VCC
Check your connections again before connecting it to your computer and uploading code to it! You don't want to burn anything.
Step 3: IoT Part
This part is really simple. First of all, go to AppStore and download Blynk app. After that, open it and sign up. Next create new project. I called mine WeatherStation but you can name it anything you want. After that, set the device option to ESP8266 and connectivity type to WiFi(picture no.1). Next tap create project. You shoul get an email with your verification token. Now jump into the code(download link below) and replace highlighted parts. After that, jump back into the Blynk app project workspace, tap on the screen to open widget box(picture no.2). Now place 3 labeled value boxes by tapping on them(picture no.3). To set them up, tap on first one and set it's name. I called it temperature(this is not mandatory but it makes everything simpler and more organised). As input select virtual pin 1 and in the label part type "°C"(picture no.4). After that you can go and set up the other labeled values.
Here is small chart:
Labeled value no.2:
Name: Humidity
Input: Virtual pin V2
Label: "%"
Labeled value no.3:
Name: Altitude or pressure - depends on which code you choose
Input: Virtual pin V3
Label: Altitude or pressure - depends on code
If you have done everything correctly, upload your code to D1mini, wait for a little while and then the values should pop up on the OLED and in your Blynk app(picture no.5)(you need to press play button in the top right corner of the screen). If nothing shows up, go to the troubleshooting part.
Step 4: Freeforming the Circuit
Okay, this will be the hardest part so get ready. Prepare your brass rods/iron rods(I will use brass coated iron hooks because I couldn't find brass only rods) and heat up your soldering iron. Now you can form it into anything you want! I will form it into a simple cube. This process requires patience and time, so don't rush it if you don't want to break your whole circuit. You can see the finished circuit in picture no.2. I decided to use 1,5mm rods on the outside, but thinner rods in the insede(1mm) for easier management.
WARNING: Solder only in well-ventilated space, soldering can put out toxic fumes!
TIPS:
For bending rods use bench vice and a small hammer - if you don't have bench vice, nor hammer, pliers and bare hands will be enough.
Use tape or helping hands to hold rods together while you solder them. It's much easier.
OR if you are using iron rods like me, you can use 2 strong magnets to hold them in place(picture no.1).
If your joints don't hold together, unsolder them and roughen them up with sandpaper.
If your solder doesn't flow into the gaps, use a bit of soldering flux or heat up the joint a bit more.
Step 5: Finale
Now the only thing remaining to do is to connect it to 5V 1A PSU. If you have done everything correctly, it should work just fine(don't forget to upload your code if you didn't already). If nothing shows up or something isn't right, jump over to the troubleshooting section.
Step 6: Troubleshooting
Display showing nan: Check your wiring! Your sensor isn't connected propperly.
BME280 outputing 0.0: Check your wiring! Your sensor isn't connected propperly.
Black display/sensor data not showing up: Check your I2C adresses using I2C scanner or check wring.
Device offline in app: Check if you entered your Token/WiFi name/WiFi password correctly. If yes, check your wifi signal. It might be weak or you don't have internet connection.
Still having trouble or you found mistakes in this instructable? Write down in comments and I will get to you ASAP. :)
Step 7: Where to Get Theese Parts?
Are you new in electronics? No problem! Here is brief explanation on some physical parts, how they work and how to get them the cheapest:
1. Where do I get all theese electronic parts?
Aliexpress. By me, Aliexpress is the best site, by far to get all of theese parts for cheap price. The only downside is that basic shipping is usually takes a lot of time (Anywhere from 2 Weeks to 1,5 Months).
2. What is BME280?
BME280 is a sensor that can measure Temperature, Relative Humidity and Atmospheric Pressure. It's really convenient to use in theese small form-factor aplications like pocket sized electronics. More about it here.
NOTE: D1mini, BME280 and OLED display were all ordered from AliExpress.
https://www.bosch-sensortec.com/products/environmental-sensors/humidity-sensors-bme280/
*******************************************************************************
//ALTITUDE CODE BY ViktorDemcak
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSans9pt7b.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET 0
#define SEALEVELPRESSURE_HPA (1013.25)
#define BLYNK_PRINT Serial
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_BME280 bme;
unsigned long delayTime;
float temperature;
char auth[] = "YourToken";
char ssid[] = "Your WiFi Name";
char pass[] = "WiFi password - leave blank if it's open.";
void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // DISPLAY I2C adress - should be the same as mine but if not, go to https://playground.arduino.cc/Main/I2cScanner/, upload it to your D1mini and check the adress.
bme.begin(0X76); // BME280 I2C adress should be the same as mine but if not, go to https://playground.arduino.cc/Main/I2cScanner/, upload it to your D1mini and check the adress.
display.clearDisplay();
display.setTextColor(WHITE);
display.setFont(&FreeSans9pt7b);
display.display();
Blynk.begin(auth, ssid, pass);
}
void loop() {
delay(100);
display.clearDisplay();
display.setCursor(10,15);
display.println(bme.readTemperature());
Blynk.virtualWrite(V1, bme.readTemperature());
display.setCursor(60,15);
display.println(" C");
display.drawCircle(60,6,2, WHITE);
display.setCursor(10,35);
display.println(bme.readHumidity());
Blynk.virtualWrite(V2, bme.readHumidity());
display.setCursor(60,35);
display.println("%");
display.setCursor(10,55);
display.println(bme.readAltitude(SEALEVELPRESSURE_HPA));
Blynk.virtualWrite(V3, bme.readAltitude(SEALEVELPRESSURE_HPA));
display.setCursor(70,55);
display.println("meters");
display.display();
}
******************************************************************************
//ATMOSPHERIC PRESSURE CODE BY ViktorDemcak
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSans9pt7b.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET 0
#define BLYNK_PRINT Serial
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
Adafruit_BME280 bme;
unsigned long delayTime;
float temperature;
char auth[] = "YourToken";
char ssid[] = "Your WiFi Name";
char pass[] = "WiFi password - leave blank if it's open.";
void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // DISPLAY I2C adress - should be the same as mine but if not, go to https://playground.arduino.cc/Main/I2cScanner/, upload it to your D1mini and check the adress.
bme.begin(0X76); // BME280 I2C adress should be the same as mine but if not, go to https://playground.arduino.cc/Main/I2cScanner/, upload it to your D1mini and check the adress.
display.clearDisplay();
display.setTextColor(WHITE);
display.setFont(&FreeSans9pt7b);
display.display();
Blynk.begin(auth, ssid, pass);
}
void loop() {
delay(100);
display.clearDisplay();
display.setCursor(10,15);
display.println(bme.readTemperature());
Blynk.virtualWrite(V1, bme.readTemperature());
display.setCursor(60,15);
display.println(" C");
display.drawCircle(60,6,2, WHITE);
display.setCursor(10,35);
display.println(bme.readHumidity());
Blynk.virtualWrite(V2, bme.readHumidity());
display.setCursor(60,35);
display.println("%");
display.setCursor(10,55);
display.println(bme.readPressure() / 100);
Blynk.virtualWrite(V3, bme.readPressure()/100 );
display.setCursor(80,55);
display.println("hPa");
display.display();
}
******************************************************************************
******************************************************************************
Comentários
Postar um comentário