Introduction: Global Earthquake Display

The crust of the Earth is in constant motion. It's moving very, very slowly but in some places the pressure builds and builds and suddenly catastrophically releases in what a scientist would call a seismic event, or in more common parlance . . . an EARTHQUAKE!

This is an Internet Of Things desktop gadget which takes data from a publicly accessible database and displays the location and magnitude of earthquakes on a world map in nearly real time.

It is also an opportunity to showcase a different way of programming the ESP32 or ESP8266. Annex RDS enables these versatile IOT devices to be programmed in a very well featured version of the BASIC programming language.

The only things you will need for this project are an ESP32 board and an ILI9486, ILI9488 (480x320) or an ILI9341 (320x240) TFT display. Optionally an old USB lead for power and a 3D printed case if you want one of these to sit on your desk. I've designed a suitable case for this at the bottom of the Instructable.

Step 1: Building the Electronics.

There are several designs of ESP32 development boards available but the one I'm using is one of the shorter boards with 30 pins. Any variant will be suitable as long as it gives access to the pins in the connection diagram above. As we're running the display at 3.3V, also solder bridge across the tiny J1 on the PCB. This is the simplest wiring connection to get just the display functioning. Additional connections are required to enable the touch screen and SD card . (Annex RDS supports both these features.)

Connect the display as shown. If you intend to run this long term then I have found the best way to power the board is using the 5V power in an old USB mouse cable with the mouse cut off and the (almost always) red and black leads to VIn and Gnd on the ESP32 board. The USB plug goes into a standard 5V wall-plug USB charger. See the Step5 for STL of a suitable 3D printed case for the most common version of the display.

Step 2: Flashing the ESP32 and Loading the Code.

See step 6 for an updated version of this program with versions for ILI9341 (240x320) or ILI9488 / ILI9488 (320x480) displays.

Firstly, register with the Annex RDS support forum which will give you download permissions. Then download the latest copy of the Annex IDE and flasher from HERE and unpack it to a location of your choice. 'Run AnnexToolkit.exe' and it will create a directory structure below that. It is compatible with Windows, Mac and Linux. Copy the the files 'quakes.txt' and 'map-l.txt' (attached here) to the 'Uploads' folder and rename them to 'quakes' and 'map-l.jpg'. Click the file 'win.bat' to run the toolkit.

Connect a USB cable to the ESP32 module and run the flashing software. On the Serial Flasher screen, select the COM port from the dropdown and then click the 'Erase the flash memory' tab.

Once that has completed, click the 'ESP32noBLE' tab and then 'Flash firmware + OTA + data', then enter your network credentials, desired network address, subnet mask and gateway in the box which appears. Once programming has completed, power-cycle the ESP32 module.

Using your favourite browser enter the IP address you've set for the module and you should see the IDE appear. Select the 'File manager' tab, then 'Upload and select 'quakes' and 'map-l.jpg' then 'upload'.

Click on the 'Config' tab and enter '/quakes' in the 'autorun' field and then find your timezone HERE and enter in the 'Time zone' field. Also select the screen type you're using from the TFT/Dropdown field. Click the 'Save' button.

If you're using an ILI9488 you'll need an Annex update. As long as you're registered on the forum, download the Zip for 1.43.5 from the bottom of the first post HERE and copy the unzipped binaries to the 'build' folder of the toolkit, then either do an OTA update (there's a tab in the toolkit and you'll need to set the OTA parameter on the 'config' screen of the ESP32) or via the USB serial. You'll then see ILI9488 in the display selection dropdown.

Go to the 'Editor' tab, 'Open' and select 'Quakes'. You should now see the program in the editor.

Select 'Run' and you should see the map appear on the display screen and the first earthquake displayed. It's very variable but you would usually see 150 or so events appear every day.

Because we set the 'autorun' program, this will automatically run if the unit is powered down and restarted.

Step 3: The Data Source - Seismic Portal.

