[ERROR] [1519470945.359482]: Lost sync with device, restarting...
hello everyone i have this error when i connect xbee s1 to my arduino to send sensors data i am using ROS kinetic with ubuntu 16.04
my code
#include <Wire.h>
#include <dht.h>
#include <ros.h>
#include <std_msgs/Float32.h>
#include <sensor_msgs/Temperature.h>
#include <sensor_msgs/RelativeHumidity.h>
//**************************************************************
#define DHT11_PIN 6
float temp ;
float hum ;
const int trigPin = 9;
const int echoPin = 10;
float sensorReading =0;
dht DHT;
long duration;
int distance;
//***********************************************************
std_msgs::Float32 sonar_msg;
sensor_msgs::Temperature temp_msg;
sensor_msgs::RelativeHumidity humidity_msg;
ros::Publisher pub_temp("temperature", &temp_msg);
ros::Publisher pub_humidity("humidity", &humidity_msg);
ros::Publisher pub_sonar("sonar", &sonar_msg);
ros::NodeHandle nh;
//********************************************************
void setup(){
Serial.begin(57600);
Wire.begin();
nh.initNode();
nh.advertise(pub_temp);
nh.advertise(pub_humidity);
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
nh.initNode();
nh.advertise(pub_sonar);
}
//**************************************************************
void loop()
{
nh.spinOnce();
if (millis()-last_time>=100){
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance= duration*0.034/2;
int chk = DHT.read11(DHT11_PIN);
temp = DHT.temperature;
hum = DHT.humidity;
temp_msg.temperature = DHT.temperature ;
humidity_msg.relative_humidity = DHT.humidity ;
pub_temp.publish( &temp_msg);
nh.spinOnce();
pub_humidity.publish( &humidity_msg);
sonar_msg.data = distance;
pub_sonar.publish(&sonar_msg);
last_time=millis();
}
}
HERE IS THE ERROR
ERROR badeaa@badeaa-VPCEA22FX:~/sketchbook/libraries$ rosrun rosserial_python serial_node.py /dev/ttyACM1
[INFO] [1519548036.306024]: ROS Serial Python Node
[INFO] [1519548036.313912]: Connecting to /dev/ttyACM1 at 57600 baud
[INFO] [1519548039.022223]: Note: publish buffer size is 512 bytes
[INFO] [1519548039.023157]: Setup publisher on temperature [sensor_msgs/Temperature]
[INFO] [1519548039.027670]: Setup publisher on humidity [sensor_msgs/RelativeHumidity]
[INFO] [1519548039.033109]: Setup publisher on sonar [std_msgs/Float32]
[ERROR] [1519548071.706710]: Lost sync with device, restarting...
[ERROR] [1519548086.708586]: Lost sync with device, restarting...
Can you please update your question with a copy and paste of the entire error that you're getting using the preformatted text (
101010
) button?I updated it right now