Bolt IoT: A fully integrated IoT Platform

The Bolt IoT Developer Hub

Welcome to the Bolt IoT developer hub. You'll find comprehensive guides and documentation to help you start working with Bolt IoT as quickly as possible, as well as support if you get stuck. Let's jump right in!

Guides    Guides

Controlling devices

You can control your devices by just writing the few lines of code. Before we start.

Prerequisite

  1. Setting up your Bolt device Setting Up the Bolt WiFi Module
  2. Product creation Creating a new product
  3. Configure the product Configuring product hardware
  4. Linking device with the product.

Getting Started with controlling device

After finishing all the steps of the prerequisite section, click on the products tab, and then click on the code tab and you can start writing your code there.
Note - This code will only work if you choose the .js extension from the code tab. This feature will work with graph and without graph code. If you write this code inside your graph code, then the graph will come first and then the control buttons will appear.

Single Button

The single button will create a single button on the control page.

Syntax
singleButton({ name : "", action :"", pin : "", value : ""})

Name - the name of the button that will appear on the page.
action - action button is the name of the command that will be executed on the click of the button. The commands are below,

  • digitalWrite
  • analogWrite

pin - pin number where you want to send the command. It could be

  • A0, 0, 1, 2, 3, 4

value - The state of the pin. It could be

  • HIGH - On digital pins
  • LOW - On digital pin
  • 0-255 - On analog pin

Example

singleButton({name:"Led On", action:"digitalWrite", 
              pin:"0", value:"HIGH"})

Save the file with .js extension.

Now click on the action icon from the devices tab.

Now we will add on more button to switch off the led.

singleButton({name:"Led On", action:"digitalWrite", 
              pin:"0", value:"HIGH"})

singleButton({name:"Led Off", action:"digitalWrite", 
              pin:"0", value:"LOW"})

Now, when you open the action page, you will get two buttons as shown in the image below.

And when you click on the Led On button, it will switch on the LED on the pin 0 and when you click on Led Off it will switch off the LED on pin 0.

Extra customization

Syntax
Parameter(s)
Description

bgcolor

color code

The bgcolor attribute specifies the background color of the button. The default color for the bgcolor is #9BDF46

shape

rectangle,circle

Shape property will specify the shape of the button. The default shape for button is rectangle.

align

left, center, right

The align attribute specifies the horizontal alignment of the button. By default the button is center aligned.

text_color

color code

You can set the color of text using text_color parameter.
The default text color is white.

Example of Extra customization

singleButton({name:"Led On", action:"digitalWrite", 
              pin:"0", value:"HIGH",bgcolor:"green",
              shape:"rectangle",align:"left","text_color":"white" })

singleButton({name:"Led Off", action:"digitalWrite", 
              pin:"0", value:"LOW", bgcolor:"red",
              shape:"rectangle", align:"left", text_color:"black"})

singleButton({name:"Fan On", action:"analogWrite", 
              pin:"0", value:"230",bgcolor:"#ffa500",
              shape:"circle", align:"right","text_color":"white" })

singleButton({name:"Fan Off", action:"analogWrite", 
              pin:"0", value:"0",bgcolor:"#6a5acd",
              shape:"circle", align:"right", text_color:"white"})

Dual Button

The dual button will create an object to create two adjacent buttons. You can add different actions to each button. Both buttons will be center aligned by default.

Syntax
var dual = dualButton(align);
dual.first_button({name :"", action :"", pin :"", value :"", text_color:""})
dual.second_button({name :"", action :"", pin :"", value :"", text_color:""})

dualButton(center)- dualButton function will create an object to create buttons. We can pass the location of the button as the parameter. The default location for the dual button is center.
first_button This function will set the property to the first button of the dual button.
second_button This function will set the property to the second button of the dual button.
Name - the name of the button that will appear on the page.
action - action is the name of the command that will be executed on the click of the button. The possible commands are below,

  • digitalWrite
  • analogWrite

pin - pin number where you want to send the command. It could be

  • A0, 0, 1, 2, 3, 4

value - The state of the pin. It could be

  • HIGH - For digital pins
  • LOW - For digital pins
  • 0-255 - For analog pin

Example

var dual = dualButton();
dual.first_button({name :"LED ON", action :"digitalWrite", 
                   pin :"1", value :"HIGH"})
dual.second_button({name :"LED OFF", action :"digitalWrite", 
                    pin :1, value :"LOW"})

Now save the file and open action page of the device and you will get the below output.

Extra customization

Syntax
Parameter(s)
Description

bgcolor

color code

The bgcolor attribute specifies the background color of the button. The default color for the bgcolor is #9BDF46 .

shape

rectangle,circle

Shape property will specify the shape of the button. The default shape for button is rectangle.

dualButton(align);

left, center, right

It will create the object to create the button and you can pass the left, center or right as parameter to align the dual button.

text_color

color code

You can set the color of text using text_color parameter.
The default text color is white.

var dual =dualButton("left");
dual.first_button({name:"Led Off", action:"digitalWrite", 
                  pin:"0", value:"LOW", bgcolor:"blue",
                  shape:"rectangle", text_color:"white"})

dual.second_button({name:"Led on", action:"digitalWrite", 
                    pin:"0", value:"HIGH", bgcolor:"black",
                    shape:"rectangle", text_color:"white"})
                    
                    
var dual2 =dualButton("right");
dual2.first_button({name:"Fan off", action:"analogWrite", 
                  pin:"0", value:"0", bgcolor:"Green",
                  shape:"circle", text_color:"black"})

dual2.second_button({name:"Fan on", action:"analogWrite", 
                    pin:"0", value:"250", bgcolor:"Red",
                    shape:"circle", text_color:"White"})

Now save the file and open action page of the device and you will get the below output.

Controlling devices


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.