This project is requesting data from Seismic Portal. This site aggregates data from the several regional monitoring authorities into one global database and among the services available (ostensibly for geophysics research professionals) it provides a free-to-use API where recent and historical seismic event data can be requested. My monitor polls the feed avery 30 seconds to see if there have been any new ocurrences.

For those wanting to learn more about the causes and effects of earthquakes there's an interesting 10 minute seismology primer by the California Institute of Technology on YouTube.

Step 4: The Map Display

Because the Earth is a sphere (OK, an oblate spheroid) and a monitor screen or a standard paper map is flat, it is impossible to accurately represent the earth on a screen without either distances, areas or angles being distorted. The way this is done is with a map projection and over the years many have been proposed. The one most people are familiar with is the Web Mercator projection which you will have seen if you've ever used a mapping program such as Google Maps.

I am using a copy of the Web Mercator map reduced to 480x320 for the LCD screen but I have taken a few liberties with it to improve the presentation. For starters I've chopped off Antartica as nothing of seismic interest happens there. Then I've shifted the map a few degrees west relative to the screen so that New Zealand and the surrounding ocean (an area of high seismic activity) are not on the very edge of the screen. The lines of latitude and longitude are still correct.

The most recent earthquake is shown on this monitor as a flashing red / yellow circle with the diameter proportional to the magnitude of the earthquake. A history of the most recent 100 earthquakes will be displayed with newer ones in yellow, fading through a dull red to brown for the oldest ones. The display shows clearly what are the most active areas of the world at any time.

Occasionally you may see only a small number of dots on the display. This is due to a lot of activity in a small geographic area so the dots are overlaying themselves. As I type this, a volcano is erupting in the Canary Islands after a couple of weeks of intense seismic activity.

Step 5: Annex RDS - BASIC for ESP32 / ESP8266

Annex Rapid Development System is the work of Francesco Ceccarella (CiccioCB on the Annex forum) as a personal project who has made it available to the Maker community for non-commercial use. Programming is done on-chip using a browser interface and programs can be run immediately with no compilation stage. Debugging and logging are supported, as is full syntax colour coding.

Commands to control many common devices are included within the language and the developer is responsive to adding additional ones if it will benefit the community. Annex supports several LCD, OLED and dot matrix displays, WS2812 LEDs, many sensors and I/O devices, several communication methods, a sound player with streaming abilities, speech synthesis, an object based GUI, Bluetooth comms, OTA firmware updates and many more. It is astonishing what is packed in there!

Annex RDS is a way of getting into IOT programming with the ESP32 or ESP8266 with a much more gentle learning curve than most other IDEs. This makes it ideal for rapid development, is great for the older maker community who may find C++, LUA, Java or Python too daunting, or anyone who wants to get results quickly in a programming language that resembles English. The downside is that because it is an interpreted language it is considerably slower than compiled C++, but plenty fast enough for the majority of projects.

The best way to get a feel for what Annex offers is to look at the help file. There is a First Steps and Flashing Procedure guide but these are on a website which is no longer updated. The place to go for support is the Annex Forum. The developer and other users are friendly and helpful.

The .STL files for a suitable case for the 3.5" display I used are below. Make sure all is in place and working before clicking the back on as once in place it's a veritable devil to remove.

Step 6: Addendum : Updated Program and Addition of ILI9341 Display Version.

This is an updated version of the Earthquake Monitor software with the code tidied a bit, additional comments, overnight display dimming and improved map dot accuracy. It comes in two versions :

Download Quakes32-L.txt and map-l.txt (rename to map-l.jpg) if using ILI9488 or ILI9487 (320x480) display.

Download Quakes32-S.txt and map-s.txt (rename to map-s.jpg) if using ILI9341 (240x320) display.

Other instructions are the same as Step2 but be sure to select the correct display type on the 'Config' screen once you have a browser connection to the ESP32.

Maps Challenge

Runner Up in the
Maps Challenge