Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By rheslip
#13605 A simple sketch based on the UDP client example. This one creates an access point and streams the serial input to a specific port via UDP.

I wrote this to connect the Navionics "Boating" app on my smartphone to my Humminbird Helix 5 fishfinder. The fishfinder sends GPS position and depth information in NMEA 0183 format at 4800 bps via an RS232 port - this is sent to the ESP8266 serial input via an RS232 level converter. When you connect the phone to the ES8266 access point, the Navionics app shows the GPS position and depth from the fishfinder. The app can actually create depth charts as you drive around in your boat in real time from this information. The Navionics phone app costs about $15. Only high end $1500+ fishfinders have the real time depth charting feature - now I have it on my phone!

This code with a few mods could be very useful for connecting all kinds of marine electronics together. This version is very specific to the Navionics app.

Rich
You do not have the required permissions to view the files attached to this post.
User avatar
By CapacitiveSmoke
#17590 Hi rheslip,

Thank you so much for sharing your code. I am attempting a similar setup with a GPS and some other sensors. I tried your code as posted using this release (https://github.com/sandeepmistry/esp826 ... /tag/0.0.5) of the ESP Arduino setup.

Unfortunately the status of the AP does not seem to change once the station (my phone) connects to it. I modified the portion of the setup() call a bit to get some more debugging from it but can't find a reason for the failure:

Code: Select allvoid setup() {
  Serial.begin(4800);  // NMEA 0183 speed
  delay(10);

  // We start by setting up WiFi access point
  Serial.println();
  Serial.print("Setting up AP ");
  Serial.println(ssid);

  WiFi.mode(WIFI_AP);
  WiFi.begin(ssid);//, password);
  WiFi.softAP(ssid);//,password,1);  // doesn't seem to set up a secure network
  Serial.print("Starting AP at: "); Serial.println(WiFi.softAPIP());
  WiFi.printDiag(Serial);
  int x = 0;
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(WiFi.status());Serial.print(".");
    if(x++ > 80)
    {
      Serial.println();
      x = 0;
    }
  }

  Serial.println("");
  Serial.println("WiFi connected"); 
  Serial.print("AP IP address: ");
  Serial.println(WiFi.softAPIP()); 
  //Serial.print("Remote IP address: "); 
  //Serial.println(WiFiClient.remoteIP());  // doesn't work - not sure how you get client's IP
 
  Udp.beginPacket("192.168.4.2", 2000);  // seems to always give out the next IP after its own, but this increases as more connections are made
}


The WiFi.status() method seems to relate to the station mode of the ESP and not the AP mode so it continuously reports a status of 1 (WL_NO_SSID_AVAIL) when waiting for the connection although I can see my reports being connected to humminbird with a valid IP (I can even ping 192.168.4.1).

How did you manage to get the connection working? :)

Here's a sample debug output of the setup() method:

Code: Select allSetting up AP humminbird
Starting AP at: 192.168.4.1
Mode: STA+AP
PHY mode: N
Channel: 1
AP id: 0
Status: 1
Auto connect: 1
SSID (10): humminbird
Passphrase (0):
BSSID set: 0
6.6.6.6.6.6.6.6.6.6.6.6.6.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.
1.1.1.1.1.1.1
User avatar
By Pawel Wiatr
#32176 Dear Rich!

Thak you for posting the description of your project.
Could you describe the HW configuration in more details.
It seems to me (I may be wrong) that the code you posted is for Arduino, so how do you use it all together.
Thanks
Pawel
User avatar
By russellkt
#82983 Thanks so much for this post! I just realized yesterday that the navionics app supports udp and have searched but this is the only direct reference I've found to setting it up. Going to give it a go next week.