- Sat Apr 18, 2020 1:38 pm
#86652
Trying to connect ESP8266 with Navionics Boating App on my iPad for the first timeSo far, I’ve learned that I need to have wireless access point created on my ESP8266 that I can connect my iPad to. In a way it’s like your normal WIFI on your home but what ESP8266 can do is to create a SoftAccessPoint that is acting as a WIFI hotspot that is not connected to internet. In other words, you can connect to this WIFI that you create with your ESP8266, but you can’t browse internet or watch Netflix while connected to it. Fine with me since I don’t need internet connection on my iPad while on the sea
I also realized that my iPad asks after a while if I want to use cellular for internet or continue trying with WIFI. If cellular selected you are actually connected to internet while still listening WIFI.
I need this Soft Access Point to send data from my Helix 7 via wireless to Navionics Boating App. Once again, I had to do some research on this. And look what I have found!
https://www.esp8266.com/viewtopic.php?f=29&t=2311Could it be that simple that I just download the .zip file from this site, extract and open the .ino file with Arduino IDE and deploy the code on my NodeMCU? So I had to give it ago. Well nothing happened. Which is actually good since I had not yet learned anything and that might have had a negative impact on what I was about to learn next.
Since nothing happened after deploying the code from R Heslip I had to dig deeper. After some reading of his code and trying to understand what this code was all about I saw Serial.print and Serial.println lines popping up more that other lines. So I decided to study on that topic for awhile.
I quickly realized that Serial.print was a command to print information via serial port that was readable with serial monitor. Cool! So how to do that?
After some additional research Arduino IDE seems to have all what I need to see serial output. I just need to open it from the menu “Tools” -> “Serial Monitor” and then I see really weird chracters. Damn! I need to study more.
2020-04-17_13h28_18.png
So looking into R Heslip’s code I see this line of code “Serial.begin(4800); // NMEA 0183 speed” and on my serial monitor I see 9600 baud. So putting these two to same speed was a no-brainer. I changed the baud on my serial monitor to match 4800, hit the RST button on my ESP8266. And now I see something that I can actually read. One issue resolved!
2020-04-17_13h31_35.png
OK so my ESP8266 is doing something but what? I noticed with my phone that a new WIFI network is now available with name “humminbird” and I can login to this network with the password that I see on the code “passme”. So, I think I’ve just created an access point that I can connect my devices to but can’t still see any available sonar devices on my Boating app when trying to add a new device. I need to dive deeper.
Next I noticed that serial port does not send any information after void setup () code ends so I had no idea if my ESP8266 was sending any data using R Heslip’s code or not. When looking what lines the code has, my assumption was that void setup() is setting things up and void loop() is what gets sent out via Udp.
Then I was trying to figure out what all these if statements are in void setup(). Since I had no glue what it was doing, I had to strip all of it out. And what I was left with was few lines of Udp.write and Udp.endPacket and a timer. Since compiler through an error on the timer, I removed that that too. Now I was left with 3 lines of code in void loop(), Udp.write & Udp.endPacket. And since I had learned earlier that Serial.print is being used to send data to serial monitor I decided to add my very first line of code. By copying Serial.println code from void setup() and adding the same text that was already included in Udp.write line. And here it is!!!
Code: Select allSerial.println("$SDDPT,4.3,0.0*50\r\n");
I then compiled the code and to my surprise no errors
So decided to push this “own” code to my ESP8266. And I was blown away when I started seeing my serial monitor go crazy printing "$SDDPT,4.3,0.0*50 again and again. Had to take a break to celebrate this huge milestone on my coding career
2020-04-17_16h07_59.png
Here is the full code that I used. I also added my own comments when trying to analyze what R Heslip had already put together and changed WIFI network name as well. Additionally, I noticed that setting up AP failed when password has less than 8 characters. So, I added one more character.
Code: Select all//These are the libraries that code below needs in order to work
#include <ESP8266WiFi.h>
#include <WiFiUDP.h>
//ssid will be your wifi network name. It seems that quotes are needed for the IDE compiler to understand where text starts and ends.
//password will be you wifi password. It seems that if you give less than 8 characters then the wifi is unsecure so better to use 8 characters or more
const char* ssid = "Helix 7";
const char* password = "12345678";
// Include Wifi Udp. Navionics boating app is expecting Udp packets from my sonar so we need this
WiFiUDP Udp;
//Void Setup used to “set the scene” for the loop code that will be repeating NMEA 0183 output from my sonar
void setup() {
// Navionics Boating App is expecting data in 4800 baud
Serial.begin(4800);
delay(10);
// Priting information via serial port to display the status during initial boot
Serial.println();
Serial.print("Creating Wifi network called: ");
Serial.println(ssid);
// Confirming that Wifi is turned on and it’s using channel 1 with ssid and pswd defined earlier on the code
WiFi.softAP(ssid,password,1);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Printing information via serial port to confirm successful wifi setup and the IP-address
Serial.println("");
Serial.println("WiFi network created");
Serial.print("Wifi netword address: ");
Serial.println(WiFi.softAPIP());
// Define what IP-address will be receiving Udp packages and what port is being used to send them out.
Udp.beginPacket("192.168.4.2", 2000);
}
// Code inside the loop is repeated over and over again
void loop() {
//Writing Udp with dummy NMEA 0183 depth data
Udp.write("$SDDPT,4.3,0.0*50\r\n");
Udp.write("\r\n");
Udp.endPacket();
Serial.println("$SDDPT,4.3,0.0*50\r\n");
}
ps. What would be the best way to add screenshots to this site? I could include few images going forward.
edit: I missed completely that you can just upload images
You do not have the required permissions to view the files attached to this post.