What does the following code do?

What does the following code do? In the code, what is pin number 2? It says an input. So if its a sensor, how do we use sensors with 2 pins like ultrasonic sensor?

#include <BoltIot-Arduino-Helper.h>
  void setup() {
    boltiot.Begin(Serial); //Initialize the Bolt interface over serial uart. Serial could be replaced with Serial0 or Serial1 on Arduino mega boards.
         //In this example Tx pin of Bolt is connected to Rx pin of Arduino Serial Port
         //and Rx pin of Bolt is connected to tx pin of arduino Serial Port
    pinMode(2,INPUT); //Set pin 2 as input. We will send this pin's state as the data to the Bolt Cloud
  }
  void loop() {
    boltiot.CheckPoll(digitalRead(2)); //Send data to the Bolt Cloud, when the Bolt polls the Arduino for data.
  //This function needs to be called regularly. Calling the CheckPoll function once every seconds is required
  }

I got this from https://docs.boltiot.com/docs/arduino-library

I am not familiar with arduino… but according to me… the code is just to setup the connection between your Bolt module and Arduino (the setup() function)… and to collect data from it using the digitalRead() in the loop() function.
image
This shows, that the pin 2 is the GPIO pin 2 on the Bolt module… and you set it as an input pin in this case…

And am guessing for a 2 pin sensor, 1 pin will be receiving the power supply, as needed, and the other pin would be giving the input to the Bolt…
PS: Like I said,… not very knowledgeable in arduino… :slight_smile: