Arduino YUN IoT for Home monitoring

Arduino YUN IoT for Home monitoring © CC0

Practicing with IoT using dweet.io service from YUN.

  • 2,989 views
  • 1 comment
  • 2 respects

Components and supplies

About this project

Use of the httpclient library to create a "thing" in dweet.io using an Arduino YUN.

/* LDR CONECTION.
----------------------------------------------------
         LDR 10K     10K
+5 o---/\/\/--.--/\/\/---o GND
                                |
 A0 o---------'
----------------------------------------------------
LM35 CONNECTION

Front view of the encapsulation. From left to right.

  • Pin 1 --> +5V in the YUN
  • Pin 2 --> Output to the A1 in the YUN.
  • One 10kOhm resistor from this point to the GND.
  • Pin 3 --> GND in the YUN

Code

Room monitoring, temperature and light just using the component LM35 and one LDR dividerArduino
The input from theLM35 sensor is connected to the Analog input A1, its value is multipled by 0.4689455791989076 to convert it in ºC and proper calibration. One 10KOhm resistor from this point to the GND is needed to stabilize the Reading.
The center point from the divider of 10kOhm resitor and the LDR is connecte to the Analog input A0, its value is mapped from its min and max values meassured with min and max lighting to scale it into a range from 0 to 100, like of the 0 - 100% of the room lighting values.
The Timestamp of the readying is also added.
#include <Bridge.h>
#include <HttpClient.h>
int analogIn = A0; int analogVal = 0; int analogIn1 = A1; int analogVal1 = 0;int light = 0;
float temp;
void setup() {
  // Bridge takes about two seconds to start up
  // it can be helpful to use the on-board LED
  // as an indicator for when it has initialized
  pinMode(13, OUTPUT);
  digitalWrite(13, LOW);
  Bridge.begin();
  digitalWrite(13, HIGH);
}

void loop() {
// Initialize the client library
String dataString;
  analogVal = analogRead(analogIn);analogVal1 = analogRead(analogIn1);
  light=map(analogVal,0,1024,0,100);// To convert Analog values to % of luminosity
  temp=analogVal1*0.4689455791989076; //Sensor Calibration
  HttpClient client;
  dataString += getTimeStamp(); // CAll routine to obtain current timestamp from the linino side of the YUN
  // Make a HTTP request:To send analog input values of A0 and A1
  client.get("http://www.dweet.io/dweet/for/YUN_ANALOG_IN_DWEETING?A0_Home_Light="+String(light)+"&A1_Home_Temp="+String(temp)+"&TimeStamp="+String(dataString)+"&Visit=https://www.hackster.io/Rjuarez7");
  delay(1000); // To give time to the server for answering
}

String getTimeStamp() {
   String result;
   Process time;
   time.begin("date");
   time.addParameter("+%D-%T");  
   time.run(); 
   while(time.available()>0) {
     char c = time.read();
     if(c != '\n')
       result += c;
   }
   return result;
}

Schematics

Preliminary reading before go to the project.
This PDF shows preliminary Reading and actions that I did before do the final Project. It can be interesting for begginers.

Comments

Similar projects you might like

Introduction to the Blynk IoT service

by Rafa Juárez

  • 2,355 views
  • 1 comment
  • 9 respects

Plant Monitoring System using AWS IoT

Project tutorial by CJA3D

  • 30,463 views
  • 6 comments
  • 77 respects

Smart Personal Money Vault Monitoring System Based on IoT

Project tutorial by Salah Uddin

  • 849 views
  • 0 comments
  • 6 respects

IoT Blink - Getting started with IoT

Project showcase by AppShed Support

  • 2,026 views
  • 0 comments
  • 11 respects

IoT@School: An IoT Implementation for Monitoring Air Quality

Project showcase by Koen Kempeneers

  • 5,750 views
  • 1 comment
  • 24 respects
Add projectSign up / Login