loading

Wanted to make a sensor interface with web interface? Imagine using a simple LDR to measure light and seeing the live updates on a web dashboard!

If you want to do something cool like this, you are at the right place!

Step 1: What Do You Need?

Boards & Parts:

1) LinkitONE Board

2) Grove light sensor (or LDR)

3) Battery pack

Tools:

1) Cutter/Dremel

2) Some tape to sticking up things

Web Services:

1) Ubidots.com account

Step 2: Assemble the Parts

Now we will assembly some parts!

First of all we'll need to hook up the WiFi antenna. Do this by pushing it in the back of the wifi port as shown in the image.

Step 3: Setup the Web Service

1) Go to Ubidots.com and then sign up
2) Log into you dashboard

3) Click on the sources button

4) Click on add source

5) Select Arduino as source

6) Name it as you want

7) Now you have successfully make your account!

8) Now click on add variable

9) Chose a line chart

10) Name your variables and add different icons to them

11) Create all of them and then go to your dashboard

12) In the dashboard, make widget and save it as we will need it afterwards.

Step 4: Writing Some Code

Now the time comes to write some code!

Algorithm:
We want our device to get all sensor data > Push sensor data to cloud > Get the sensor data on our application.

Copy the code in your arduino IDE and then replace the VARIABLE IDs and TOKEN with tokens and IDs in your Ubidots.com account.

CODE:

------------

#define WIFI_AP "iPhone" #define WIFI_PASSWORD "helloworld1" #define WIFI_AUTH Edison WIFI_WPA // choose from EDISONWIFI_OPEN, LWIFI_WPA, or LWIFI_WEP.

// Ubidots information #define URL "things.ubidots.com" #define TOKEN "YOUR_TOKEN" // replace with your Ubidots token generated in your profile tab #define VARIABLEID "SUNLIGHT_ID" #define VARIABLEID1 "TEMPRATURE_ID" //temprature #define VARIABLEID2 "DUST SENSOR_ID" //dust #define VARIABLEID3 "AIR_SENSOR_ID" // air quality Barometer myBarometer; float temperature; unsigned long duration; unsigned long starttime; unsigned long sampletime_ms = 3000; unsigned long lowpulseoccupancy = 0; float ratio = 0; float concentration = 0; int counter = 0; void setup() { pinMode(8,INPUT); Serial.begin(9600); myBarometer.init(); // keep retrying until connected to AP Serial.println("Connecting to AP"); while (0 == EdisonWiFi.connect(WIFI_AP, EdisonWiFiLoginInfo(WIFI_AUTH, WIFI_PASSWORD))) { delay(1000); } } void loop() { temperature = myBarometer.bmp085GetTemperature(myBarometer.bmp085ReadUT()); //Get the temperature, bmp085ReadUT MUST be called first duration = pulseIn(8, LOW); lowpulseoccupancy = lowpulseoccupancy+duration; ratio = lowpulseoccupancy/1000; // Integer percentage 0=>100 concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; save_value(String(analogRead(A0)), String(temperature), String(concentration), String(analogRead(A2))); delay(500); } void save_value(String value, String a, String dust, String crow){ Serial.println("Sending value to Ubidots..."); EdisonWiFiClient c; while (!c.connect(URL, 80)) { Serial.println("Retrying to connect..."); delay(100); } String data = "{\"value\":"+ value + "}"; String thisLength = String(data.length()); // Build HTTP POST request c.print("POST /api/v1.6/variables/"); c.print(VARIABLEID); c.print("/values?token="); c.print(TOKEN); c.println(" HTTP/1.1"); c.println("Content-Type: application/json"); c.println("Content-Length: " + thisLength); c.print("Host: "); c.println(URL); c.print("\n" + data); c.print(char(26)); data = "{\"value\":"+ a + "}"; thisLength = String(data.length()); // Build HTTP POST request c.print("POST /api/v1.6/variables/"); c.print(VARIABLEID1); c.print("/values?token="); c.print(TOKEN); c.println(" HTTP/1.1"); c.println("Content-Type: application/json"); c.println("Content-Length: " + thisLength); c.print("Host: "); c.println(URL); c.print("\n" + data); c.print(char(26)); ////////////////////////////////////////////////////////// data = "{\"value\":"+ crow + "}"; thisLength = String(data.length()); // Build HTTP POST request c.print("POST /api/v1.6/variables/"); c.print(VARIABLEID3); c.print("/values?token="); c.print(TOKEN); c.println(" HTTP/1.1"); c.println("Content-Type: application/json"); c.println("Content-Length: " + thisLength); c.print("Host: "); c.println(URL); c.print("\n" + data); c.print(char(26)); /////////////////////////////////////////////////////////////////// data = "{\"value\":"+ dust + "}"; thisLength = String(data.length()); // Build HTTP POST request c.print("POST /api/v1.6/variables/"); c.print(VARIABLEID2); c.print("/values?token="); c.print(TOKEN); c.println(" HTTP/1.1"); c.println("Content-Type: application/json"); c.println("Content-Length: " + thisLength); c.print("Host: "); c.println(URL); c.print("\n" + data); c.print(char(26)); ////////////////////////////////////////////////////// // read server response while (c){ Serial.print((char)c.read()); } c.stop(); }

--------------

Dont forget to edit the tags with your variable ID and account ID

Also change the wifi information as your wifi SSID and password.

Step 5: Hook Up the Sensor

Now its the time to hook up our sensors.

Take your sensors and then put them in the following ports:

Light Sensor to A0 port

note them carefully as you will need them in your code as well!

Step 6: Testing It Out!

Now you can make a widget and a graph out of this.

Move to your sensor dashboard and observe the graph. You'll see the graph updating!

If your graph is updating every second, it means your project worked!

If not, then check your details like Wifi SSID/password, variable ID etc.

Step 7: Final Touches

Now make a small box for the web interface! You can do this by taking out a box of old bell and putting your LinkitONE inside it!

Also you can embedd code so you can embedd the sensor readings on your own website.

hi please send algorithm code to my email <br>assasin.201236@gmail.com

About This Instructable

216views

7favorites

License:

More by ssarthak598:DIY Smart Home Monitoring Bottle Arduino Video Game (The DIY Gift) Is My Fridge Door Open?! 
Add instructable to: