element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Achievement Levels
    • Benefits of Membership
    • Feedback and Support
    • Members Area
    • Personal Blogs
    • What's New on element14
  • Learn
    Learn
    • eBooks
    • Learning Center
    • Learning Groups
    • STEM Academy
    • Webinars, Training and Events
  • Technologies
    Technologies
    • 3D Printing
    • Experts & Guidance
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Arduino Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Project Groups
    • Raspberry Pi Projects
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • 'Choose another store...'
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Würth Elektronik
  • Products
  • Manufacturers
  • Würth Elektronik
  • More
  • Cancel
Würth Elektronik
Blog WE testing around the World: Mesuring height of Burj Khalifa using Pressure Sensor
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Würth Elektronik requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: nwieland
  • Date Created: 24 Aug 2022 5:28 AM Date Created
  • Views 2070 views
  • Likes 9 likes
  • Comments 9 comments
  • testing
  • sensors
  • burj khalifa
  • würth elektronik
  • wireless connectivity
  • WE testing around the World
Related
Recommended

WE testing around the World: Mesuring height of Burj Khalifa using Pressure Sensor

nwieland
nwieland
24 Aug 2022
WE testing around the World: Mesuring height of Burj Khalifa using Pressure Sensor

Mesuring height of Burj Khalifa using Pressure Sensor

image


 

BY GOPI PATEL

Scene Setting:

Vacation inspires all of us; it recharges our mental batteries and open opportunity to reflect on true purpose of the professional work and perhaps connect our actions with real life. Every journey motivates me, especially when flying high - a burst of idea is obvious to most of us; welcome on board long-haul flight to Dubai, a city with hundreds of world record including the tallest building on the planet – Burj Khalifa. Tallest, how tall? How to measure it? It there a simpler way to estimate altitude? Etc… you can imagine one idea and several questions, all about heights and altitude at 42,000 feet in a one of the largest aircraft. I am a design engineer with 30 years of experience and able to build most prototypes by hand, so it was obvious that I always carry some gadgets to satisfy my curiosity. Do you remember a quote something like…

image

“Altitude is determined by your attitude”.

Expectations:

In this article, you will learn how simple it is to measure altitude using Arduino and the most simple pressure sensor. WSEN-PADS is smallest I2C or SPI pressure sensor with integrated temperature sensor operating temperature range -40°C to +85°C. Calibrated pressure data output via 128 FIFO buffer that can update up to 200 time a second (not that I was ascending at a fighter-jet speed). Measureable pressure range 126kPa to 26kPa and relative accuracy ±2.5 Pa; which mean you could potentially measure atmospheric pressure up to 10km above or 1km below sea level; just perfect to do what I wanted to do. By the way Burj Khalifa the tallest building in the world is 160 stories tall, has fastest lift in the world and several other Guinness world records. This experiment was done without any calibration; neither temperature compensated, nor sea level zero balance. Miraculously it worked well in the maiden attempt up to 126th floor; now you will read how did I do that. Of-course it was not that easy to carry bare electronic circuits through security, I had to get special approvals and assure no disturbance or hazard of any sort. If you think of doing something like this, then you must consider all aspects of risk, safety, compliance and convenience to others around you. Vantage point 360⁰ Dubai view from top of Burj Khalifa is pretty spectacular. Once you are on the top, do yourself a favour and invest in very inspiring book “Flashes of Thought” by Sheikh Mohammed bin Rashid Al Maktoum. This book is now one of my favourite collection. 

Sensor Shield for Arduino:

image

First, I took a sensor shield and mounted on to Arduino Uno to make-sure blink LED works on its own, then I inserted PADS and ITDS Eval boards in to I2C headers. I got their examples from GitHub and made sure both sensors are working well. Good thing about this is that they are quick connect without any tools. Though you will not need to worry about I2C connections, I have also provided a pinout detail in the table. At the beginning, my Arduino code started to read pressure, temperature and values of acceleration of X, Y and Z-axis on the serial terminal. I could just modify few lines of program to convert pressure in to altitude and keep reading on a serial terminal; well, being an engineer, I challenged myself to go beyond this. I wanted to see all these data on my mobile phone, so I created bespoke app using MIT App Inventor, took me about three hours to make all that working. Are you excited to know what challenges I had to overcome?

image

               image

