Controlling home appliance with bolt

First of all, I would like to thank the team for creating such a good tutorial. :slight_smile:
I am making a basic project to control my home appliance(bulb, etc) using relay with bolt via cloud.
So here’s the code


but, after the code is deployed and clicking on the bolt name on the home screen and then clicking on the ON button, there’s no response.
so, please guide me the changes I’ve to make.

Hi @raunak.rtu

To control your led using bolt cloud, you have to pass on more parameter in command that is the device name. bolt.js is not written for bolt cloud. It is written for local control.

digitalWrite?pin=0&state=LOW&deviceName={{ Name }}
When you type Name in curly braces in html page , It is automatically replaced by device name .

You can refer this code. I am using jquery ajax to make it more simple. You can use normal ajax also.

<!DOCTYPE html>
<html lang="en">
   <head>
      <title>LED</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
   </head>
   <body align="center">
      <button onclick="LedOn()"> LED On</button>
      <button onclick="Ledff()"> LED Off</button>
   </body>
   <script>
      function LedOn(){
      $.ajax({
                    type: 'GET',
                    url: "/digitalWrite?pin=0&state=HIGH&deviceName={{ Name }}",
                    contentType: false,
                    processData: false,
                    dataType: 'json',
                    success: function(response) {
                       responseData = response;
                       console.log(responseData);
                    }
                });
      }
      
      function LedOff(){
      $.ajax({
                    type: 'GET',
                    url: "/digitalWrite?pin=0&state=LOW&deviceName={{ Name }}",
                    contentType: false,
                    processData: false,
                    dataType: 'json',
                    success: function(response) {
                       responseData = response;
                       console.log(responseData);
                    }
                });
      }
   </script>
</html>

Let me know in case you need further assistance

Thanx for help @rahul.singh
But I don’t know programming in Ajax/Json.
If you have the code in HTML/JavaScript, do share with me.

I’m unable to get the output using this code via cloud. please check the code to control the direction of a robot.

x



use this code and change the number of the D_NAME variable into your bolt device number

if you want to use the device for controlling home appliances from cloud you can use this below given code

Thanx for your help bro. But there’s an error !!!

yaah, I changed the name wherever it was told.

do one thing the (var D_NAME=“BOLT791645”) is in the comment line remove it from comment line and give your bolt number and no need to give your bolt device number for every line

sir how to connect rely with bread board for home appliances project?

note i do not have rely module i just have rely

plz reply

Hi @nitishsrivastav75,

I will suggest you use the relay module because the only relay is not safe for Bolt. One small mistake on relay connection and you can burn your Bolt device. Check this link https://www.hackster.io/boltmakers/home-automation-8cc388

Do let me know in case you need further asistance.

Sir my project is turning on and off led using Google assistant
I
My led is not glowing sir,