Your Nautical Barometer Gold for Precise Weather Forecasts

by debinix in Circuits > Electronics

6563 Views, 65 Favorites, 0 Comments

Your Nautical Barometer Gold for Precise Weather Forecasts

finsihed-barometer-gold.jpg

Why a nautical barometer?

The answers are simple. I'm a sailor, and predicting the wind and weather changes is a good thing. Second, with the recent inventions of pressure sensors, precision is way better than old-fashioned mechanical instruments.

This barometer's history scales are a unique feature.

The pressure tendency can forecast short-term changes in the weather, which will give us an early warning of what to expect in the coming hours.

The core of our project is an ESP32 microcontroller, an environment sensor, and a color display.

I wanted this project to have a wide choice of ESP32 development boards and sensors. Therefore, I designed "the ESP32 adapter board to rule them all," which accepts ESP32's modules from 20 pins to 38 pins designs.

Finally, I would say it's gold because other barometer solutions are compared to it, the gold standard.

Find the necessary parts and tools in step 5.

Let’s get started!

Weather and Barometer Functions

explanation-for-barometer-readout.png

The Earth's atmosphere exerts pressure on the surface with 1013 mbar (hPa), defined as the standard pressure.

Thus, I decided that the standard pressure is the value in the middle of the scale of our display.

The unique feature is the history meters on our barometer, which will display absolute values between 1003 up to 1023 mbar, from "now" and ten hours back in time. Note that not every hour is available for the history meters. We only have six scales, so time is unevenly spaced out.

Actual pressure, with two decimals, is always shown above as a digital readout, with two decimals.

Learn to forecast the weather practically

Time to hone your weather and wind prediction skills without relying on the internet or mobile phone coverage. Weather meteorologists plot Isobars on their weather maps, which connect air masses with the same pressure. Much like a topographical map combines the same height. The wind will be stronger when these Isobar lines are tight together, which translates to the historical part of the display as rapid pressure changes over a short period.

Enough with weather talk. Let's continue to the next step.

Pressure Sensor BME680

pomoroni-bme680.png
old-kind-of-barometer.jpg

The mercury barometer was invented in 1643 in Florence, Italy. But it was not until the beginning of 1900 when the modern design without mercury became popular. It was much smaller, a commercial success, and widely used aboard ships.

Still, it is a mechanical device with friction between moving parts, influencing its ultimate precision and repeatability.

We can quickly improve these old-fashioned mechanical barometers with the BME680 sensor, an environmental sensor with temperature, barometric pressure, air quality, and humidity capability.

In this project, we will use the Pomoroni breakout board with the BME680 sensor. We can use other breakout boards from vendors like Adafruit, Sparkfun, or an unbranded CJMCU-680 on our flexible adapter board.

Specification for the BME680 is impressive.

  • humidity with ±3% absolute accuracy
  • barometric pressure with ±0.6 hPa (0 ... 65°C) and ±0.12 hPa (25 ... 40°C) absolute accuracy
  • temperature with ±1.0°C (0 ... 65°C) and ±0.5°C (at 25°C) absolute accuracy

Pressure specification is for absolute accuracy, and I expect the repeatability performance to be excellent.

ESP32 Development Boards

esp32-things-plus.jpg
esp32-tinypico.jpg
esp32-30pins.jpg
esp32-36pin.jpg

The heart of our project is an ESP32 development module. Thanks to the designed adapter board (step 13), we have many modules choices.

Looking at the list of available variations of ESP32 in the Arduino IDE gives you an idea of the variability.

I decided to limit the adapter board to a few implementations, use pins counts that are the most popular, and find the required pins for the project.

The project does not use ESP32 WiFi capability, but this can be something for the future.