Second, I needed to mount a Proteus-III BLE module on a Sensor Shield, fortunately, there was already a placeholder and I only soldered FOUR pins (VCC, GND, TX and RX). In my hand-assembled prototype, you will see two wires (TX + RX) mounted on a pin header rather than soldered permanently, that is because Arduino UNO only have single UART that is shared between programming and BLE, so during firmware upload I lift two pins and during normal operation I insert them on the socket. If you do not do this then it will not allow to program or not work at all. Okay, we also need to consider the TX of BLE must join to RX of Arduino and vice versa. At this point, my job was only 25% done, I still needed to write firmware for Arduino, make android app and then debug all hardware + firmware + appware. You may be surprised how easy it was once I set my mind to do this adventure, time was ticking as I only had couple of days left in my vacation before catching return flight to UK. Third, I tackle firmware, here you can find working codes, they are not scrutinized and never verified by any other professional so expect scope for improvements, feel free to modify to your taste. Original PADS Sensor example was downloaded from GitHub, I did modified example just to get absolute pressure data in mbar and temperature in degree Celsius.

image

imageimage

Firmware:

Almost any mcu firmware can be split into FOUR chunk: 1) include, 2) setup, 3) main loop and 4) call sub-routines.  Writing code is an art, you can never perfect and always evolves as you debug or progress. To get sensor data and calculate distance and then send over to BLE required some modifications to the original PADS example. I started with including Würth Elektronik PADS header file to quick start, then define some global variables as in the lines 1:9 below. Arduino likes float, byte and int as numeric variable and it works well. On STM32 or PIC micro you might need to use uint8, uint16, char or int8 style of RAM. If answer you expect contains decimal point then you should use float, else keep it positive integer. Buffer for UART transmission is named as tx[100] mean there are 100 spaces [0 to 99 inclusive] for  UART data. In line #30 you will see I am using 90 bytes a payload and about 7 other add-on, which mean I am within my allocation RAM buffer size. Checksum variable is important in secure BLE data exchange; I have defined as ‘csum’ on line #7 and used it on lines 43 and 45.

Include:

image

Of-course these way of coding is my short cut for private use, professionally I have much different style of writing firmware with lot more meaning and colleague-friendly. It is better to create your own file.h so that you can keep re-using the same library.

Setup:

Setup() is a one-off routine, required by Arduino compiler. Let’s keep UART 115200 baud rates and initiate serial communication along with usual checkpoints in steps 13:21. Throw error messages if no sensor was detected, here you could blink LED if you wish. Since I used readymade SDK example from GitHub I never needed to worry about address, however if you like to know more, see chapter 4.3.6 depicts slave address mechanism. SAO pin helps alternating address selection.

image

Before we move to next topic, I recommend looking at the AppNote ANM003 to learn how pressure to altitude can be done professionally. Lot of my practice run was done on a “Smart Commander”, download free. This proves that there are many road leads to Rome, and Rome was not built in one day.

“The fortune is for those who dare to dream and find the courage to pursue their dreams”

– Flashes of Thought, page 34. 

Main Loop:

Main program executes in a Loop between lines 51:74 to get raw I2C reading, then convert pressure to actual millibar and Pascal in a 16bit, then split in to LSB and MSB for easy transmission via BLE. In Arduino there is a nice command called map, I used that to convert pressure in to meters. I accepted temperature reading as it is because it is factory calibrated according to datasheet. Line 65:68 are optional and very useful to see all the data on an Arduino or other serial terminal using Serial.print command. You can imagine not much happening in this loop, so it could repeat hundreds of time per second. By adding deliberate 1000ms (1 second) delay #73, I can avoid overloading the TX buffer.

image

image
Image below is a screenshot of Arduino serial monitor; you can see one new packet each second. Timings could be accurate if interrupts were used, never mind, we are on different agenda here. Did you know that there is a ticket to go to the top of the world - floor 126 of Burj Khalifa, and there are usually long que and all lifts are fully loaded with people? So to avoid risk of firmware-crashing, sensor-malfunction or out-of-range data, I used my hotel lift as a calibration laboratory and I trialled few times up and down 16 floors. Fortunately, hotel lift had no queue at early morning 5am nor any ticket. I was enjoying sensor board, Arduino, android phone and laptop. Launch day we arrived early at the Burj Khalifa, security checkpoint told me that laptops are not allowed in the world’s fastest lift. Well, in order not put myself in trouble, I politely informed concierge manager and couple of receptionist, in emirates everyone are very cooperative.  

image

MSB x 256 + LSB = 16 Bit data    so that … 3 x 256 + 237 = 1005 mbar

Proteus-III BLE Send Data:

Proteus module can exchange bidirectional data in two different mode 1) transparent mode and 2) command mode. Transparent is easy, but I am not here for easy ride, so I chose command mode. In command mode you can do lot more complex things securely, read more in the Proteus-III user manual. sendProteus() is my own  call sub-routine lines 25:49 that sends data over the air to a mobile app via Proteus-III BLE. #26 pre-fills every byte with 0 to 99, I found it useful when developing android app, and it keeps placeholder of each byte. #27 is a simple counter that increases every time I send data, mind that I have no requirement to read acknowledgement so we will not talk in this experiment.  #28 is a first tx buffer, always 0x02 for all Würth Elektronik radio modules. #29 is a command byte (can be any command e.g. change BLE name, change PIN, stop advertising, go to sleep etc), command 0x04 mean I need to send some payload. In addition, the length of payload is defined by 16 bit in #30/31 because Proteus-III can handle up to 964 byte, which is more than one byte. Fill the buffers (4 to 93) with actual payload and then last byte 94 is checksum byte made using exclusive or of all the previous bytes (0 to 93). That’s it, my program successfully sent send data to BLE or computer.

image

image

The difference between actual 452m at level 124 and 590m on my android mobile app is 138 meter, can be down to three main factors, a) I forgot to consider ZERO at the start of the test on ground level, b) I did not account temperature calibration formula, the relationship between pressure and altitude is not straight line, and c) I enjoied roof-top lunch with my wife then took express lift through Emporio Armani suite to level 126 where I stopped my app but the plack “You are here – Level 124 – 452m” was on of-course on two level below which is open air balcony for tourist.

image

Check their dessert, cakes are super delicious. The more tastier item was “Tennis Ball” which has five sensors (Temperature, Pressure, Acceleration, Humidity and Light), STM32, long range 600m BLE combined with 2.4GHz MESH radio (Setebos-I) and powered by single coincell which could last few years; seems amazing isnt it!! Keep an eye on another publication, I have done several experiments with it in Dubai, London and few places in Europe; it is going to be the best ever tool for IoT engineer.  Hey, I am willing to publish how to develop best IoS or Android app, please comment your feedback.

image

Acknowledgement:

You must understand that this was just curiosity experiment and not a final product in any shape; nevertheless, you may be able to invent commercially viable design for application of your imagination, I wish very best on that. I, my colleagues, Würth Elektronik, publisher or other names mentioned in this draft take no responsibility for loss or damage of any type. Idea here is to show you possibilities and capabilities, I chose Burj Khalifa because not only it is the tallest building in the world and pressure sensor is on the extreme the tiniest in the electronic industry; but I chose this venue to respect their creators, visionary management and ambitious builders who risk their lives. I enjoy doing challenging experiment entirely on my own risk, self-funding and self-learning; I did not get any sponsor and this is not a paid marketing advertisement. Honestly, I do this for the electronic engineering brains across the world. Please like and share if you found this useful. Write your comments and feedback along with what else you curiously expect. Massive thank goes out to my wife Ragini, she carried gadgets in her backpack and tolerated my frequent change of direction.

image

  • Sign in to reply

Top Comments

  • nwieland
    nwieland over 1 year ago in reply to dougw +1
    Hi dougw , we are happy that you are interested in the topic and for your question thats good thinking I talked with Gopi and he said "Top of Burj Khalifa viewing gallery has open air with no ceiling…
  • Gopi1
    Gopi1 over 1 year ago in reply to dougw +1
    Much appreciated your comments, you are absolutely right about indoor/outdoor pressure difference. I had no issue at open roof viewing gallery on top of Burj Khalifa.
  • Gopi1
    Gopi1 over 1 year ago

    Check this AppNote : https://www.we-online.com/catalog/media/o179223v410%20ANM003_Pressure_altimeter_using_absolute_pressure_sensor_WSEN-PADS.pdf 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dougw
    dougw over 1 year ago

    I did a similar project with an accurate Würth sensor that could discriminate 3 inch changes in altitude:

    /products/roadtest/rv/roadtest_reviews/1578/wrth_elektronik_sens_1

    I am still looking for known elevations to test its accuracy over greater heights.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Gopi1
    Gopi1 over 1 year ago

    Hello everyone, I have just joined the silicon club - e14. How is life here !!

    Logic will take you from A to B. Imagination will take you everywhere. - Albert Einstein 

    Based on this quote, you could imagine I use GPS and curiosity (rarely any logic). 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Gopi1
    Gopi1 over 1 year ago in reply to dougw

    Much appreciated your comments, you are absolutely right about indoor/outdoor pressure difference. I had no issue at open roof viewing gallery on top of Burj Khalifa.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Gopi1
    Gopi1 over 1 year ago in reply to nwieland

    Cheers Nicola for uploading this post, I hope audience will learn, experiment and of-course hit like button. I have just joined the e14 community, nice to meet you here and all the members. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube