亿迅智能制造网
工业4.0先进制造技术信息网站!
首页 | 制造技术 | 制造设备 | 工业物联网 | 工业材料 | 设备保养维修 | 工业编程 |
home  MfgRobots >> 亿迅智能制造网 >  >> Manufacturing Technology >> 制造工艺

当地气象站

组件和用品

Arduino Nano R3
× 1
Seeed Grove - 气压计传感器 (BMP280)
× 1
DHT11 温湿度传感器(4 针)
× 1
ElectroPeak 0.96" OLED 64x128 显示模块
× 1
GUVA-S12SD 紫外线传感器
× 1
DS3231 RTC
× 1

必要的工具和机器

烙铁(通用)
焊锡丝,无铅
3D 打印机(通用)

应用和在线服务

Arduino IDE
Autodesk Fusion 360

关于这个项目

很长一段时间,我想在不使用互联网的情况下制作一个气象站。测量周围天气数据并在需要时查看数据非常有用。所以,我做了一个看起来很酷的当地气象站,可以测量你周围的气压、温度、湿度和当天的紫外线指数(如果你把它放在靠近窗户的地方)。等等还有更多! 😉 它还有一个时钟屏幕,用于显示时间、日期和星期几。

在本教程中,我将向您展示如何通过这些步骤制作这个凉爽的天气站。

第 1 步:构建外壳

我使用 Autodesk fusion 360 创建外壳并用绿色 PLA 打印。它需要支撑,我在我的 Ender 3 上以 70 毫米/秒的速度以 20% 的填充率打印它。你会在这个项目中找到外壳的 STL 文件。

第二步:BMP280

BMP280 是大气压力和温度传感器,它使用 I2C 或 SPI 协议与 Arduino 通信。这里我使用SPI。使用SPI,连接-

  • CS 到 D10
  • SDA 转 D11
  • SDO 转 D12
  • SCK 到 D13

在代码部分,要使用这个传感器,我们需要一个库。首先,我将库包含在代码中 #include .你可以从这里下载图书馆。

然后我定义传感器的 SPI 引脚。在setup函数中,我初始化了BMP传感器,在loop函数中,我使用bmp.readPressure()读取了压力和温度数据 和 bmp.readTemperature() 命令。我将压力值除以 100 以测量以 hPa 为单位的压力。为了测量高度,我使用 bmp.readAltitude(1005.47) 命令。在这里,您必须更改值 (1005.47) 根据您所在地区的平均气压。

第 3 步:DS3231 RTC

这个气象站还有一个时间屏幕,可以显示弱者的当前时间、日期和日期。为此,我使用了 DS231 RTC 模块,它使用 I2C 协议进行通信。所以要使用这个,连接-

  • SCL 到 A5
  • SDA 转 A4

首先,您必须使用 DS3231_set.ino 在 RTC 上设置时间和日期 来自库示例的程序。

在主程序中,我包含了库 #include 并按照库中的指令读取时间数据。在这里,我使用库中的示例作为代码的参考。我为一周中的每一天创建了一个案例来查找当天。

第 4 步:DHT11

我用这个传感器来测量湿度。为此,我将其数据输出 到 Arduino D2 .在程序中,我包含了 DHT 库 #include 然后在设置中初始化传感器并在循环中使用 dht.readHumidity() 读取湿度值 命令。

第 5 步:GUVA-S12SD 紫外线传感器

GUVA-S12SD 是基于氮化镓的肖特基型光电二极管。其典型的紫外检测波长为 240-370nm(涵盖 UVB 和大部分 UVA 光谱)。它输出一个校准的模拟电压,该电压随紫外光强度而变化。所以,我们可以通过Arduino ADC读取模拟值。

在循环函数中,我模拟读取传感器值并计算紫外线指数

float sensorValue =analogRead(A0);
float sensorVoltage =sensorValue / 1024 * 5.0;
int UV_index =sensorVoltage / 0.1;

第六步:OLED显示

我在这个项目中使用了 0.96" 128*64 OLED 显示器,它使用 I2C 协议,所以我将它连接到 Arduino,如下所示-

  • SCK 到 A5
  • SDA 转 A4

在程序中,首先我包含了 Adafruit_SSD1306 和 Adafruit_GFX 库

#include 
#include

然后我创建显示变量并添加一些位图来显示一些图像。在设置中,我初始化了显示。然后在循环中,我使用 display.print() 显示每个数据 功能。我在四页上显示数据,时间、压力、温度和湿度以及 UV_index。每个页面之间有 5 秒的延迟。

视频剪辑

代码

  • 当地气象站代码
