Ask Your Question

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

asked 2017-12-29 10:53:58 -0500

ARUN T S gravatar image

updated 2017-12-29 10:56:13 -0500

#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() {
while (!Serial)
Serial.println("Starting wifi");
wifi.connectToAP("wifissid", "wifipass");
wifi.connectToServer("", "11411");
wifi.send(SERVER, "ESP8266 test app started");
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..
for(int i=0;i<5;i++)
{      range_msg.range = i;


edit retag flag offensive close merge delete


What is your question?

jayess gravatar imagejayess ( 2017-12-29 11:12:36 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-12-29 11:21:43 -0500

For the love of all that is good, please learn to indent your code!

There may be a problem with your setup function. you need to add a ; after the while(!Serial) line, this is meant to wait until the serial port is setup, but inside this loop you're writing to the Serial port if it's not setup which may be causing some problems.

while (!Serial);
Serial.println("Starting wifi");

I recommend printing some useful debugging information to the serial port and viewing it from your computer to see what's going on. If you can describe in more detail how this is failing then we'll be able to help you more.

edit flag offensive delete link more


+1 on the indenting and giving us more information.

jayess gravatar imagejayess ( 2017-12-29 11:25:48 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-12-29 10:53:58 -0500

Seen: 831 times

Last updated: Dec 29 '17