Why I'm unable to connect or sync software(coding) part to the cloud

Hello Team,!
We are performing ‘‘Light Dependent Airlock Door system’’ project on Bolt IOT . We are perfect with the hardware connections part and also with the html software part . But , We are facing the problem at the output . Bolt Cloud is not taking the total coding part into it . Cloud is not responding . How can we dump total coding part into the cloud.? And I’m also getting 404 error and troubleshoot problem .
HOW CAN I SET THAT ERROR.?
Please help me out in this regard.!
Thank you.

@anilamadishetty123
Can you share the code as well as the screenshot of the error that you are getting?

Helloo
@yeshwant.naik,
Thanks for responding!
Here’s the code –

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Door Lock Opener !!!</title>
    <!-- <link rel="shortcut icon" type="image/x-icon" href="1.ico" /> -->
    <script type="text/javascript" src="/serveFile?filename=bolt.js">
      setDebug(true);
    </script>
  </head>
  <body bgcolor="#C2DFFF">
    <h2 Font-family="Arial" align="center"><b>PASSWORD PLEASE</b></h2>
    <p>* Please touch the respective lock pattern to open the door !!! :)</p>
    <button type="button" onclick="lock();">Click here to Unlock !</button>
    <script type="text/javascript">
      var a = 1 ;
      var b = 0 ;
      Voltagedrop1=()=>{
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
              var obj = JSON.parse(xmlhttp.responseText);
              if(obj.success=="1"){
                  if (obj.value >=980){
                    return 1;
                  } else {
                      return 0;
                  }
                } else {
                    return 0;
                }
          }
      }
      xmlhttp.open("GET","/analogRead?pin=A0",true);
      xmlhttp.send();
      }
      Voltagedrop2=()=>{
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                var obj = JSON.parse(xmlhttp.responseText);
                if(obj.success=="1"){
                    if (obj.value >= 980){
                        return 1;
                    } else {
                        return 0;
                    }
                } else {
                     return 0;
                }
            }
        }
      xmlhttp.open("GET","/analogRead?pin=A1",true);
      xmlhttp.send();
      }
      Voltagedrop3=()=>{
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            var obj = JSON.parse(xmlhttp.responseText);
            if(obj.success=="1"){
                if (obj.value >= 980){
                    return 1;
                } else {
                    return 0;
                }
            } else {
                return 0;
            }
        }
      }
      xmlhttp.open("GET","/analogRead?pin=A2",true);
      xmlhttp.send();
      }
      Voltagedrop4=()=>{
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            var obj = JSON.parse(xmlhttp.responseText);
            if(obj.success=="1"){
                if (obj.value >= 980){
                    return 1;
                } else {
                    return 0;
                }
            } else {
                return 0;
            }
        }
      }
      xmlhttp.open("GET","/analogRead?pin=A2",true);
      xmlhttp.send();
    }
      lock=()=>{
      if (a == Voltagedrop1() && b == Voltagedrop2() && b == Voltagedrop3() && b == Voltagedrop4() ) {
        x();
        }else{
            alert("Invalid Password");
        }
      }
      x=()=>{
      if(b == Voltagedrop1() && a == Voltagedrop2() && b == Voltagedrop3() && b == Voltagedrop4() ){
        y();
        }else{
            alert("Invalid Password");
        }
      }
      y=()=>{
      if(b == Voltagedrop1() && b == Voltagedrop2() && a == Voltagedrop3()&& b == Voltagedrop4() ){
        z();
        }else{
            alert("Invalid Password");
        }
      }
      z=()=>{
      if(b == Voltagedrop1() && b == Voltagedrop2() && b == Voltagedrop3() && a == Voltagedrop4() ){
          g();
        }else{
            alert("Invalid Password");
        }
      }
      g=()=>{
      var name = "Your Lock is Unlocked !!!!"; // Declare a local variable
      document.write(name);
      }
      setTimeout(x,500);
      setTimeout(y,500);
      setTimeout(z,500);
    </script>
  </body>
</html>

And I’m getting " Error 404 "
Please check and give me the solution
Thanks. !

@anilamadishetty123

I can not find the code in your previous message. Can you please share the same as a file attachment?

Sorry for the inconvenience.!

Hello
@yeshwant.naik
can you please respond.!
Did you find code in the above link

Hi @anilamadishetty123,

You are following the method of Bolt version-1 and it will not work with Bolt version-2. Refer to this example instead

Also, check this thread What is boltCommands.js?

Do let me know in case you need further assistance.

1 Like

Hello Team,
Thanks for the response.
We actually working on new bolt version and our project works on analog pins . But we have one analog pin and 5 digital pins in new version bolt. How we can connect other analog pins or how can we convert analog to digital.
We stuck in middle of the project.
The programming code is also not working . We tested the code you sent. It’s just showing invalid password dialogue box.
Tell us how we can dump the total coding part into cloud and difference between old version bolt and new version bolt.
We searched old version bolt ,but we couldn’t find it anywhere.
We know that our project works on old version bolt . so, please check out this and help us.!

If you have free digital inputs, you can use an external analog to digital converter.you can also an Arduino board that reads Analog data and sends it via UART… Could you explain what do you want ur project to do. What part have u completed and is working. And what part of are you facing problems.(what do you mean by new version bolt?)

We are performing LIGHT DEPENDENT AIRLOCK DOOR SYSTEM. And we seen in bolt platform that, to perform this project they used old version bolt . Now we are having new version bolt with us. Where we need to connect other 3 analog pins in bolt – confused here and half part of the code is executing and it is showing invalid password dialogue box.