Here is a list of the ESP32 units which this project can use.

  • 20 pin (for Unexpected Maker’s TinyPico ESP32)
  • 12+16 pins (for Sparkfun’s ESP32 Thing Plus)
  • 30 pins (for ESP32 Geekcreit's module)
  • 36 pins (for Geekcreit-DOIT's ESP32 DEVKIT V1)
  • 38 pins (for Expressif’s ESP32-DEVKITC-32D)

On the GitHub repository for the adapter board, you will find the latest updated list of ESP32 boards that should have the pins in the right place to be workable.

If you think you have a working ESP32 module for the adapter board, submit an issue ticket, and I will update the table in my repository.

If you wish the adapter board to be updated to include a new favorite ESP32 pin variant, write it in the comments.

TFT SPI 2.8” 240x320 Color Display

display.png
mounted-TFTSPI-240x320-display.jpg

There are many displays to choose from, but I like the SPI TFT 2.8” 280x320 pixels color display for my DIY projects. It's reasonable priced and easy to find online.

There is also good Arduino library support for this particular display and the ILI9341 driver.

Wiki documentation is available here.

The project does not use the built-in circuitry for touch functionality.

If you plan to experiment with the touch pins, make sure to buy a suitable model. Pins are broken out on the adapter board if anyone wants to try it out.

Necessary Parts and Suggested Tools

Components (use one from each group)

Boards:

  • ESP32 Geekcreit-DOIT's DEVKIT V1 - 36 Pins (Banggood)
  • ESP32 - Geekcreit's module with 30 pins (Banggood)
  • ESP32 Sparkfun's Thing Plus (12+16 Pins) (Sparkfun)
  • Unexpected Maker's TinyPico - 20 pins (Amazon)
  • Expressif’s ESP32-DEVKITC-32D - 38 pins (Mouser/TME)

Environment sensors:

Breadboard:

  • Breadboard BPS BB830 (Mouser) – optional
  • Breadboard Jameco Valuepro (Amazon) – optional

Additional components

  1. Display 2.8 Inch TFT SPI v1.2 Touch Panel 240x320 (eBay)
  2. DuPont cables for build on a breadboard (Amazon) – optional
  3. Male breakaway pin headers (Amazon)
  4. Female single row female headers kit (Amazon)
  5. The ESP32 adapter board (see step 13)

Suggested tools

  1. Soldering Iron (Amazon/Amazon)
  2. Solder wire (Amazon)
  3. Gorilla super glue (Amazon)
  4. Side cutter (Amazon/eBay)
  5. Blu Tack (Amazon/eBay)

Breadboard Build - Add Componets

7_breadboard_no_display.png

The next step is to build the project on the breadboard. Since it’s a good idea to test both the Arduino IDE setup for program loading and that the parts work together.

For this, we need a breadboard (or two, if using an extra-wide ESP32 development module) and some DuPont wires to wire it up according to the Fritzing schematic. The PCB schematic can also be helpful. If you use some other ESP32 module, refer to that pin out-diagram.

First, put

  • BME680 breakout board
  • ESP32 module
  • TFT SPI display

on the breadboard, similar to Fritzing schematic.

With an extra-wide ESP32 module with 38 pins, we need to use two breadboards to fully access the development board's sides (really just the 3V3 pin). Narrower modules require only one breadboard.

With only one breadboard and wide 36-pins or 30 pins module, an alternative is to temporarily use other available GPIO pins for TFT_CS and the TFT_DC signals for a test.

Breadboard Build - Wires to the Display

display-esp32-connections.png

Now connect the wires between the ESP32 and the display accordingly.

Note that there is no marking on the front side of the display. Therefore, the connection list to the left is in order from left to right.

Thus begin to add TFT_CS (third pin from left on display) to the ESP32 module. The next pin, TFT_RESET, is the fourth pin from the left on display, and so on. Leave the power connections for later and the LED pin for later.

Wide ESP32 boards workaround

There is a workaround for wide 30- and 36 pin modules, with only one breadboard.
Connect TFT_CS to GPIO 5 and TFT_DC to GPIO 2.

Remember to set these two temporary GPIO assignments back (step 11) as given in the schematic. That is TFT_CS to 27 and TFT_DC to 26. Otherwise, it will not work later on the adapter board.

Breadboard Build - BME680 Sensor and Power

9_breadboard_no_pwr.png
completed-with-power.png

1. I2C

Now add the two wires for I2C signals to BME680.

2. Power

Finally, we hook up the 3.3 V output from the ESP32 module to supply the display and the sensor.

The Fritzing schematic uses the three different power rails to distribute the breadboard's 3.3V (red wires) and the GND (black wires).

The display should not have any wires connected to the six rightmost display pins.

Time to test in the next step. We now have the complete project in a somewhat temporary setup.

Install Arduino IDE and Add Support for ESP32 Boards

esp32-boards-support-in-arduino.png
board-manager-for-esp32-in-arduino-cut.png

Install Arduino IDE

To use the ESP32 board with the Arduino libraries, you'll have to use the Arduino Integrated Development Environment (IDE), with added ESP32 board support.
Suppose you have not installed Arduino IDE yet; head over to Arduino's official site and download the current stable version (1.8.15 as of this writing) for Windows, macOS, and Linux. Do not install any beta software versions.

Add support for ESP32 boards.

Next is to add support for ESP32 boards with Arduino’s board manager.
Under the top menu, select "File-> Preferences." Then, in the new window, click the small symbol, far right, on the line that says "Additional Boards Managers URLs.". Select this, and this opens up a list of unsupported URLs for other boards. Next, visit Arduino's GitHub page for unofficial 3rd party board support URLs.

Scroll down the long list until you find Expressif's ESP32 support.

Please copy the link address, i.e. (https://dl.espressif.com/dl/package_esp32_index.js...) and add it to the end of the existing board's list in the small window as below. Press OK when done.

In the main menu, go to "Tools-> Board: *-> Board Manager" In the search box, type ESP32, and click the Install button to install support for many ESP32 modules manufactured by various suppliers. Close when done.

Open Boards Manager from "Tools-> Board:-> ESP32 Arduino", menu and select the correct ESP32 board. Choose, e.g., ESP32 Dev Module if that is the ESP32 module you have on the breadboard.

Next step

In the next step, we will install additional code libraries to make working with the Display and the BME680 sensor easier.

Get the Project Code and Install Arduino Libraries

bme680-library-install-cut.png
esp32time-library-install-cut.png
tft_espi-library-install-cut.png

Install libraries

The project requires three Arduino libraries. The easiest way is to use Arduino Library Manager to install them.
Select "Tools-->Manage Libraries" in the Arduino menu and search for the three required libraries.

  1. TFT_eSPI by Bodmer (Display hardware-specific library)
  2. BME680 by SV-Zanshin (Interface to the sensor)
  3. ESP32Time by fbiego (Interface to Real Time Clock in the ESP32)


ESP32 Nautical Barometer Gold Project Code

Download the latest released zip archive from GitHub to your sketchbook folder, and extract the source code there. You find the sketchbook location if you look in the Arduino menu, select "File-> Preferences" and "Sketchbook location."

After extracting the project archive, you have a folder named esp32-nautical-barometer-gold-1.0. In this folder, you find the Arduino code ready to be downloaded to your ESP32 module, which we will do next.

Library Configuration and Initial Tests

1. Libray (TFT_eSPI) configuration

Before using the display library, we must define which pins we use on the breadboard and the adapter PCB.

Open the Arduino libraries folder. You find this location if you look at the menu "File-> Preferences" and "Sketchbook location.". In the libraries directory, find and open TFT_eSPI/User_Setup.h file in a text editor.

Go through the file and adjust a few configuration parameters.

In Section two

In section two, you define the actual module and the pins to use. Likely, around line 158, you find that the ESP8266 module is by default set active; comment out all these lines with //.

Scroll down until you find the ESP32, in section two, around line #191 and activate and adjust pin-numbers. MISO is not required.

//#define TFT_MISO 19
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_CS 27 // Chip select control pin
#define TFT_DC 26 // Data Command control pin
#define TFT_RST 4 // Reset pin

Save the file.

It's good to do some basic tests that the Arduino IDE setup is working with the ESP32 module and the TFT SPI display.

2. Test Arduino IDE setup

Run the Blink program to test code upload. Open "File-> Examples-> 01. basics-> Blink".

ESP32 does not use Arduino's predefined LED_BUILTIN value. Replace it with:

#define LED_BUILTIN 2

Just hit the upload arrow button, and the code should compile and upload. The built-in LED should start to blink. If not, check that the com port is selected and that you have connected a good data USB-cable to ESP32, not the ones that only use only the power pairs. In some cases, you may need to push and release the ESP32's miniature boot button before Arduino IDE can upload the code.

3. Test the display

Open "File-> Examples-> TFT_eSPI-> Tests and diagnostics-> Colour_Tests"

Upload this file to verify that the library is configured and that the breadboard build is correct.

Upload Project Code

completed-breadboard-build-no-power.png
breadboard-first-power-on.png

Finally, load the project code.

Now open the downloaded code folder in Arduino IDE and click on esp32-nautical-barometer-gold.ino. By default, temperature values are displayed in degrees Fahrenheit. To change it to degrees Celcius, edit code, and set a define to zero, like so:

#define FAHRENHEIT 0

Now you are ready to upload the code, just hit the upload arrow button.

The first reading is visible after about 5 seconds delay. Note that only the first pressure arrows in the history indicate the current barometric reading in the "now" column. Thus, you have to wait 10 hours before all arrows have data to display. All values are read from the sensor once every hour.

The history values are lost when power is lost; therefore, an ESP32 module with a USB supply permanently attached is recommended, or an ESP32 module that has Li-Po battery connections, like Sparkfun's ESP32 Thing Plus.

Do not use long USB cables. A good supply for the project is a power pack or a USB power supply with good current capability. If the screen is black at start-up, it's likely to lack start-up current.

Another top tip is to push the reset button or try to upload the code again.

The ESP32 Adapter Board to Rule Them All

front-and-back-cupper-routing.png
with-ground-planes.png

Design of the adapter board

I have drawn the schematic and done the complete board design using KiCad software. It's open-source, free, and available for almost any operating system.

If you are new to KiCad, Shawn Hymel (at Digi-Key) has an excellent introductory guide on YouTube. The design workflow is as follows.

  1. Create your electrical schematic by placing ready-made symbols and draw lines (electrical connections) between them.
  2. Associate each component symbol from the schema to a component footprint, and you can also create your own.
  3. Load the resulting output (the netlist) from previous steps into the KiCad’s PCB Layout Editor.
  4. Next, draw lines between each pad between all components.

This last exercise can be a tedious process if you have many parts. I spent most of the time creating this adapter board's footprints for the BME680 breakout boards and the ESP32 development modules.

Several sites offer free electrical symbols, footprints, and 3D models for downloads, like KiCad, Ultra Librarian, SnapEDA, and GrabCAD.

Fabrication

amazing-esp32-adapter-board.png

In the KiCad menu, select "File-> Plot." The output of this command creates the required files for fabrication. Feel free to send them to OSHPark, EUROcircuits, JLCPCB, or PCBWay for manufacturing.

All my adapter PCB design files are on GitHub and are free to download for tinkering. In case the actual design changes, all files are kept in this repository.

Prepare Male Header Pins

two-male-headers-and-cutter.jpg
more-male-header-pins.jpg

After receiving the adapter board from the PCB fab house, we must prepare our male header parts. For this, you need a side cutter.

1. Male header pins for the adapter board- optional

With the side cutter, cut, so you have two dual-pin male headers.

  • Jumper J1- 1x2pins (male) - 1 pcs, for TinyPico v1 reset
  • Jumper J2- 1x2pins (male) - 1 pcs, for UART TX debug port

2. Male header pins for your sensor

  • U8 - BME680 Pomoroni - 1x5pins (male ) - 1 pcs

I only have the Pomoroni BME680 with five pins, so I make a 5-pin male header with the cutter, which I later solder to the sensor. If you have other BME680-modules, cut the appropriate number of pins.

3. Male header pins for your ESP32 module of choice

Many ESP32 development modules come with male header pins already soldered, so that this step may be completely unnecessary.

  • U1 - ESP32 Sparkfun Thing Plus board - 1x12pins (male) – 1 pcs
  • U1 - ESP32 Sparkfun Thing Plus board - 1x16pins (male) – 1 pcs
  • U2 - Expressif’s ESP32-DEVKITC-32D board 1x19pins (male) – 2 pcs
  • U3 – UM ESP32 TinyPico - 1x10pins (male) – 2 pcs
  • U4 – ESP32 – module with 1x15pins (male) – 2 pcs
  • U5 – ESP32 - DOIT DEVKIT V1 - 1x18pins (male) – 2 pcs

Prepare Female Headers

super-glue.jpg
with-adafruit-u9.jpg

We must prepare our female headers parts. For this, you need super glue unless you find the exact header combination for your need. Thus, see this as an alternative solution.

First, align headers nicely on a flat surface and against a ruler or similar. Then, glue the missing pin combinations together. Again, some rubbing with abrasive paper improves the strength of the two pieces.

1. Make female headers for adapter board ESP32 positions

Here I assume that we want to make all female headers for all ESP32 modules unless you plan to solder the ESP32 development module to the adapter board.

  • U1 - ESP32 Sparkfun Thing Plus module - 1x12pins (female) – 1 pcs
  • U1 - ESP32 Sparkfun Thing Plus module - 1x16pins (female) – 1 pcs
  • U2 - Expressif ESP32-DEVKITC-32D module - 1x19pins (female) – 2 pcs
  • U3 – UM ESP32 TinyPico - 1x10pins (female) – 2 pcs
  • U4 – ESP32 - Geekcreit module with 1x15pins (female) – 2 pcs
  • U5 – ESP32 - Geekcreit-DOIT DEVKIT V1 module - 1x18pins (female) – 2 pcs

Use the following combinations based on what you have in the Amazon female header box kit. Put a tiny amount of super glue on both sides of the female headers, align them, and press them together for five seconds.

For U1 (16-pin), we need to build one from 8 + 8 headers. The 12-pin header should be in the box kit.

For U2 (19-pin), we need to build two from 8 + 6 + 5 headers

Alternatively, you can trim off one position with the side cutter from the 20-pin header without damaging the 19th position.

Headers for U3 (10-pin) should be in the box kit.

For U4 (15-pin), we need to build two from 10 + 5 headers.

For U5 (18-pin), we need to build two from 12 + 6 headers.

2. Create one Adafruit female header for their BME680

Only the Adafruit BME680 (7-pin) needs some creativity. Here we can combine 4 + 3 female headers and glue them together. Headers for the remaining sensors (U6, U7, U8) are in the box kit, i.e., 4-pin, 5-pin, and 6-pin headers.

3. Create female headers for the SPI Display

  • U10 – Main SPI connector 1x14pins (female) – 1 pcs
  • J3 – Auxiliary SPI connector 1x14pins (female) – 1 pcs

The display itself uses eight positions, excluding touch functionality. Thus, we do not strictly need any glued modifications to extend the main connector to the full 14 positions. You may want to add additional mechanical support for the display or a fully used auxiliary connector by gluing a six-pin header.

4. Female or male headers for the auxiliary connector (J3) - optional

For the J3 auxiliary connector, glue one eight-pin plus one six-pin headers together for this purpose. Another option is to use male header pins and not female headers, and for the latter case, use the cutter to make the 14-pin male header. Finally, we should have all the needed parts for soldering to the adapter board itself for the next step.

Solder Male Headers

solder-pins-on-esp32.jpg
solder-pins-on-bme680.jpg
solde-male-headers-on-board.png

For soldering, you will need a good soldering iron and solder.

1. ESP32 modules

Put the male header pins in a breadboard, giving the correct positions between pins for all the ESP32 modules at hand. In this way, all pins will line up, so they are perpendicular to the board. Next, apply a small amount of solder to the iron and heat both the header pin and the pad on the module board. In this way, this prevents bad solder joints.

2. Sensor breakout boards

Use the same technique above for the breakout board to fixate the male header pins when soldering the BME680 sensor.

3. Solder J1 and J2 to the adapter board - optional

Locate the J1 and J2 positions on the adapter board.

Use Blu Tack to hold the header pins in place on the module-sensor side while soldering the pins on the display side.

Solder Female Header on the Display Side

solder-female-headers-for-display-new.png
female-header-on-display-side.jpg

Female headers for the SPI display
Position the female headers according to the figure on the display side. Then, use Blu Tack to hold the female header while soldering the pins. Next, solder the female header, one 14-pin on the module-sensor side of the adapter board.

Solder Headers on Module-Sensor Side

front-view-female-headers.jpg
solder-headers-for-auxiliary-connector.png
solder-female-headers-for-bme680.png
solder-female-headers-for-esp32.png

Flip the board to the module-sensor side and mount the remaining headers.

1. Female headers for ESP32 modules

Position all the female headers according to the image on the module-sensor side. Then use Blu Tack to hold parts in place while soldering the pins on the display side of the adapter board.

2. Female headers for sensor breakout boards

Use Blu Tack to hold the female headers on the module-sensor side while soldering the pins on the other side.

3. Female or male headers for the auxiliary connector (J3) - optional

Position the additional female headers or male pins according to the figure on the module-sensor side. Again, use Blu Tack and solder the female 14 positions header or optionally one 14 pins male header, for the J3 auxiliary connector.

Final Assembly and Test

ready-for-assembly.jpg
powered-esp32-finally.jpg
powered-display-finally.jpg

1. Mount one ESP32 on the board

Carefully insert the ESP32 module with the matching number of pins with the ESP32 module at hand. For orientation, the USB connector is always facing outwards on the board to simplify powering the barometer. Warning: Please carefully check your ESP32 module's pin-out diagram, particularly the power (3V3 and GND) If you don't use the same ESP32 modules. The electrical schematic shows which GPIO ports are in use for the project.

2. Mount the BME680 sensor

Insert the BME680 sensor breakout board. The text shows which sensor position is correct. Next, place it according to the printed white silkscreen.

3. Attach the 2.8” SPI TFT Display

Turn the adapter board around and insert the display, and you are ready to power up the completed project. Congratulation if you have come all the way here with the project. You may attach the display to the auxiliary connector on the module-sensor side facing outwards during software development. Be careful to insert the display in the correct orientation. 3V3 and GND are clearly marked on the adapter board but not on display.

4. Attach the power and upload code

Connect the USB cable to power up the board. The Arduino setup was described and tested in a previous step. Thus we only have to open the downloaded project code, extract the code in your sketchbook folder, open esp32-nautical-barometer-gold.ino, and push the upload button. Hold down the boot button in case Arduino IDE upload does not starts. The display shows the humidity- and first pressure readings after five seconds. Press the reset button on the ESP32 module if the barometer scale is not shown as above.

Enjoy your very accurate readings!

What's Next?

completed-barometer-with-power-pack.jpg

Finally done

Now, with the "nautical barometer gold" electronics done, we need some enclosure.

Your Enclosure

I did a golden wooden frame for the nautical barometer in the final next step. Alternatively, put your newly created project in a 3D-printed enclosure if you have a printer.

Your feedback and thoughts

Please, feel free to provide your experience with this project or if you want to give some constructive comments, good or bad. Do you miss any feature, or what ESP32 do you like the most, your favorite display that you would like to see? Support for other pressure sensors, the use of WiFi, or any other ideas is welcome. Maybe there will be a second version of this project?

Credits

Two excellent Arduino libraries made this project possible.

Build the Enclosure

wooden-frame-backside.jpg
cut-out-dimensions.jpg
barometer-in-foam.jpg
barometer-half-in-frame.jpg

List of materials

  1. Wooden picture frame - (Amazon/eBay) mounting area greater than 168x138 mm (6.6”x5.4”)
  2. Sheet of foam board, white or any color - (Amazon/eBay) 5 mm (3/16”)
  3. Velcro self-adhesive fasteners – (eBay)
  4. Carpenters knife (Amazon/eBay)

1. My picture frame

I decided to reuse an existing picture frame, which I thought was a perfect fit for this project since it was "golden." Any small wooden picture frame should work as long as larger than the adapter board dimensions: 168x138 mm (6.6"x5.4"). I removed the glass, which I did not use. Every picture frame is slightly different in size and depth, so that some improvisions may be necessary.

2. Attach Velcros fasteners

Cut out the opening for the display area, 50x70 mm (1.97”x2.76”) in the foam board. Next, attach four small pieces of Velcros fasteners to the corners of the foam board and the adapter board.

3. Assembly adapter board into the frame

Fit the completed board-foam assembly into the wooden frame and secure it, and this project is complete.