{"id":942,"date":"2017-06-11T21:43:39","date_gmt":"2017-06-11T19:43:39","guid":{"rendered":"http:\/\/www.albertopasca.it\/whiletrue\/?p=942"},"modified":"2023-10-10T17:06:48","modified_gmt":"2023-10-10T15:06:48","slug":"arduino-ios-bike-speedometer-tracking-using-bluetooth","status":"publish","type":"post","link":"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/","title":{"rendered":"Arduino\/iOS &#8211; Bike speedometer tracking using bluetooth"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Scope of the project,<br>add a speedometer on my <strong>MTB<\/strong> to store and track the trip using <strong>only Bluetooth transmission<\/strong>, send data to iPhone and store to cloud for later data-analysis.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Used components:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>digital display (<strong>controlled by the iOS app<\/strong>). Can show <em>current speed<\/em> (km\/h), <em>total km<\/em>, current <em>temperature<\/em>, current <em>humidity<\/em>.<\/li>\n\n\n\n<li><strong>GPS<\/strong> module<\/li>\n\n\n\n<li><strong>bluetooth<\/strong> module<\/li>\n\n\n\n<li><strong>DHT<\/strong> sensor for temperature and humidity<\/li>\n\n\n\n<li>Swift backend<\/li>\n\n\n\n<li>mongoDB as database<\/li>\n\n\n\n<li>Swift iOS App<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/07\/IMG_0704.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"3264\" height=\"2448\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/07\/IMG_0704.jpg?resize=3264%2C2448\" alt=\"\" class=\"wp-image-1103\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/07\/IMG_0704.jpg?w=3264&amp;ssl=1 3264w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/07\/IMG_0704.jpg?resize=300%2C225&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/07\/IMG_0704.jpg?resize=768%2C576&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/07\/IMG_0704.jpg?resize=1024%2C768&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/07\/IMG_0704.jpg?resize=200%2C150&amp;ssl=1 200w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/07\/IMG_0704.jpg?w=2000 2000w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/07\/IMG_0704.jpg?w=3000 3000w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><\/figure>\n<\/div>\n\n\n<!--more-->\n\n\n\n<h3 class=\"wp-block-heading\">Putting things together<\/h3>\n\n\n\n<h5 class=\"wp-block-heading\">Connecting a DHT sensor<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">Connecting a temperature and humidity sensor. This component is optional, I use this sensor only for data-analysis on backend side for calculating analytics on the speed and track based on the environment variables.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/Arduino-DHT11-Tutorial-4-Pin-DHT11-Wiring-Diagram.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"593\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/Arduino-DHT11-Tutorial-4-Pin-DHT11-Wiring-Diagram.png?resize=1280%2C593\" alt=\"\" class=\"wp-image-963\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/Arduino-DHT11-Tutorial-4-Pin-DHT11-Wiring-Diagram.png?w=1280&amp;ssl=1 1280w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/Arduino-DHT11-Tutorial-4-Pin-DHT11-Wiring-Diagram.png?resize=300%2C139&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/Arduino-DHT11-Tutorial-4-Pin-DHT11-Wiring-Diagram.png?resize=768%2C356&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/Arduino-DHT11-Tutorial-4-Pin-DHT11-Wiring-Diagram.png?resize=1024%2C474&amp;ssl=1 1024w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\">Connecting a GPS module<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">A GPS module is used to track your movements. I use this module from <em>Parallax<\/em><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/35240-28146-l.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"450\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/35240-28146-l.jpg?resize=600%2C450\" alt=\"\" class=\"wp-image-955\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/35240-28146-l.jpg?w=600&amp;ssl=1 600w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/35240-28146-l.jpg?resize=300%2C225&amp;ssl=1 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Connect it to Arduino:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/gps.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"277\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/gps.jpg?resize=600%2C277\" alt=\"\" class=\"wp-image-951\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/gps.jpg?w=600&amp;ssl=1 600w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/gps.jpg?resize=300%2C139&amp;ssl=1 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">remember to go outside to test it&#8230; in your house, this module can have some problems detecting the signal from satellites.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Attaching a bluetooth module<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;ve used a Bluetooth 3 module to make communication between sensors and the iOS app. This is not a BLE module, you must connect to the peripheral to send and receive data in Bluetooth.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><a href=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/ble.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-953\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/ble.jpg?resize=600%2C337\" alt=\"\" width=\"600\" height=\"337\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/ble.jpg?w=600&amp;ssl=1 600w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/ble.jpg?resize=300%2C169&amp;ssl=1 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a>Connect a seven segment display<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;ve used the <strong>HT16K33<\/strong> display (that use a few<em> pins<\/em> on Arduino) and this library:&nbsp;<a href=\"https:\/\/github.com\/jonpearse\/ht16k33-arduino\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/jonpearse\/ht16k33-arduino<\/a> to show the data on display.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"461\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/led_matrix_7segheader.jpg?resize=600%2C461\" alt=\"\" class=\"wp-image-950\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/led_matrix_7segheader.jpg?w=600&amp;ssl=1 600w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/led_matrix_7segheader.jpg?resize=300%2C231&amp;ssl=1 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/figure>\n<\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">The iOS App:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The iOS app is created using <strong>Swift<\/strong>. The goal of this app is to read data <strong>ONLY from the Bluetooth<\/strong> and draw the live-route on a map that you&#8217;ve done with your bike.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Of course, I could have an app that uses the GPS of the phone, but I want to use the Bluetooth packets.<\/em><\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Data transmission:<\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">The main screen permits you to change the settings of the 7-segment display (sending Bluetooth&nbsp;commands to Arduino).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Data is sent&nbsp;via Bluetooth using the CoreBluetooth library for iOS, in particular:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"swift\" class=\"language-swift\"><code>func writeValue(_ data: Data, for characteristic: CBCharacteristic, type: CBCharacteristicWriteType)<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Arduino module, receive data reading the <strong>BTSerial<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"swift\" class=\"language-swift\"><code>BTSerial.read();<\/code><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h6 class=\"wp-block-heading\">FEATURES<\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">In the iOS app you can control the 7-segments display and switch between:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>speed in km\/h<\/li>\n\n\n\n<li>total distance<\/li>\n\n\n\n<li>environment temperature<\/li>\n\n\n\n<li>environment humidity<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">And of course, you can <strong>start tracking<\/strong> your route. Data is cached in a <strong>Realm<\/strong> database.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When a route is completed, is <strong>automatically saved<\/strong> in the list, you can <em>view<\/em> the track, <em>delete<\/em> and <em>share<\/em>.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-3 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/IMG_0770.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"338\" height=\"600\" data-id=\"948\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/IMG_0770.png?resize=338%2C600&#038;ssl=1\" alt=\"\" class=\"wp-image-948\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/IMG_0770.png?w=338&amp;ssl=1 338w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/IMG_0770.png?resize=169%2C300&amp;ssl=1 169w\" sizes=\"auto, (max-width: 338px) 100vw, 338px\" \/><\/a><figcaption class=\"wp-element-caption\">Main screen, history of route, display options<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/IMG_0771.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"338\" height=\"600\" data-id=\"947\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/IMG_0771.png?resize=338%2C600&#038;ssl=1\" alt=\"\" class=\"wp-image-947\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/IMG_0771.png?w=338&amp;ssl=1 338w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/IMG_0771.png?resize=169%2C300&amp;ssl=1 169w\" sizes=\"auto, (max-width: 338px) 100vw, 338px\" \/><\/a><figcaption class=\"wp-element-caption\">Saved route with speed informations (time\/km).<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/IMG_0772.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"338\" height=\"600\" data-id=\"946\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/IMG_0772.png?resize=338%2C600&#038;ssl=1\" alt=\"\" class=\"wp-image-946\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/IMG_0772.png?w=338&amp;ssl=1 338w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/IMG_0772.png?resize=169%2C300&amp;ssl=1 169w\" sizes=\"auto, (max-width: 338px) 100vw, 338px\" \/><\/a><figcaption class=\"wp-element-caption\">Live recording using Bluetooth data<\/figcaption><\/figure>\n<\/figure>\n\n\n\n<h6 class=\"wp-block-heading\">Communication between devices<\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">Every run loop, the Arduino collect data, append to a data structure and when connection with Bluetooth is available, start transmit.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example for <strong>GPSData<\/strong> structure and <strong>DHTData<\/strong> structure:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"c\" class=\"language-c\"><div><pre>struct GPSData {\n  doublelat;\n  doublelon;\n  doublealt;\n  doublekmh;\n  intdate;\n  inttime;\n};<\/pre>\n<pre>struct DHTData {\n  doubletemp;\n  doublehum;\n};<\/pre><\/div><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In these data structures are stored the informations collected real-time by GPS and DHT.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When the app send the command to change the display mode (passing letters: A, B, C or D), Arduino use it to display something different.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"c\" class=\"language-c\"><div><pre>if ( btReceivedData == 'A' ) {\n  writeOnDisplay( <strong>gpsData->kmh<\/strong> );\n} else if ( btReceivedData == 'B' ) {\n  writeOnDisplay( <strong>gpsData->lat<\/strong> ); \/\/ example\n} else if ( btReceivedData == 'C' ) {\n  writeOnDisplay( <strong>dhtData->temp<\/strong> );\n} else if ( btReceivedData == 'D' ) {\n  writeOnDisplay( <strong>dhtData->hum<\/strong> );\n}<\/pre><\/div><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The data received from the app is a little bit different, because is a delimited string.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In order to minimize the size of the transmission, this string can be changed using bytes. More fast and secure. It&#8217;s not showed here but you can find it in the source code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The original data format is like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"c\" class=\"language-c\"><div>\n<pre>StringbtOutputStr = String(gps-&gt;lat);\nbtOutputStr += \"\u00a7\";\nbtOutputStr += String(gps-&gt;lon);\nbtOutputStr += \"\u00a7\";\nbtOutputStr += String(gps-&gt;alt);\nbtOutputStr += \"\u00a7\";\nbtOutputStr += String(gps-&gt;kmh);\nbtOutputStr += \"\u00a7\";\nbtOutputStr += String(gps-&gt;date);\nbtOutputStr += \"\u00a7\";\nbtOutputStr += String(gps-&gt;time);\nbtOutputStr += \"\u00a7\";\nbtOutputStr += String(dht-&gt;temp);\nbtOutputStr += \"\u00a7\";\nbtOutputStr += String(dht-&gt;hum);\nbtOutputStr += \"#\";\n\n<span style=\"background-color: #fcfcfc; font-family: Inconsolata, monospace; white-space: pre-wrap;\">BTSerial.write(btOutputStr);<\/span><\/pre>\n<\/div><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A string separated with &#8220;<strong>\u00a7<\/strong>&#8221; and terminated with &#8220;<strong>#<\/strong>&#8220;.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\"><strong>lat \u00a7 lon \u00a7 altitude \u00a7 km\/h \u00a7 date \u00a7 time \u00a7 temperature \u00a7 humidity#<\/strong><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The iOS app read this data and draw a point on the map for each line received from Arduino.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The result is a live tracking of your control unit (that is our speedometer!).<\/p>\n\n\n<div class=\"wp-block-image size-full wp-image-946\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"338\" height=\"600\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/IMG_0772.png?resize=338%2C600\" alt=\"\" class=\"wp-image-946\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/IMG_0772.png?w=338&amp;ssl=1 338w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/IMG_0772.png?resize=169%2C300&amp;ssl=1 169w\" sizes=\"auto, (max-width: 338px) 100vw, 338px\" \/><figcaption class=\"wp-element-caption\">Live recording using Bluetooth data<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><span style=\"color: #999999;\">( In a common <\/span>sports<span style=\"color: #999999;\"> shop you can buy for 10\u20ac more or less&#8230; ;D, but there is no fun <\/span>if<span style=\"color: #999999;\"> is already done by someone else! )<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When the\u00a0track recording is complete, the data are stored on a no-SQL database (<strong>MongoDB<\/strong> in this case) hosted on <strong>Heroku<\/strong> (<strong>https:\/\/ardubike.herokuapp.com<\/strong>\/).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The entire backend and the API (POST\/GET) are written completely in Swift using <a href=\"http:\/\/vapor.io\/\" target=\"_blank\" rel=\"noopener\">Vapor framework<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next step of the project, analyze the collected data for statistics\/performance\/speed and whatever, based on the environment climatic conditions for instance.&nbsp; But now holidays are finished, I&#8217;ll start a new job so have no more free time&#8230;<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">The app of course if only a draft. Is not on the App Store, was created just for fun and to play a little bit with the Bluetooth.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here the original circuit&#8230;:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/circuit-01.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"450\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/circuit-01.jpg?resize=600%2C450\" alt=\"\" class=\"wp-image-952\" srcset=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/circuit-01.jpg?w=600&amp;ssl=1 600w, https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/05\/circuit-01.jpg?resize=300%2C225&amp;ssl=1 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Source code (for iOS app and Backend) is not yet available. It will be available soon.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Cheers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Scope of the project,add a speedometer on my MTB to store and track the trip using only Bluetooth transmission, send data to iPhone and store to cloud for later data-analysis. Used components:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1],"tags":[257,617,618,616,688,138,615,609,689,692,271,340,690,46,600,691],"class_list":["post-942","post","type-post","status-publish","format-standard","hentry","category-generic","tag-arduino","tag-bluetooth","tag-dht","tag-gps","tag-heroku","tag-iphone","tag-km","tag-mongodb","tag-realm","tag-record","tag-sensors","tag-speed","tag-struct","tag-swift","tag-temperature","tag-track"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Arduino\/iOS - Bike speedometer tracking using bluetooth - while (true) {\u00a0}<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Arduino\/iOS - Bike speedometer tracking using bluetooth - while (true) {\u00a0}\" \/>\n<meta property=\"og:description\" content=\"Scope of the project,add a speedometer on my MTB to store and track the trip using only Bluetooth transmission, send data to iPhone and store to cloud for later data-analysis. Used components:\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/\" \/>\n<meta property=\"og:site_name\" content=\"while (true) {\u00a0}\" \/>\n<meta property=\"article:published_time\" content=\"2017-06-11T19:43:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-10T15:06:48+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/07\/IMG_0704.jpg\" \/>\n<meta name=\"author\" content=\"Alberto Pasca\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@lupasca\" \/>\n<meta name=\"twitter:site\" content=\"@lupasca\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alberto Pasca\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-ios-bike-speedometer-tracking-using-bluetooth\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-ios-bike-speedometer-tracking-using-bluetooth\\\/\"},\"author\":{\"name\":\"Alberto Pasca\",\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"headline\":\"Arduino\\\/iOS &#8211; Bike speedometer tracking using bluetooth\",\"datePublished\":\"2017-06-11T19:43:39+00:00\",\"dateModified\":\"2023-10-10T15:06:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-ios-bike-speedometer-tracking-using-bluetooth\\\/\"},\"wordCount\":744,\"publisher\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"image\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-ios-bike-speedometer-tracking-using-bluetooth\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/IMG_0704.jpg\",\"keywords\":[\"arduino\",\"bluetooth\",\"dht\",\"gps\",\"heroku\",\"iPhone\",\"km\",\"mongodb\",\"realm\",\"record\",\"sensors\",\"speed\",\"struct\",\"swift\",\"Temperature\",\"track\"],\"articleSection\":[\"generic\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-ios-bike-speedometer-tracking-using-bluetooth\\\/\",\"url\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-ios-bike-speedometer-tracking-using-bluetooth\\\/\",\"name\":\"Arduino\\\/iOS - Bike speedometer tracking using bluetooth - while (true) {\u00a0}\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-ios-bike-speedometer-tracking-using-bluetooth\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-ios-bike-speedometer-tracking-using-bluetooth\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/IMG_0704.jpg\",\"datePublished\":\"2017-06-11T19:43:39+00:00\",\"dateModified\":\"2023-10-10T15:06:48+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-ios-bike-speedometer-tracking-using-bluetooth\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-ios-bike-speedometer-tracking-using-bluetooth\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-ios-bike-speedometer-tracking-using-bluetooth\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/IMG_0704.jpg?fit=3264%2C2448&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/IMG_0704.jpg?fit=3264%2C2448&ssl=1\",\"width\":3264,\"height\":2448},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-ios-bike-speedometer-tracking-using-bluetooth\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Arduino\\\/iOS &#8211; Bike speedometer tracking using bluetooth\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#website\",\"url\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/\",\"name\":\"while (true) {\u00a0}\",\"description\":\"notes from a developer, tutorials, how-to, ideas\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\",\"name\":\"Alberto Pasca\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"caption\":\"Alberto Pasca\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\"},\"description\":\"Software engineer @ Pirelli &amp; C. S.p.A. with a strong passion for mobile \uf8ff development, security, and connected things.\",\"sameAs\":[\"https:\\\/\\\/www.albertopasca.it\",\"albertopasca\",\"https:\\\/\\\/x.com\\\/lupasca\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Arduino\/iOS - Bike speedometer tracking using bluetooth - while (true) {\u00a0}","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/","og_locale":"en_US","og_type":"article","og_title":"Arduino\/iOS - Bike speedometer tracking using bluetooth - while (true) {\u00a0}","og_description":"Scope of the project,add a speedometer on my MTB to store and track the trip using only Bluetooth transmission, send data to iPhone and store to cloud for later data-analysis. Used components:","og_url":"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/","og_site_name":"while (true) {\u00a0}","article_published_time":"2017-06-11T19:43:39+00:00","article_modified_time":"2023-10-10T15:06:48+00:00","og_image":[{"url":"http:\/\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/07\/IMG_0704.jpg","type":"","width":"","height":""}],"author":"Alberto Pasca","twitter_card":"summary_large_image","twitter_creator":"@lupasca","twitter_site":"@lupasca","twitter_misc":{"Written by":"Alberto Pasca","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/#article","isPartOf":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/"},"author":{"name":"Alberto Pasca","@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"headline":"Arduino\/iOS &#8211; Bike speedometer tracking using bluetooth","datePublished":"2017-06-11T19:43:39+00:00","dateModified":"2023-10-10T15:06:48+00:00","mainEntityOfPage":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/"},"wordCount":744,"publisher":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"image":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/#primaryimage"},"thumbnailUrl":"http:\/\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/07\/IMG_0704.jpg","keywords":["arduino","bluetooth","dht","gps","heroku","iPhone","km","mongodb","realm","record","sensors","speed","struct","swift","Temperature","track"],"articleSection":["generic"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/","url":"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/","name":"Arduino\/iOS - Bike speedometer tracking using bluetooth - while (true) {\u00a0}","isPartOf":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/#primaryimage"},"image":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/#primaryimage"},"thumbnailUrl":"http:\/\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/07\/IMG_0704.jpg","datePublished":"2017-06-11T19:43:39+00:00","dateModified":"2023-10-10T15:06:48+00:00","breadcrumb":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/#primaryimage","url":"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/07\/IMG_0704.jpg?fit=3264%2C2448&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/07\/IMG_0704.jpg?fit=3264%2C2448&ssl=1","width":3264,"height":2448},{"@type":"BreadcrumbList","@id":"https:\/\/www.albertopasca.it\/whiletrue\/arduino-ios-bike-speedometer-tracking-using-bluetooth\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.albertopasca.it\/whiletrue\/"},{"@type":"ListItem","position":2,"name":"Arduino\/iOS &#8211; Bike speedometer tracking using bluetooth"}]},{"@type":"WebSite","@id":"https:\/\/www.albertopasca.it\/whiletrue\/#website","url":"https:\/\/www.albertopasca.it\/whiletrue\/","name":"while (true) {\u00a0}","description":"notes from a developer, tutorials, how-to, ideas","publisher":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.albertopasca.it\/whiletrue\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac","name":"Alberto Pasca","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","caption":"Alberto Pasca"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g"},"description":"Software engineer @ Pirelli &amp; C. S.p.A. with a strong passion for mobile \uf8ff development, security, and connected things.","sameAs":["https:\/\/www.albertopasca.it","albertopasca","https:\/\/x.com\/lupasca"]}]}},"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/942","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/comments?post=942"}],"version-history":[{"count":22,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/942\/revisions"}],"predecessor-version":[{"id":3425,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/942\/revisions\/3425"}],"wp:attachment":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/media?parent=942"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/categories?post=942"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/tags?post=942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}