This project includes an Arduino-based weather station, an ASP.NET Core MVC data presentation page, and an ASP.NET Core WebAPI. The collected data is sent using ESP8266 and written to the SQL Server database via WebAPI. The weather station consists of the following parts:
- Arduino Nano
- Nano Shield
- AM2320 - Digital Temperature and Humidity Sensor
- BMP280 - Barometric Pressure and Altitude Sensor
- ML8511 - UV sensor
- GP2Y1010F45 - Optical Dust Sensor
- DS3231 - RTC
- ESP8266 - WIFI
- SD card module
- 18650 Li-ion and Charger (Optional)
Most of the referenced libraries come from Adafruit and Aduino Playground, and some I don't know who written it. AM2320 comes from thakshak.
GitHub: https://github.com/ZhangGaoxing/weather-station-arduino
Arduino ConnectionI2C Sensors
- VCC - 5V
- GND - GND
- SDA - A4
- SCL - A5
- ML8511
ML8511
- VIN - 3.3V
- OUT - A0
- GND - GND
- EN - 3.3V
- 3.3V - A1
GP2Y1010F45
- Sharp pin 1 (V-LED) - 5V (Series 150Ω resistor, pin 1 and resistance connected to 220 μF capacitor and grounded)
- Sharp pin 2 (LED-GND) - GND
- Sharp pin 3 (LED) - pin 4
- Sharp pin 4 (S-GND) - GND
- Sharp pin 5 (Vo) - A2
- Sharp pin 6 (Vcc) - 5V
ESP8266
- TX - pin 3
- RX - pin 2
- CH_PD - pin 5
- VCC - 3.3V
- GND - GND
SD Card
- MOSI - pin 11
- MISO - pin 12
- CLK - pin 13
- CS - pin 10
Connect sensors to Arduino.
- Open "WeatherStation.sln" and rebuild solution
- In project API, WebPage, open Startup.cs, change connection string
- In project API, open Controllers - WeatherController.cs, change token
- Open Tools - NuGet Package Manager - Package Manager Console, change Default project to Utility
in PMC run this
Add-Migration
InitialUpdate-Database
or use SSMS run this SQL
CREATE DATABASE WeatherStation
CREATE TABLE [dbo].[Weathers] (
[ID] INT IDENTITY (1, 1) NOT NULL,
[DateTime] DATETIME2 (7) NOT NULL,
[Temperature] FLOAT (53) NOT NULL,
[Humidity] FLOAT (53) NOT NULL,
[Pressure] FLOAT (53) NOT NULL,
[Dust] FLOAT (53) NOT NULL,
[UV] FLOAT (53) NOT NULL,
CONSTRAINT [PK_Weathers] PRIMARY KEY CLUSTERED ([ID] ASC)
);
- Publish API, WebPage to your server
- Copy libraries to x:\Program Files (x86)\Arduino\libraries
- Open "WeatherStation.ino"
- In Line 134, replace your WIFI name and password
- In Line 139, replace your server address and port
- In Line 150, replace your Token
- In Line 155, replace your Host
- Upload program to your Arduino
http://weatherstation.zhangyue.xin/
Comments
Please log in or sign up to comment.