Weather Station IoT

 

PROJECT: Weather Station IOT

Introduction

In the beginning, I try to learn , what is the meaning of IOT and what can do with use this technology. My supervisor give me the topics for learning coding for IoT system. In my projects, I have used these technologies.

Nodemcu ESP 8266:

  • MQTT client
  • Sensor Coding: Rain, Ldr, Pressure, Temperature, Humidity

Node.js:

  • MQTT client
  • Database using MongoDB
  • Chart.js
  • Socket programing with Socket.io

Raspberry Pi 3:

  • MQTT server

Hardware Part

In my projects, I try to use cheap and useful components. For example, NodeMcu board is more useful than Arduino Uno for this projects also It have wifi module with interval and cheaper than Arduino Uno.

Equipment

  • 4 Nodemcu Esp8266
  • 1 Raspberry Pi
  • 2 Rain Sensor
  • 4 LDR (Light Sensor)
  • 2 BMP 180 (Pressure Sensor)
  • 4 DHT11 (Temperature and Humidity Sensor)
  • 4 Buzzer
  • 4 Led
  • 3 10k Resistor
  • 2 Diode 1N4001 1A 50V
  • Jumper
  • 3.7 V Battery

Nodemcu Esp8266

 

Nodemcu is have own WiFi module and also have 1 Analog I/O and 8 Digital I/O. Also Nodemcu allows deep sleep system with using timer. The NodeMCU is a development card have the ESP8266 WiFi module with the firmware installed. Developed using the ESP8266 SDK, the Extra supports GPIO, PWM, IIC, 1-Wire and ADC connections without the need for a microcontroller. On the CP2102 USB – Serial converter is integrated. I used this module for communication each other and server.

Raspberry Pi 3

I used raspberry pi for MQTT server and Node.js server. Those server only work in localhost.

Rain Sensor

When this sensor panel be wet resistivity is increase and therefore current is decrease I read these current value and in the Arduino IDE I convert to value my own style. I read analog value with using Nodemcu analog input part.

LDR

When light shows up on the LDR resistivity is decrease so current is increase and I read the current with Nodemcu analog input port and after limiting this value(output) I use these value for Light’s value

DHT11 (temperature and humidity sensor)

I used these sensor with own Arduino library code and these sensor have Analog output

Bmp180 (pressure sensor)

These sensor also have Temperature sensor. I use these sensor with own Arduino library code. Also I calculated altitude with pressure value.

Battery

C:\Users\cceem_000\AppData\Local\Microsoft\Windows\INetCache\Content.Word\WhatsApp Image 2017-08-29 at 10.03.09.jpeg I use this battery with own charger module. I removed this battery to my own power bank. This battery voltage 3.7 V and 2500MaH and this is good for this project.

Circuit

I design to circuit like bellow figure. Also I add to buzzer and Led for some warning. For example when Nodemcu connect internet Buzzer work 1 seconds and try to connect to MQTT server when It connected Buzzer works 3 times in 6seconds. If not connect server buzzer works more times. Therefore I can know Nodemcu works or not without serial monitor. C:\Users\cceem_000\AppData\Local\Microsoft\Windows\INetCache\Content.Word\F3F4PFPIOLP1KZ9.MEDIUM.JPG

Software Part

In the software part of my projects is contain Web and Arduino programing.

Arduino

Firstly, Nodemcu is connect the WiFi and after that try to connect Mqtt server this server IP is raspberry pi’s IP and start to 10000msec delay time. It means, Nodemcu send to Sensor values to raspberry pi server each 10 sec. Also you can change this delay time with using website.

 

Mqtt

Nodemcu is the client of the server for send value. In this case each Nodemcu have specific topic and message. Message contains to sensor value and topic contains the Which Nodemcu send this message. For example; “client.publish(“wheather/station/1”, message); “wheather/station/1” is the topic of the message it means this Nodemcu is the 1.Station. You can see my code link end of the report.

Mqtt Callback

Also Nodemcu can receive message come from other client for example (web site). You can change delay time and you can set sleep time. I design to callback function for these. Callback function listen to Server for specific topics. These are “wheather/command/1/delay” and “wheather/command/1/sleep” when receive these topics message change to delat time or sleep time

Node.js

I use Node.js for Website, Database and Mqtt Server.

You can contact me for Node.js proect file

Web Site

I design to theme with using CSS and EJS. Ejs is similar to HTML but EJS is more useful and work with Node.js. Also I used to Socket.io for when values come to server page is not change only value is changed so Website is not use a lot of cache memory. Also I used to Node.js Express for more functional structure for Website. Also I visualized old data and live data with Chart.js graph

Chart.js

Chart.js is the best graph library for Node.js . Also these graphs is dynamic and live. I can use all data in the same graph. Above graph is the live data for station 1. It show only 10 new data. You can change display for example You can show only Altitude and Temperature value and close other values showing. Also secon figure show old values graph with using MongoDB database C:\Users\cceem_000\AppData\Local\Microsoft\Windows\INetCache\Content.Word\2.png

Socket.io

Socket.io is one of the socket programing library for javascript. Usually this use for chat application. However, I use this library for live data what came from sensors. Also these socket.io change icon in case of value that came from sensors. C:\Users\cceem_000\AppData\Local\Microsoft\Windows\INetCache\Content.Word\1.png

Icon

These icon changes in the webpage with sensors data. Give the status for weather station. For example(cloudy, rainy, humid, sunny, dark, bright, hot, cold ,etc). In the above figure show Status and live values with using socket.io

Bootstrap

I use bootstrap for design display website with using css and html . Bootstrap allows the table visualization and display settings for all kind of resolutions.

Database

I use to MongoDB for database, MongoDB is noSQL database therefore I can save big data without table so I can use these data fastly. Above figure show the database query you can show the results with chart or value. Bellow figure shows query result value C:\Users\cceem_000\AppData\Local\Microsoft\Windows\INetCache\Content.Word\5.png

Mqtt Server

For the Mqtt server, I use Mosca library for Node.js Mqtt application and I use port 1883 for Mqtt server. In this Mosca library is one of the socket programing. Also It is very simple.

Problems

I encountered a few problems and difficulties while working on the project. These are often software problems. Since I was not familiar with Node.js, I learned a lot about it, so I had difficulty writing the database and communication codes. For example, MongoDB save date with ISODate format but Chart.js can’t handle this format but I can change to ISOdate to String format. So I change manually format in loop. Also Communication not fast enough If I start to all 4 station and sensor with 1 seconds delay time. Server receive all data without any drops but Socket.io can’t handle these data therefore Webpage can’t show all data without lost data. And localserver can’t handle big traffic. In other problem is the Nodemcu sleep system I can turnoff the Nodemcu with specific time but I can wake the sleep before the scheduled time. I want to wake Nodemcu with using ping but I can’t find to how to do it.

Development

First of all, My projects communication system works only localhost. We can development this and I can reach all station other internet connection. For this, I install the VPS system in Raspberry Pi for create own hosting for projects. Also I can develop sleep system if I can solve the problem that mentioned above. I can add the battery life for each station. Also Web –page can be professional dashboard and add the machine learning and data analyze for big data.

 

 

3 thoughts on “Weather Station IoT

Leave a Reply

Your email address will not be published. Required fields are marked *