Introduction: Bolt With ThingSpeak : Live Data From LDR

I will connect LDR sensor to BOLT and collect live data from LDR sensor and send it to ThingSpeak.

ThingSpeak is an open source Internet of Things (IoT) application and API to store and retrieve data from things using the HTTP protocol over the Internet or via a Local Area Network. ThingSpeak enables the creation of sensor logging applications, location tracking applications, and a social network of things with status updates.

Here I am using ThingSpeak to retrieve live data from LDR sensor .After collecting data we can analyze and visualize the data with MATLAB.

Here are the steps:

Step 1: Setting Up Bolt

First step is to connect the BOLT to a Wi-Fi network.

  • The BOLT creates its own hotspot when you power it on for the first time
  • Download NetPlug App from playstore.
  • First time it will create its own Wi-Fi hotspot.Connect your mobile Wi-Fi to BOLT hotspot to switch on your BOLT.
  • Open NetPlug app and click on the BOLT icon.Then click on configure button and it will take you to the BOLT setting page where u have to put the details of the Wi-Fi network to which you want to connect your BOLT.Click on save and restart.
  • Turn on your wifi.
  • Now BOLT will restart and try to connect to the Wi-Fi network
  • If BOLT is properly connected then the blue light will stop blinking and it becomes stable
  • Now we have to find the IP address of the BOLT.Advanced IP Scanner can be used to do that.
  • Now type that IP address in the browser
  • You will see index.htm page on the screen.

Step 2: Getting Started With ThingSpeak

  • Open https://thingspeak.com and create a new account.No need to create a account if you have one.
  • Open your account
  • Click on new channel
  • A channel stores the data that we send to thingspeak
  • Channel will consists 8 for fields for storing data of any type,3 location filed nad 1 status field.
  • A page will be open
  • Enter the Channel name and fill other fields too
  • Save the channel
  • Now click on ApI key and copy the key.We will be needing this key later.

My channel id is 297949.

Step 3: Connect LDR to Bolt

  • What is LDR

LDR stands for Light Dependent Resistor or Photoresistor, which is a passive electronic component, basically a resistor which has a resistance that varies depending of the light intensity and on changing r resistance,voltage also varies.

The resistance is very high in darkness, almost high as 1MΩ but when there is light that falls on the LDR, the resistance is falling down to a few KΩ depending on the model.

So,according to the light falling on the LDR,Resistance varies and with the help of volatge we can calculate the present resistance of LDR.

  • Connect LDR to BOLT

To connect the LDR connect one end of LDR to gnd and other to A0.

To connect the resistor connect one end of resistor to A0 and other to gnd.

LDR and resistor are in series.

Step 4: Write Html Code and Test It

  • After connecting LDR to bolt its time to write the code

The extension of file must be .htm

The function analogRead() reads the value at the analog pin that you have chosen – in this case, it is the analog pin A0 ans save it in var r.

Then I used the API update request of thingspeak.In API update request i m passing API key and the value of variable r which contains the LDR sensor data.

After firing this update request our sensor data will be send.

Now time to test the code

  • Connect your laptop to the same network to which bolt is connected
  • For uploading your index.htm type Bolt_ipaddress/developer
  • Now choose your file and click on upload
  • Restart your bolt by typing Bolt_ipaddress/restart
  • Wait for the bolt to get connected to wifi
  • Once bolt is connected type the ip address in browser
  • The current index page will open
  • There is a box for API KEY
  • Type the API KEY which we copied earlier
  • You can also get the API KEY through ThingSpeak site
  • Click on Take reading
  • Now click on pass reading to thingspeak
  • After clicking check the thingspeak site
  • We can see a new entry is made and the graph for sensor data is updated.

Step 5: Check ThingSpeak

We are done.

For the LDR sensor data we can goto ThingSpeak site and see the enteries and graph corresponding to it.