For analog inputs, you can use an external adc/Arduino board. are you running the code yourself or on the bolt cloud?. Also include your code in the reply, so we would be able to help you out.
I am not aware of old version of bolt. Can anyone explain (Is it firmware or hardware?)

Here’s the code

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Door Lock Opener !!!</title>
    <!-- <link rel="shortcut icon" type="image/x-icon" href="1.ico" /> -->
    
    <script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js"></script>

  </head>
  <body bgcolor="#C2DFFF">
    <h2 Font-family="Arial" align="center"><b>PASSWORD PLEASE</b></h2>
    <p>* Please touch the respective lock pattern to open the door !!! :)</p>
    <button type="button" onclick= lock() >Click here to Unlock !</button>
    <script type="text/javascript">
    
    // var api_key = "24aeaed8-b413-4f7a-beb1-xxxx";
    // var d_name = "BOLT74219xx";
    // var base_url = "https://cloud.boltiot.com/remote/"
    // var A0 ="A0"
      var a = 1 ;
      var b = 0 ;
    //   var debug = 0;
      Voltagedrop1=(pin,val)=>{
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
              var obj = JSON.parse(xmlhttp.responseText);
              if(obj.success=="1"){
                  if (obj.value >=980){
                    return 1;
                  } else {
                      return 0;
                  }
                } else {
                    return 0;
                }
          }
      }
      xmlhttp.open("GET","/analogWrite?pin=A0",true);
      xmlhttp.send();
      }
      Voltagedrop2=(pin,val)=>{
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                var obj = JSON.parse(xmlhttp.responseText);
                if(obj.success=="1"){
                    if (obj.value >= 980){
                        return 1;
                    } else {
                        return 0;
                    }
                } else {
                     return 0;
                }
            }
        }
      xmlhttp.open("GET","/analogWrite?pin=A1",true);
      xmlhttp.send();
      }
      Voltagedrop3=(pin,val)=>{
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
              var obj = JSON.parse(xmlhttp.responseText);
              if(obj.success=="1"){
                if (obj.value >= 980){
                    return 1;
                } else {
                    return 0;
                }
            } else {
                return 0;
            }
        }
      }
      xmlhttp.open("GET","/analogWrite?pin=A2",true);
      xmlhttp.send();
      }
      Voltagedrop4=(pin,val)=>{
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
              var obj = JSON.parse(xmlhttp.responseText);
              if(obj.success=="1"){
                if (obj.value >= 980){
                    return 1;
                } else {
                    return 0;
                }
            } else {
                return 0;
            }
        }
      }
      xmlhttp.open("GET","/analogWrite?pin=A3",true);
      xmlhttp.send();
    }
    lock=()=>{
      (a == Voltagedrop1() && b == Voltagedrop2() && b == Voltagedrop3() && b == Voltagedrop4()) ? x() : alert("Invalid Password");
    }
    x=()=>{
      (b == Voltagedrop1() && a == Voltagedrop2() && b == Voltagedrop3() && b == Voltagedrop4()) ? y() : alert("Invalid Password");
    }
    y=()=>{
      (b == Voltagedrop1() && b == Voltagedrop2() && a == Voltagedrop3()&& b == Voltagedrop4()) ? z() : alert("Invalid Password");
    }
    z=()=>{
      (b == Voltagedrop1() && b == Voltagedrop2() && b == Voltagedrop3() && a == Voltagedrop4()) ? g() : alert("Invalid Password");
    }
    g=()=>{
      var name = "Your Lock is Unlocked !!!!"; // Declare a local variable
      document.write(name);
    }
       setTimeout(x,500);
       setTimeout(y,500);
       setTimeout(z,500);
    </script>
  </body>
</html>

We confused there itself. We don’t have other analog inputs. We are using only new bolt version hardware and LDR’s, 1kohm resistors. As we don’t have other analog inputs, the code is not dumping into the cloud.

By new bolt version, do you mean this ?image|690x352 . I don’t understand why you are using LDR for password input(you can use push-buttons).

No, not using that bolt .
Bolt with ESP8266 wifi module, we are using.

And we have seen in bolt platform that to perform this project we have to use ldr’s.!
We choosen this project from bolt platform only.

Hi @anilamadishetty123,

Your code seems incorrect to me.

The below two lines is very important.

<script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js">
  </script>

  <script type="text/javascript">
    // The following line will set the api key and device name. It will be auto-initialized by Bolt cloud.
    setKey('{{ApiKey}}','{{Name}}');
</script>

The setKey function will set the API key and device id as a global variable. You can check the function inside

function setKey(key,dev_name){
    api_key = key;
    d_name = dev_name;
}

api_key and d_name is a global variable and you can use it anywhere in your code.

For example:

var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200 ) {
        //document.getElementById("javascript_response").innerHTML = "Javascript Response : "+xmlhttp.responseText;
            alert(xmlhttp.responseText);
            var obj = JSON.parse(xmlhttp.responseText);
                if(obj.success=="1"){
                    alert(obj.value);
                }
        }
    };  
    xmlhttp.open("GET",base_url+api_key+"/analogWrite?pin=a0&value=100&deviceName="+d_name,true);
    xmlhttp.send();

Also to debug the issue, you can add the

console.log() function in your code to check what is happening with your code. Check this video https://www.youtube.com/watch?v=q9jAFZjPFHo

Also, can you share your device with me to my email id rahul.singh@boltiot.com https://docs.boltiot.com/docs/sharing-device

Do let me know in case you need further assistance.