当地气象站代码Arduino
#include #include #include #include #include #include #include #include #include //#include #define SCREEN_WIDTH 128#define SCREEN_HEIGHT 64#define OLED_Reset_SCREEN_SCREEN_RESET130_SCREEN_12pt7b.h> , OLED_RESET);#define BMP_SCK (13)#define BMP_MISO (12)#define BMP_MOSI (11)#define BMP_CS (10)DS3231 clock;bool Century =false;bool h12Flag;bool pmFlag;Adafruit_BMP280 bmp(BMP_CS, BMP_M , BMP_SCK);#define DHTPIN 2#define DHTTYPE DHT11DHT dht(DHTPIN, DHTTYPE);const unsigned char PROGMEM frame0 [] ={0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x000,0x000,0x000 0x01, 0xFF, 0x80, 0x00, 0x00, 0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x3F, 0xFF, 0xFC, 0x00, 0x00, 0x7F, 0x,0,0x,0,0x,0,0x,0,0x,0,0x,0,0x,0,0x,0,0x,0,0x,0 0xF0, 0x00, 0x0F, 0x80, 0x03, 0xE0, 0x18, 0x07, 0xC0, 0x07, 0x86, 0 x18, 0x61, 0xE0, 0x0F, 0x02, 0x00, 0x40, 0xF0, 0x0F, 0x02, 0x00, 0x40, 0xF0, 0x1E, 0x00, 0x00, 0xC,0x0,0x0,0x0,0xC,0x0,0x1, 0x0, 0xC, 0x0, 0x7 0x00时,0×06,为0x3C,为0x3C,0×01,0x80的,0×00,为0x3C,0x38,0x00时,0x80的,0×00,为0x1C,0x38,0x00时,将0xC0,0x00时,为0x1C,0x78,0x00时,取0xE0,0x00时,0X1E,0x79的,将0xC0, 0xF0, 0x03, 0x9E, 0x79, 0xC0, 0x7C, 0x03, 0x9E, 0x78, 0x00, 0x7E, 0x00, 0x1E, 0x38, 0x00, 0x00, 0xC,0xC,0xC,0xC,0xC,0xC,0xC,0xC,0xC,0xC,0xC,0xC,0xC,0xC,0xC,0xC,0xC,0xC, 0xC, 0xC, 0xC, 0xC, 0x03, 0x7E, 0x78, 0xF0, 0x03, 0x9E 0x7E, 0x3F, 0x3C, 0x3C, 0xFE, 0x7E, 0x7F, 0x3C, 0x1C, 0x7E, 0x18, 0x7E, 0x38, 0x1E, 0x3F, 0x00,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF,0xF, 0xF 0xFF, 0xF8, 0xF0, 0x07, 0x87, 0xFF, 0xE1, 0xE0, 0x03, 0xC1, 0xFF, 0x83, 0xC0, 0x03, 0xF0, 0x3C, 0x0x0x0x,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0 0x81, 0xFE, 0x00, 0x00, 0x3F, 0xFF, 0xFC, 0x00, 0x00, 0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x01, 0xFF, 0x,0,0,0x,0,0,00x,0,00,0x,0,0,0 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};const unsigned char PROGMEM frame1 [] ={0x00, 0x00,为0x00,0x00时,0×00,0x00时,0×00,为0x18,0x00时,0×00,0x00时,0×00,的0x7E,0x00时,0×00,0x00时,0×00,0xC3,0x00时,0×00 0×01,0×00,0x9D,0x80的,0×00,×03,0x80的, 0xB4,取0xE0,0x00时,0×06,0x80的,0xA6,0x80的,0×00,×04,将0xC0,0xA6,取0xE0,0x00时,0x0C,0x40的,0xA6,取0xE0,0x00时,0x08时,0x60的,0xA6,0x80的,0×00,0x08时,0×20, 0xA6,取0xE0,0x00时,0x08时,0x60的,0xA6,0x80的,0×00,为0x0E,将0xC0,0xA6,取0xE0,0×00,×03,0x80的,0xA6,0x80的,0x00时,0×00,为0x10,0xA6,将0xC0,0x00时,0×00,0x38, 0xA6,取0xE0,0x00时,0×00,0x38,0xA6,0x80的,0x00时,0×00,0x6C,0xA6,取0xE0,0x00时,0×00,×44,0xA6,0x80的,0x00时,0×00,0x6C,0xA6,取0xE0,0x00时,0×00,0x38, 0xA6,0x80的,0×00,0x00时,0×00,0xA6,0x80的,0×00,0x00时,0×00,0xA4,取0xE0,0x00时,0×00,0x00时,0xA6,0x80的,0x00时,0×00,0x40的,0xA6,取0xE0,0x00时,0×00,将0xC0, 0xA6,0x80的,0×00 0×01,0XA0,0xA6,取0xE0,0×00 0×01,的0x30,0xA6,取0xE0,0×00,×03,为0x10,0xA6,0x80的,0x00时,0×02,为0x18,0xA6,取0xE0,0x00时,0×06,0x08时, 0xA6, 0x80, 0x00, 0x06, 0x08, 0xA6, 0x80, 0x00, 0x02, 0x19, 0xA6, 0xC0, 0x00, 0x03, 0xF3, 0x606, ,为0x00,0x00时,0xC6,0×26,的0x30,0x00时,0×00,0x0C,0xE3,0x10的,0x00时,0×00,×09,0x80的,0x98在全局,0x00时,0×00,0x19,0x00时,0xC8,0x00时,0×00,0×13,0×00,0x6C ,0x00时,0×00,×12,0x00时,0x6C,0x00时,0×00,×12,0x00时,0x6C,0x00时,0×00,×12,0x00时,0x6C,0x00时,0×00,0x1B,0x00时,0x4C,0x00时,0×00,×09,0x80的,0xC8 ,为0x00,0x00时,0x0C,0xC1,0x98在全局,0x00时,0×00,×04,0x7F的,的0x30,0x00时,0×00,0×06,为0x1C,0x60的,0x00时,0×00,×03,0x81表示,将0xC0,0x00时,0×00,0x00时,为0xFF,0x80的, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};const unsigned char PROGMEM frame2 [] ={0xFF, 0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF0 、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF 、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF , 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF F、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、 0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF 0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF 0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF 0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF 0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF 0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0xFF、0 xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80};void setup() { Serial.begin(57600);如果(!display.begin(SSD1306_SWITCHCAPVCC,0x3C)){Serial.println(F(“SSD1306失败”)); Wire.begin(); dht.begin(); if (!bmp.begin()) { Serial.println(F("Problem.bmp"));而(1)延迟(10); } display.clearDisplay(); display.setTextColor(WHITE); display.setTextSize(1); display.setCursor(0, 9); display.setFont(&FreeSans9pt7b); display.println("**** 本地 ****"); display.setCursor(0, 38); display.setFont(&FreeMonoBoldOblique12pt7b); display.println("水"); display.setCursor(27, 58); display.println("车站");显示。显示();延迟(2000); bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* 操作模式。*/ Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */ Adafruit_BMP280::SAMPLING_X16, /* 压力过采样 */ Adafruit_BMPTER2800/* Filtering.::*/ Adafruit_BMP280::SAMPLING_X2 Adafruit_BMP280::STANDBY_MS_500); /* 待机时间。 */}void loop() { //时间显示.clearDisplay(); display.setTextColor(WHITE); display.setTextSize(1); display.setCursor(13, 15); display.setFont(&FreeMonoBoldOblique12pt7b); display.print(clock.getHour(h12Flag, pmFlag)); display.setCursor(38, 15); display.println(":"); display.setCursor(50, 15); display.println(clock.getMinute()); display.setCursor(70, 15); if (pmFlag) { display.println(" PM"); } else { display.println(" AM "); } display.setFont(&FreeSans9pt7b); display.setCursor(20, 60); display.println(clock.getDate()); display.setCursor(40, 60); display.println("/"); display.setCursor(46, 60); display.println(clock.getMonth(世纪)); display.setCursor(65, 60); display.println("/"); display.setCursor(70, 60); display.println("20"); display.setCursor(90, 60); display.println(clock.getYear()); display.setCursor(30, 30); display.setFont(&FreeSans9pt7b); switch (clock.getDoW()) { case 1:display.println("Saturday");休息;情况 2: display.println("星期日");休息; case 3:display.println("星期一");休息; case 4:display.println("星期二");休息; case 5:display.println("星期三");休息; case 6:display.println("星期四");休息; case 7:display.println("星期五");休息; } display.display();延迟(5000); //P display.clearDisplay(); display.drawBitmap(0, 0, frame0, 40, 40, 1); display.setFont(&FreeSans9pt7b); display.setCursor(41, 28); display.println(bmp.readPressure() / 100); display.setCursor(110, 28); display.setFont(); display.println("hPa"); display.setCursor(0, 55); display.setFont(&FreeSans9pt7b); display.println("海拔高度:"); display.setCursor(65, 62); display.println(bmp.readAltitude(1005.47)); display.setCursor(113, 62); display.println("m");显示。显示();延迟(5000); //T&RH display.clearDisplay(); display.setFont(&FreeMonoBoldOblique12pt7b); display.drawBitmap(0, 5, frame1, 40, 51, 1); display.setCursor(35, 30); display.print(bmp.readTemperature()); display.setFont(&FreeSans9pt7b); display.setCursor(102, 28); display.println(" *"); display.setCursor(110, 31); display.println(" C"); display.setFont(); display.setCursor(66, 45); display.println("RH:");字节 RH =dht.readHumidity(); display.setCursor(95, 45); display.println(RH); display.setCursor(110, 45); display.println("%"); display.drawBitmap(0, 56, frame2, 135, 15, 1);显示。显示();延迟(5000); //UV display.clearDisplay();浮动传感器值 =模拟读取(A0);浮动传感器电压 =传感器值 / 1024 * 5.0; int UV_index =sensorVoltage / 0.1; display.setFont(&FreeSans9pt7b); display.setCursor(0, 15); display.print(" UV INDEX "); display.setCursor(58, 45); display.println(UV_index);显示。显示();延迟(5000);}

定制零件和外壳

示意图


制造工艺

  1. 基于树莓派的气象站
  2. Raspberry Pi 2 气象站
  3. Raspberry Pi 气象站
  4. Weather Station V 2.0
  5. 6-Shooter:Arduino 饮料混合站
  6. 多温度传感器
  7. Arduino Powered Weather Balloon Datalogger
  8. $10 便携式 Arduino 气象站 (AWS)
  9. ThingSpeak Arduino 气象站
  10. WiFi ESP8266 和 DHT22 传感器
  11. SmartWristband
  12. 监测健康站