Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I am planning to publish sensor data over wifi module(ESP8266-01) through arduino. In my program it created a access point but it is not sending any data

#include <SoftwareSerial.h>
#include <SerialESP8266wifi.h>
#include <ros.h>
#include <sensor_msgs/Range.h>
#define sw_serial_rx_pin 12 //  Connect this pin to TX on the esp8266
#define sw_serial_tx_pin 11 //  Connect this pin to RX on the esp8266
 #define esp8266_reset_pin 5 // Connect this pin to CH_PD on the esp8266, not reset. (let reset be unconnected)
 SoftwareSerial swSerial(sw_serial_rx_pin, sw_serial_tx_pin); 
SerialESP8266wifi wifi(swSerial, swSerial, esp8266_reset_pin, Serial);//adding Serial enabled local echo and wifi debug
ros::NodeHandle nh;
sensor_msgs::Range range_msg;
ros::Publisher pub_range("car", &range_msg);
char ultrafrid[] = "/ultrasound";
void setup() {
swSerial.begin(9600);
Serial.begin(9600);
nh.initNode();
nh.advertise(pub_range);
while (!Serial)
Serial.println("Starting wifi");
wifi.setTransportToTCP();
wifi.endSendWithNewline(true); 
wifi.connectToAP("wifissid", "wifipass");
wifi.connectToServer("192.168.4.255", "11411");
wifi.send(SERVER, "ESP8266 test app started");
nh.initNode();
nh.advertise(pub_range);
range_msg.header.frame_id =  ultrafrid;   // ultrasound frame id
range_msg.field_of_view = 0.1;
range_msg.min_range = 0.0;
range_msg.max_range = 20;
}
void loop() {
 if (!wifi.isStarted())      //Make sure the esp8266 is started..
wifi.begin();
for(int i=0;i<5;i++)
{      range_msg.range = i;
}

 pub_range.publish(&range_msg);

nh.spinOnce();
}

I am planning to publish sensor data over wifi module(ESP8266-01) through arduino. In my program it created a access point but it is not sending any data

#include <SoftwareSerial.h>
#include <SerialESP8266wifi.h>
#include <ros.h>
#include <sensor_msgs/Range.h>
#define sw_serial_rx_pin 12 //  Connect this pin to TX on the esp8266
#define sw_serial_tx_pin 11 //  Connect this pin to RX on the esp8266
 #define esp8266_reset_pin 5 // Connect this pin to CH_PD on the esp8266, not reset. (let reset be unconnected)
 SoftwareSerial swSerial(sw_serial_rx_pin, sw_serial_tx_pin); 
SerialESP8266wifi wifi(swSerial, swSerial, esp8266_reset_pin, Serial);//adding Serial enabled local echo and wifi debug
ros::NodeHandle nh;
sensor_msgs::Range range_msg;
ros::Publisher pub_range("car", &range_msg);
char ultrafrid[] = "/ultrasound";
void setup() {
swSerial.begin(9600);
Serial.begin(9600);
nh.initNode();
nh.advertise(pub_range);
while (!Serial)
Serial.println("Starting wifi");
wifi.setTransportToTCP();
wifi.endSendWithNewline(true); 
wifi.connectToAP("wifissid", "wifipass");
wifi.connectToServer("192.168.4.255", "11411");
wifi.send(SERVER, "ESP8266 test app started");
nh.initNode();
nh.advertise(pub_range);
range_msg.header.frame_id =  ultrafrid;   // ultrasound frame id
range_msg.field_of_view = 0.1;
range_msg.min_range = 0.0;
range_msg.max_range = 20;
}
void loop() {
 if (!wifi.isStarted())      //Make sure the esp8266 is started..
wifi.begin();
for(int i=0;i<5;i++)
{      range_msg.range = i;
}

 pub_range.publish(&range_msg);

nh.spinOnce();
}