IoT powered weather logging with graphing capability.

in arduino •  7 years ago  (edited)

It's my first post so I'd like to say hello! ;)


I want to share with you my DIY project I've completed sometime ago. Which I'm using to see what temperature is in my house, well - In each room.


Take a look:

Pretty simple, right? That's what best about it. 

The dashboard looks like this:

And now how It's made..

The hardware consists of:

  • NodeMCU ( esp8266 ) ( 3$ on Aliexpress )
  • BME280 ( 6$ on Aliexpres )
  • Breadboard ( 0,6$ on Aliexpress )
  • Some wires

At total cost of no more than 10$ you're getting very accurate sensor and a micro-controller with built-in Wi-FI, with an ability to add more sensors, for example PM10/PM2,5 sensor. ;)

It works like this.. ESP2866 is connected to my home Wi-FI network, every 10 seconds it sends a POST request to my InfluxDB database, that's installed on my server, with everything that's needed: 

  • Id of esp8266 
  • Temperature
  • Humidity
  • Pressure

Here's the full ready to use code, I'm using this library for BME280.. You can easily change the frequency, or the units in which the output is presented, metric or not, and every kind of pressure unit.

#include "ESP8266WiFi.h"

#include <BME280.h>

#include <Wire.h>



// WiFi parameters

const char* ssid = "";

const char* password = "";



// InfluxDB parameters

const int Port = ;

const char* host = "";



int freq = 10; // In seconds



String id = "6"; // Ids of each esp8266 unit, in case of multiple units.



// BMP280 settings

BME280 bme;

uint8_t pressureUnit(1); // unit: 0 = Pa, 1 = hPa, 2 = Hg, 3 = atm, 4 = bar, 5 = torr, 6 = N/m^2, 7 = psi

bool metric = true;



float temp(NAN), hum(NAN), pres(NAN);



String host_db = "ESP82660" + id;



void setup() {



WiFi.mode(WIFI_STA);

WiFi.begin(ssid, password);



while (WiFi.status() != WL_CONNECTED)

{

delay(500);

}



Wire.begin(4, 5);



while (!bme.begin()) {

delay(1000);

}

}



void loop() {



WiFiClient client;



if (!client.connect(host, Port)) {

return;

}



bme.ReadData(pres, temp, hum, metric, pressureUnit);



String PostTemp = "temperature,host=" + host_db + " value=" + String(temp);

String PostHum = "humidity,host=" + host_db + " value=" + String(hum);

String PostPres = "pressure,host=" + host_db + " value=" + String(pres);



client.println("POST /write?db=name_of_database&u=username&p=password HTTP/1.1");

client.println("Host: " + String(host));

client.print("Content-Length: ");

client.println(PostHum.length() + PostHum.length() + PostPres.length() + 4);

client.println();

client.print(PostTemp + "\n" + PostHum + "\n" + PostPres);

client.println("Connection: close");

client.println();



delay((freq - 4) * 1000);



}


I hope You'll like this! Here it is again steemit like the mess up the formatting: https://gist.github.com/ireun/306571c2b44e82720080ed6fbd7ce81a


IreuN.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

hi @ireun

Wow, you are a very talented person, and you have succeeded in building such a thing for a home. I do not know why you need it, but all the respect for your creativity and I hope that in the future you will build something that will move the world and change our thinking. I see that it is not as simple as you say. If you had a few more smart people like you, you would create something that would change the world. Today we were in a different situation, because like I said all the time I was in Thailand and I see the situation here of the people and it's just crying from what's happening here. Despair a lot of success in life!
@ravivshachar

Congratulations @ireun! You have received a personal award!

1 Year on Steemit
Click on the badge to view your Board of Honor.

Do not miss the last post from @steemitboard!


Participate in the SteemitBoard World Cup Contest!
Collect World Cup badges and win free SBD
Support the Gold Sponsors of the contest: @good-karma and @lukestokes


Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Congratulations @ireun! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

The Steem community has lost an epic member! Farewell @woflhart!
SteemitBoard - Witness Update
Do not miss the coming Rocky Mountain Steem Meetup and get a new community badge!
Vote for @Steemitboard as a witness to get one more award and increased upvotes!
  ·  7 years ago Reveal Comment