An ESP8266-01 WiFi module to read NMEA marine serial data and UDP broadcast it to multiple openCPN instances as a Bridge.
On my boat and several others, we are running OpenCPN for navigation software. Most of us run it on a laptop. The common inputs are GPS, AIS and some have all their instruments connected as well; depth, wind, speed & distance log, etc.
There are two problems that I am trying to solve. First, too many cables to the laptop providing the instrument data. And second, a way to share the instrument data with multiple devices. The release of opencpn for android tablets and smart phones makes it feasible to have multiple displays around the boat. Like in the captain's bunk to check on the boat and crew performance without getting out of bed.
So this friend that wants all of the instrument data over the network has a multiplexer that takes his SeaTalk and various NMEA 0183 signals and outputs a higher baud NMEA sentence data stream. And I have a combination AIS/GPS that has NMEA 0183 at 38400 baud. My laptop is getting old and if you touch the USB cable from the RS-232-to-USB it disconnects and reconnects using a different port configuration.
And besides it would be nice to have no cables, especially to a phone or tablet.
Along comes the ESP8266 Serial WiFi module with a modest price around $2.50 USD and other board configurations for a few dollars more.
So the plan is to create new firmware for the module, connect the rs-232 based NMEA 0183 signals to it and broadcast the sentences over the WiFi as UDP packets on the local subnet. So this will require a WiFi Access-point (AP) on the boat. (ED. It may be possible for the ESP to be the router too.) Another recent development is the availability of cheap pocket routers such as the TP-LINK WR702N. I picked mine up in Singapore for less than $8.00 USD last year, but the market is full of competitors.
I want to be able to run openCPN on both a laptop and a tablet at the same time. I would like the laptop down below deck, safe from the rain and salt water spray. I would like to have a mostly waterproof tablet in the cockpit to monitor progress. And I would like to be able to quickly check the ship's status from the captain's berth when off watch, maybe on a smart phone.
I decided to implement a device to read the serial data from all the boat instruments and send that data to openCPN over a WiFI link so there are no physical wires attached. It will broadcast the data with UDP so that multiple devices can read the data at the same time.
The ESP8266 ESP-01 was chosen because it was on hand and it has adequate I/O for this project.
NMEA 0183 is usually rs232 or rs484 at 4800 baud. The rs-232 input signal voltage should work with -12 to +12 volts. This project was tested with a Garmin 72H which outputs -5 to +5 and 4800 baud and an OceanPC AIS which outputs -3.0 to +3.0 at 38400 baud. Therefore, after a little search, I found a single transistor level shifter for the Rx input to make it conform to the 3.3v TTL levels of the ESP module.
Figure 1a. Strip-board implementation
Figure 1b. Strip-board bottom
The +5v power (from a 12v automobile USB charger module) comes in through the switch, upper left then a 3.3v regulator and then to the ESP module's socket. It is a little sensitive, so pull-up resistors are recommended on the 3 data lines, GPIO2 and Rx) and the chip select and reset pins. Tx and Rx are needed for programming (flashing) the firmware, and as a development board I chose to bring those to the top right pins with a ground for a future test of a 16x2 serial display.
The LEDs and pins at the bottom show the state of the 2 GPIO lines. The software configuration technique uses a short between these to go into config mode. The push button puts the module in flash mode.
Connect power lines and input signal rs-232 line with ground. Press and hold config button, press reset, continue to hold config until the LED stays lit. Connect to the AP "NMEA WiFi Bridge" with a system/phone/etc. Connect your browser to 10.1.1.1 with password in code "nmeawifi".` Configure the form for your network and click the "configure" button. Verify the results page. Press reset or cycle power for the module to connect to your network.
To verify it is working, there is a status page on the address on the NMEA WiFi Bridge. Type this address into your browser.
The design of the code has three parts: setup configuration, normal execution and a status webpage.
First, setup configuration, short GPIO0 to GPIO2 (press the config button) and turn on the power. After a few seconds (5-6) the LED comes on indicting the module is ready to configure. This starts an AP at 10.1.1.1 that you can connect to with a WiFi capable device (laptop or phone or tablet using DHCP), then access the webpage at that IP. You get page_1.jpg.
figure 3. Setup
Enter the ssid and password for your boat network, the UDP port to connect and the baud rate to listen for the NMEA data.
When you click configure, it displays a confirmation of your data. If it is correct, turn off the power, connect it to you NMEA data, remove the short between the GPIO pins (do not press the button) and turn on the power.
Figure 4. Confirmation
The second part of the code, normal execution, now runs. It listens for NMEA sentences and when it has a complete sentence, broadcasts it to the broadcast address of the subnet you provided in config. All devices on that subnet can read these UDP packets.
Now go to your opencpn configuration settings, then connections. Add a new connection, selecting: network, UDP and the port number from above (default is 10110).
You should be getting data.
Figure 5. Status
The third part consists of a status page. You can look in a web browser at the IP address of the NMEAWiFiBridge and get a status page that updates the number of sentences broadcast every 10 seconds. It may severely impact the ability of the ESP to keep up with a busy data stream to monitor it, so it is only there to help with trouble shooting the connections. It should only impact performance while your browser is displaying the page.
Figure 6. Rev 3 installed
Since the initial build I have made custom boards (3 trys to get them right) and have 2 installed and running aboard the Katie Lee.
See my github repository for code and schematics: https://github.com/svkatielee/NMEA_WiFi_Bridge
The configuring software is based upon the work of Forward Computing and Control. My hardware is open-source, my software is GPL3.
1 - ESP8266-ESP-01
1 - LD1117-33 regulator (any 3.3v > 500ma will do)
1 - 1uF tantalum
6 - 4.7K ohm pull-up resisters
1 - 330 ohm current limit for Tx buffer
1 - 10K ohm for rs232 level convert 1 - 2n2222 for level convert
1 - 1N5819 program Rx input
1 - LED
3 - momentary pushbuttons
Code and schematic on Github
Live realtime stock market prediction website. https://www.stocksignalslive.com my latest creation. Uses AI and machine learning.
New site featuring ESP8266 and ESP32 projects. tutorials, and news.
ESP8266.com Founder and Administrator
Home of the ESP8266, ESP8285, and ESP32 microcontrollers....