Global Earthquake Display

11,014

141

78

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

Be the First to Share

    Recommendations

    • Microcontroller Contest

      Microcontroller Contest
    • Fandom Contest

      Fandom Contest
    • Metal Contest

      Metal Contest

    78 Comments

    0
    degerang
    degerang

    Question 2 months ago

    hello
    it worked for many mounts
    today it shows a qr code i scanned it
    annex32 wifi can 1.43.5
    how to get it working
    Lasse

    0
    AndyGadget
    AndyGadget

    Answer 2 months ago

    Hi Lasse.
    On the screen with the QR code it also shows the IP address and the network it's connected to. If the address is 192.168.4.1 then it may have lost its configuration; that's happened once or twice to my devices. You may have to re-flash it with the toolkit, If it is connected to your network then open te address with a browser and check the autorun setting on the config page.
    Andy.

    0
    dpcons
    dpcons

    Question 1 year ago

    Where is the AnnexToolkit.exe file located? I downloaded and unzipped the files and don't see the executable.

    0
    Namirred
    Namirred

    Answer 1 year ago

    If you are using windows there is a file called win.bat run that and the toolkit will run

    0
    dpcons
    dpcons

    Reply 1 year ago

    Thanks for the reply. I finally saw the documention regarding that. Now I have to figure out how to run the quakes app. If I upload it from the upload folder, it says it's successful, but when I open it...it's empty. I'll do more reading. Thanks again.

    0
    dpcons
    dpcons

    Reply 1 year ago

    What version of Annex did you use? On the latest version I'm getting lots of syntax errors in the Quakes code. Seems the annextoolkit appears different also.

    0
    AndyGadget
    AndyGadget

    Reply 1 year ago

    Hi Dpc. Apologies, I missed your comments before.
    The toolkit should be v0.9beta.
    I'm suprised you're seeing syntax errors. You're definitely using an ESP32 (not an ESP8266) are you? Annex should be Annex32 WiFi CAN 1.43.4 (at the top of the 'editor' screen) or 1.43.5 if you're using an ILI9488, as per my updated instructions in step 2.

    0
    dpcons
    dpcons

    Reply 1 year ago

    I'm using Annex32 WiFi 1.43.2 CAN BLE and 1.09 of the toolkit and an ESP32 Devkit 30-pin...like the one in your writeup...I have several.

    0
    AndyGadget
    AndyGadget

    Reply 1 year ago

    You've picked up the old version of the toolkit and a slightly outdated Annex version. Delete that and download the new multi-platform version and Annex 1.43.4 from the top HERE then grab and unzip Annex 1.43.5 from the bottom of that first post and copy the BIN files to the BUILD directory before you flash the ESP32. (The version number of the toolkit has stepped back from what you have as it's now a different program and the one that the developer will be working on going forwards.)

    0
    dpcons
    dpcons

    Reply 7 months ago

    Sorry. I think I forgot to say thanks for all the info you sent. Thanks! It all works well.

    0
    dpcons
    dpcons

    Reply 1 year ago

    Thanks for the update. I'll make the changes.

    0
    dpcons
    dpcons

    Reply 1 year ago

    Reloaded 1.43.5...appears to work, now just waiting for quakes.
    Thanks again for your help.
    Dan

    0
    Zathras-42
    Zathras-42

    Reply 1 year ago

    Seen the same. Make sure you hit Save in the Editor. That worked for me.

    0
    dpcons
    dpcons

    Reply 1 year ago

    Thanks for the response. Now, sometimes it works...sometimes not. Seems like a nice package. Alot there. Some discrepancies in the documentation. Again thanks.

    0
    heamou8801
    heamou8801

    10 months ago

    wow looks sick
    it could be used in other stuff like cheating in a test
    (just a joke)

    0
    SoakedinVancouver
    SoakedinVancouver

    10 months ago

    Hi Andy, great project! but i am a bit disappointed that nobody used an output pin to run a vibrating motor under a car dash mount Hawaiian Hula dancing girl statuette as an event feedback...

    0
    AndyGadget
    AndyGadget

    Reply 10 months ago

    You're right - It needs one of those!
    Unfortunately in the UK they're either way overpriced or come on the slow boat from China . . . but, watch this space :¬)

    0
    fireman87
    fireman87

    10 months ago

    Hi Andy,
    This is my first ESP32 project and it works really well.
    Thanks for the detailed explanation how to make it.
    I have just one question, is it possible to have an output on the ESP32 that goes high for around 100ms when a new event appears? as I would like to have short beep when there is a new event.
    I looked at the code but its a bit beyond me how to do it.
    I can add it in the editor if you can let me know what and where to put in.
    your help would be appreciated.

    John

    0
    AndyGadget
    AndyGadget

    Reply 10 months ago

    Hi John.
    We'll use the PWM command to make a beep, so connect your sounder between just about any spare data pin - gpio5 is as good as any - and Ground.
    Add this line near the top of the program, after tft.brightness 255.
    pwm.setup 5,1,0,1000
    Add this code to the MsgReceived routine, after the OldRef$ = Ref$ line.
    'Beep on event
    if not((Hour >=22) or (Hour <=7)) then
    pwm.out 1,128
    pause 100
    pwm.out 1,0
    end if

    This will silence the beep overnight. Leave out the IF and END IF lines if you don't mind being woken up in the middle of the night :¬)