Interfacing Bolt with Arduino

Hello sir this is my code of arduino to interfacing with bolt
this code return {“success”:“1”,“value”:""}
when we send http response with data hello ,it’s not return data hello

void setup() { // put your setup code here, to run once:
Serial.begin(9600); //Begin Serial at 9600
Serial.setTimeout(50); //Timeout serial if readString is unavailable
}

void loop() {
// put your main code here, to run repeatedly:
String inString = “”;
if (Serial.available() > 0) {
// get incoming String
String inString = Serial.readString(); //Read input string from bolt
Serial.print(inString); //Send same string back to bolt
}

And my second issue is that i have a program of arduino of motor ON or OFF and i control my motor through gsm but now i want to control my motor through bolt then tell me the solution
my code is below

#include<LiquidCrystal.h>
LiquidCrystal lcd(14,13,12,11,10,9);
char inchar,mosture_sensor;
String check_power= “ajityadav”;
String check_power1= “motorband”;
String power;
String power1;
int led=7;
//int c;
int x;
//int aaaa;
int a=2;
int b=3;
//int led=13;
//int relay=4;
//void mosture();
void stop();
void sensor();

void setup() {
// put your setup code here, to run once:

pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(A5,INPUT);
pinMode(7,OUTPUT);
// pinMode(13,OUTPUT);
//pinMode(A0,INPUT);
// pinMode(relay, OUTPUT);
Serial.begin(9600);
//Serial.println(“AT”);//to avtivate
lcd.begin(16,2);
lcd.cursor();
lcd.print(“WELCOME”);
digitalWrite(2,LOW);
digitalWrite(3,LOW);
// digitalWrite(13,LOW);
// Serial.print(“pin state low\n”);
delay(1000); // give time for GSM module to register on network.
Serial.println(“AT”);
delay(2000);
Serial.println(“AT+CSCS=“GSM””); // set SMS mode to text
delay(1000);
Serial.println(“AT+CMGF=1”);
delay(1000);
Serial.println(“AT+CNMI=2,2,0,0,0”); // set module to send SMS data to serial out upon receipt ,to save the message in gsm module
delay(200);
}

void loop()
{

// put your main code here, to run repeatedly:
int i;
lcd.clear();
lcd.print(“type_message”);
lcd.setCursor(0,1);
//lcd.print(“ajityadav”);
//delay(2000);
//lcd.clear();

if(Serial.available() >0)
{
for(x=0;x<360;x++)
{
//lcd.setCursor(0,0);
//lcd.print(“yadavajit”);
//delay(2000);
inchar=Serial.read();

  if (inchar=='#')
  {
     power=Serial.readStringUntil(13);
      lcd.setCursor(0,0);
      lcd.print(power);
      delay(2000);
  
    if(power==check_power )
    {
      sensor(); 
      /*     
      
      */
      Serial.print("AT+CMGD=1,4");//Delete all message
      delay(2000);
      //while(1){;}
       //mosture();
    }
    
    if(power==check_power1)
    {      
      lcd.setCursor(0,1);
      lcd.print("ACCESS MOTOR"); 
      digitalWrite(a, LOW); 
      digitalWrite(b, LOW);
      lcd.setCursor(0,2);
      lcd.print("motor_off");
      
      Serial.println("AT+CMGF=1");
      delay(500);
      Serial.println("AT+CMGS=\"8955563856\"");//Change the receiver phone number,number of gsm
      delay(3000);
      Serial.println("Motor OFF");    //the message you want to send
      Serial.write(26);
      delay(3000);
      Serial.print("AT+CMGD=1,4");//Delete all message
      delay(2000);
      //while(1){;}
       //mosture();
    }
  }
}

}
}
void sensor()
{
int d =analogRead(A4);
Serial.print(“adc=”);
Serial.println(d);
delay(1000);
Serial.println("");
int leak=digitalRead(A5);
Serial.print(“digitalread=”);
Serial.println(leak);
Serial.println("");
delay(1000);

if(leak==0 && d<300)
{
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(led, HIGH);
lcd.setCursor(0,2);
lcd.print(“motor_off”);
Serial.println(“AT+CMGF=1”);//to type mesage
delay(2000);
Serial.println("AT+CMGS=“8955563856"”);
delay(2000);
Serial.println(“motor_off”);
Serial.write((char)26); //ctrl+z
delay(2000);
Serial.println(“AT+CMGD=1,4”);//Delete all message
delay(2000);
}
else
{
lcd.setCursor(0,1);
lcd.print(“ACCESS MOTOR”);
digitalWrite(a, HIGH);
digitalWrite(b, LOW);
lcd.setCursor(0,2);
lcd.print(“motor_on”);
Serial.println(“AT+CMGF=1”);
delay(500);
Serial.println("AT+CMGS=“8955563856"”);//Change the receiver phone number,number of gsm
delay(3000);
Serial.print(“Motor ON”); //the message you want to send
Serial.write(26);
delay(3000);
Serial.println(“AT+CMGD=1,4”);//Delete all message
delay(2000);
}

}

Try this code instead

void setup() { // put your setup code here, to run once:
Serial.begin(9600); //Begin Serial at 9600
Serial.setTimeout(100); //Timeout serial if readString is unavailable
}

void loop() { // put your main code here, to run repeatedly:
String inString = “”;
if (Serial.available() > 0) { // get incoming String
delay(10);
while(Serial.available()>0){
char inChar = Serial.read();
inString = inString + inChar;
}
Serial.print(inString); //Send same string back to bolt
}

this is your screenshort

Now my screenshort is

Here hello should be print

use this for the correct reply

First use 192.168.43.233/serialBegin?baud=2

Then

192.168.43.233/serialWR?data=hello

serialWrite only sends data doesn’t expect a reply.

thanks sir i got my solution
thankyou very very much@datta.naik sir

2 Likes

Hello sir i have to run my motor as well as data visualisation of sensor ,is it possible from bolt ?

Hello sir i have to run my motor as well as data visualisation of sensors together ,is it possible from bolt cloud using html code ? when i click my button of motor on then motor become start and when we click motor off then motor off and we have also interfaced sensor to bolt and want get visualisation data at the same time from boltcloud

Yes it is possible,

Use different serial data to control the motors connected to arduino.

Example send “w” to start the motors, “s” to stop the motors etc.

1 Like

Hello sir,
I want to interface bolt with Arduino nano and read the analog values (Temperature, Light_intensity) using the UART commands. I have done a Mobile App which reads a single analog data from bolt through API commands and print it, but i want to read two analog values and this is why i got a new nano board. I am new to Arduino IDE and i dont know what code to be written.

Please help me and let me know how to interface, code and get the analog values from arduino through UART commands.

Hello sir,

I had interfaced Arduino Nano with Bolt written code for getting Analog data from nano to bolt. But, I am not able to get the values. This is my code :

#include <BoltIoT-Arduino-Helper.h>

String returnLoggableData(String *data){
	String retval="";
	retval=retval+analogRead(A0)+",";
	retval=retval+analogRead(A1)+",";
	retval=retval+analogRead(A2)+",";
	retval=retval+analogRead(A3)+",";
	retval=retval+analogRead(A4)+",";
	retval=retval+analogRead(A5);
	return retval;
}


String returnExtraMonitoringData(String *data){
	String retval="";
	retval=retval+digitalRead(2)+",";
	retval=retval+digitalRead(3)+",";
	retval=retval+digitalRead(4)+",";
	retval=retval+digitalRead(5)+",";
	retval=retval+digitalRead(6);
	return retval;	
}

String runPwmCommand(String *data){
	int pwmChannel=data[0].toInt();
	int pwmValue=data[1].toInt();
}

void setup(){
	boltiot.begin(Serial);
	boltiot.setCommandString("GetAnalogData",returnLoggableData);
	boltiot.setCommandString("GetData",returnExtraMonitoringData);
	boltiot.setCommandString("PWM",runPwmCommand,2);  //2 arguments are required, 1 is pwm channel and 2 is pwm value.
}

void loop(){
	boltiot.handleCommand();
}

I had used this Api call to get analog data :

https://cloud.boltiot.com/remote/a0XXXXXd-fXXXX-4006-XXXXX-1cXXXXXXXe/serialWR?data=GetAnalogData&deviceName=BOLTXXXXX

But my output is:

{"value": "", "success": "0"}

But I am able to get those values serial Monitor (Arduino IDE)
Please help me

Hi Shrikanth,

Your code seems to be proper.

I would suggest you to recheck your connections.

This is normally the root cause for not retrieving data from an Arduino interfaced with the Bolt unit.
It is for this very reason that we have designed the BoltDuino (Earlier called the Bolt IoT Arduino Adapter)

Hi @shree1998juhi,

I forgot to tag you in the previous post.

https://create.arduino.cc/projecthub/order-of-the-bolt-nix/harry-potter-weasleys-clock-using-bolt-iot-a7d04a this is the complete link by which u can interface Bolt device with the Arduino @PPV

1 Like

unable to configure properly


Sir what’s the problem, please help

1 Like

Hi Sir,
this looks like a very good code to feed on the arduino. But after feeding it there,

  1. What is the code to be written on the bolt IOT module?
    2.How do we send commands to serial write to the bolt IOT module?
  2. What are the hardware connections btw the bolt module and Arduino

I did try the instructables link and it didn’t seem to quite work out.

I would love it if you or my role model, @PPV sir could help me with learning this.

Regards,
Tejas

Sir i am done my certificate exam before 6 days but still i am not get certificate from bolt iot …

Thank you sir for help
Sir can you make 1 video on this topic because this video are very useful for us.