Bolt receiving wrong data from arduino

Yes, never upload with the serial pins connected.

and BTW i made the change you suggested and i got this


Are you sure that is the updated code screenshot?

sorry my bad


hey what i think is data got little bit distorted


in last two outputs it gave 6767 but actual value is 67 so i think data got distorted or wifi module is slow in retriving data since HC-SR04 giving super fast inputs if im wrong correct me please!!

There is definitely something wrong with what your arduino is putting on serial monitor and what the bolt is reading it.

I have checked, and nothing seems to be wrong in code. You have to be make sure you don’t put all the data continously when using serial communication with bolt. After all, it has to run the URL and check what the bolt has on it.

I have a tester on me, which you can use to see if your serial communication is working fine - https://gist.github.com/hippyaki/4470c6a1cfcdc069ecf3dacab454188e

Push any data on the serial monitor, every 2 seconds and it will return you accurate data.

And try to do most of the programming on Arduino itself. Use the arduino to trigger a message on the Bolt in case any event occurs. Instead of pushing all the data to the bolt.

i have checked withe the code you provided i think the problem is speed when i make a change it literally takes 53 seconds to show up on screen
and also with distortions like instead of 16 it shows 116 or 1616 like that is there any way to solve it i tried what you said by putting delay(2000) but it effects its process also i mean it detecting obstacle 2 seconds late

Yes, that’s why I asked you to use IoT ability only to be triggered on certain conditions. Like, in case you want to read the current data of US, send a serialWrite of ‘RD’ from python. In the Arduino’s side, return the value when it receives a ‘RD’ command.

I hope you understood this part.

Using IoT to constantly receive data isn’t what I would suggest.

ok then i want to use iot to send message when it is less than 14cm is that fine

can you tell me where should i make changes in python script

Yes, do something like.

when <14cm --> print(little near)

when <25cm --> print (near)

when <50cm --> print (very near)

Is it not working currently? Even though it is a bit late?

still it has some 9 seconds delay

can you help me out how to trigger BOLT from arduino!!

like just mention what should i add in arduino code
present arduinocode
const int trig = 12;
const int echo = 13;
const int LED1 = 8;
const int LED2 = 7;
const int LED3 = 6;
const int LED4 = 5;
const int LED5 = 4;
const int LED6 = 3;
const int BUZ = 2;

int duration = 0;
int distance = 0;

void setup()
{
pinMode(trig , OUTPUT);
pinMode(echo , INPUT);

pinMode(LED1 , OUTPUT);
pinMode(LED2 , OUTPUT);
pinMode(LED3 , OUTPUT);
pinMode(LED4 , OUTPUT);
pinMode(LED5 , OUTPUT);
pinMode(LED6 , OUTPUT);
pinMode(BUZ , OUTPUT);

Serial.begin(9600);

}

void loop()
{
digitalWrite(trig , HIGH);
delayMicroseconds(1000);
digitalWrite(trig , LOW);

duration = pulseIn(echo , HIGH);
distance = (duration/2) / 28.5 ;
Serial.println(distance);
delay(2000);//------------------------------------------------>this is the 2seconds delay i added

if(distance<=7)
{
digitalWrite(LED6,HIGH);
digitalWrite(LED5,HIGH);
digitalWrite(LED4,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED1,HIGH);
tone(BUZ,3000);
}
else if(7<distance && distance<=14)
{
digitalWrite(LED6,HIGH);
digitalWrite(LED5,HIGH);
digitalWrite(LED4,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED1,LOW);
tone(BUZ,3000);
delay(100);
noTone(BUZ);
delay(100);
}
else if(14<distance && distance<=21)
{
digitalWrite(LED6,HIGH);
digitalWrite(LED5,HIGH);
digitalWrite(LED4,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED2,LOW);
digitalWrite(LED1,LOW);
tone(BUZ,3000);
delay(200);
noTone(BUZ);
delay(200);
}
else if(21<distance && distance<=28)
{
digitalWrite(LED6,HIGH);
digitalWrite(LED5,HIGH);
digitalWrite(LED4,HIGH);
digitalWrite(LED3,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED1,LOW);
tone(BUZ,3000);
delay(300);
noTone(BUZ);
delay(300);
}
else if(28<distance && distance<=35)
{
digitalWrite(LED6,HIGH);
digitalWrite(LED5,HIGH);
digitalWrite(LED4,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED1,LOW);
tone(BUZ,3000);
delay(400);
noTone(BUZ);
delay(400);
}
else if(35<distance && distance<=42)
{
digitalWrite(LED6,HIGH);
digitalWrite(LED5,LOW);
digitalWrite(LED4,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED1,LOW);
tone(BUZ,3000);
delay(500);
noTone(BUZ);
delay(500);
}

 else 

{
digitalWrite(LED6,LOW);
digitalWrite(LED5,LOW);
digitalWrite(LED4,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED1,LOW);
noTone(BUZ);
}
}

I’ll share 2 sample gist by today evening. Arduino to trigger depending on your conditions, and another for bolt to receive those data to print or send sms/mail.

I’ll only share the sample, you’ll have to make changes in your code yourself. You’ll be able to relate, i’ll assure that.

ok is there any chance we can slowdown pusing of data to BOLT without actually effecting the process

write the serialprint inside a function, say void trigger(){…}

Now, call this function after every 3 loops. How?

Declare a variable int a = 0;

The very first line inside void loop() has to be a++;

Now write a if condition -->

if (a%3 = 0){
  trigger();
}

But with that we are just printing data what about pushing data