{"id":2683,"date":"2020-04-20T15:06:43","date_gmt":"2020-04-20T15:06:43","guid":{"rendered":"http:\/\/www.daveakerman.com\/?p=2683"},"modified":"2020-09-28T08:50:11","modified_gmt":"2020-09-28T08:50:11","slug":"hab-watch","status":"publish","type":"post","link":"https:\/\/www.daveakerman.com\/?p=2683","title":{"rendered":"HAB Watch"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"625\" height=\"361\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/09\/image.png\" alt=\"\" class=\"wp-image-2732\" srcset=\"https:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/09\/image.png 625w, https:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/09\/image-300x173.png 300w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/figure>\n\n\n\n<p>One of the nice things about LoRa vs traditional radio modulation techniques used by high altitude balloons, is that LoRa chips include decoders.\u00a0 So whereas RTTY and APRS generally require a PC to decode the signal, LoRa only needs a basic microcontroller.\u00a0 So LoRa receivers are cheap and small.<\/p>\n\n\n\n<p><br>I&#8217;ve made several different LoRa receivers, from Raspberry Pi gateways down to a handheld Arduino-based receiver.&nbsp; The latter is battery powered, quick to start, lightweight and portable.&nbsp; It shows distance and direction to the payload so it&#8217;s ideal for the &#8220;last mile&#8221; chase of a balloon on foot, which is typically across a field, but it&#8217;s long been a dream of mine to make something even smaller that can be worn like a watch.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">TTGO T-Watch<\/h2>\n\n\n\n<p><br>One option for this is a Smartwatch linked to a LoRa receiver, but suitable watches are expensive.&nbsp; So I was very interested to discover the LilyGo T-Watch which is about \u00a350 delivered <strong>including a GPS\/LoRa board<\/strong>.&nbsp; So that makes the watch a completely self-contained LoRa chase watch.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/imgaz2.staticbg.com\/thumb\/large\/oaupload\/ser1\/banggood\/images\/D7\/36\/c8436d8c-da42-4bf5-abdd-483e12375476.jpeg\" alt=\"lilygo\u00ae ttgo t-watch upgraded version sim800l gps lora ...\" width=\"357\" height=\"357\"\/><figcaption>Lilygo TTGO T-Watch<\/figcaption><\/figure><\/div>\n\n\n\n<p><br><br>It packs a lot of devices into a rather thick but still practical watch &#8211; not something you&#8217;d want to wear all the time but absolutely fine for an activity like chasing a balloon.&nbsp; The watch contains:<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow\">\n<ul><li>ESP32 processor running at 240MHz<\/li><li>16 MB flash<\/li><li>8 MB PSRAM<\/li><li>WiFi<\/li><li>Bluetooth \/ BLE<\/li><li>180mAh battery<\/li><li>AXP202x battery management<\/li><li>240&#215;240 IPS backlit LCD touch-screen<\/li><li>micro-SD<\/li><li>I2C port<\/li><li>RTC<\/li><li>3-axis accelerometer<\/li><li>power and custom buttons<\/li><li>(optional) LoRa + GPS board (S78G for 434Mhz).<\/li><\/ul>\n<\/div><\/div>\n\n\n\n<p>Of those, the CPU, battery and power management, touchscreen and LoRa\/GPS are what we need.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">S78G LoRa\/GPS Board<\/h2>\n\n\n\n<p>Rather than having those devices connect directly to the ESP32 on the main board, they connect to a small STM32 processor.&nbsp; The GPS connects to the STM32 by serial, the SX1276 LoRa chip connects via SPI, and the STM32 connects back to the ESP32 over another serial connection.<\/p>\n\n\n\n<p>The STM32 comes programmed with stock LoRaWAN firmware.&nbsp; This firmware does not provide access to all LoRa modes, does not report GPS altitude, and is generally unsuitable for our purposes.&nbsp; There does exist alternate firmware as part of the SoftRF system, which helps on the GPS side by sending raw NMEA packets from the GPS, but does not solve the LoRa limitations.&nbsp; So I had to write my own firmware.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Programming<\/h2>\n\n\n\n<p>Both the main (ESP32) and backplane (STM32) processors can be programmed using the Arduino IDE, and LilyGo supply a library with examples for the ESP32.<\/p>\n\n\n\n<p>To program the ESP32, install an ESP32 board package into the IDE, install the Lilygo library, and connect the watch to host computer via the supplied USB C cable.&nbsp; In the IDE, choose the &#8220;TTGO T-Watch&#8221; board option, select the correct serial port, and then load one of the sample programs.&nbsp; Note that to test the GPS you <strong>must<\/strong>&nbsp;use the S7XG\/GPS example and not the regular GPS example.<\/p>\n\n\n\n<p>To program the STM32, install an STM32 board package and select the Nucleo 64 \/ L073RZ board.&nbsp; There are some other board settings which have to be set correctly, since the S78G uses different serial port connections to those on the L073RZ board; my S7XG firmware on github shows the options.&nbsp; Also, you need to buy and connect an ST-Link USB programmer (inexpensive) and make up a custom cable to connect from the programmer to the 5 programming pins on the S78G.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">S78G Firmware<\/h2>\n\n\n\n<p>The aim here is to provide the the following capabilities for the host ESP32:<\/p>\n\n\n\n<ol><li>Receive GPS latitude, longitude, altitude and direction<\/li><li>Receive packets received by the LoRa module<\/li><li>Set the LoRa module frequency and other settings<\/li><\/ol>\n\n\n\n<p>Item (1) is something that any balloon tracker does, so I wasn&#8217;t short of code to borrow.&nbsp; However, the S78G uses a Sony GPS and not the usual UBlox, so I had to use code that handles standard NMEA messages instead of the UBlox custom protocol.<\/p>\n\n\n\n<p>Items (2) and (3) I&#8217;ve also already coded, for example in my LoRa OTG device for phones and tablets.&nbsp; This code provides a serial protocol which I can use here to allow the ESP32 to set frequency etc. and to receive LoRa packets.<\/p>\n\n\n\n<p>So it didn&#8217;t take long to merge my existing source code together and have something that should work on the S78G, assuming I knew the pin allocations for STM32 to GPS and LoRa.&nbsp; Documentation on this proved elusive, but fortunately the SoftRF firmware I mentioned is open source on github, so I searched that code for the information I needed.<\/p>\n\n\n\n<p>If you want to program your own T-Watch S78G with my firmware, <a href=\"https:\/\/github.com\/daveake\/S7xG\">download it from github<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">TTGO Firmware<\/h2>\n\n\n\n<p>This firmware has these functions:<\/p>\n\n\n\n<ul><li>Display various screens, chosen by the user:<ul><li>Logo screen with version etc.<\/li><li>GPS screen with current GPS data<\/li><li>LoRa screen with current balloon telemetry<\/li><li>Direction screen showing distance and direction to balloon<\/li><li>Settings screen allowing change of LoRa frequency and mode<\/li><\/ul><\/li><li>Display status bar (GPS status, LoRa status, Battery status) at all times<\/li><li>Communicate with S78G board:<ul><li>Receive GPS position<\/li><li>Receive LoRa telemetry<\/li><li>Send LoRa frequency and mode on startup and when changed<\/li><\/ul><\/li><li>Monitor user button and touchscreen for swipes (screen change) and presses (settings buttons)<\/li><li>Store settings in EEPROM after changing them, and load from EEPROM on startup<\/li><\/ul>\n\n\n\n<p>If you want to program your own T-Watch S78G with my firmware, <a href=\"https:\/\/github.com\/daveake\/THABWatch\">download it from github<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Operation<\/h2>\n\n\n\n<p>The watch starts up with this logo screen:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"528\" height=\"526\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image.png\" alt=\"\" class=\"wp-image-2685\" srcset=\"https:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image.png 528w, https:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-300x300.png 300w, https:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-150x150.png 150w\" sizes=\"(max-width: 528px) 100vw, 528px\" \/><\/figure>\n\n\n\n<p><br>Note the status bar with:<\/p>\n\n\n\n<ul><li>GPS status bar<\/li><li>Battery level<\/li><li>LoRa signal strength bar<\/li><li>LoRa status bar<\/li><\/ul>\n\n\n\n<p>To change to the next screen, swipe up or left, or press the user button briefly (less than 0.5 seconds); to change to previous screen swipe down or left, or press the user button for at least 0.5 seconds.&nbsp; The screen sequence is:<\/p>\n\n\n\n<p class=\"has-text-align-center\">Logo &#8211;&gt; GPS &#8211;&gt; LoRa &#8211;&gt; Direction &#8211;&gt; Settings<\/p>\n\n\n\n<p>The screens are in a loop so going &#8220;back&#8221; from Logo takes you to the Settings screen.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">GPS Screen<br><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"483\" height=\"481\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-2.png\" alt=\"\" class=\"wp-image-2687\" srcset=\"https:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-2.png 483w, https:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-2-300x300.png 300w, https:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-2-150x150.png 150w\" sizes=\"(max-width: 483px) 100vw, 483px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">LoRa Screen<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"448\" height=\"439\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-3.png\" alt=\"\" class=\"wp-image-2688\" srcset=\"https:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-3.png 448w, https:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-3-300x294.png 300w\" sizes=\"(max-width: 448px) 100vw, 448px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Direction Screen<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"459\" height=\"463\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-4.png\" alt=\"\" class=\"wp-image-2689\" srcset=\"https:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-4.png 459w, https:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-4-297x300.png 297w, https:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-4-150x150.png 150w\" sizes=\"(max-width: 459px) 100vw, 459px\" \/><\/figure>\n\n\n\n<p>Note that the direction relies on knowing the user&#8217;s direction as reported by the GPS, so if you have not moved recently then take a few steps forward so that the GPS can measure your direction.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Settings Screen<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-5.png\" alt=\"\" class=\"wp-image-2690\" width=\"453\" height=\"442\" srcset=\"https:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-5.png 371w, https:\/\/www.daveakerman.com\/wp-content\/uploads\/2020\/04\/image-5-300x293.png 300w\" sizes=\"(max-width: 453px) 100vw, 453px\" \/><\/figure>\n\n\n\n<p>Just touch the buttons to adjust the LoRa mode up\/down.<\/p>\n\n\n\n<p>Touch the frequency up\/down buttons to adjust the frequency in 1kHz (&lt;\/&gt;) or 25kHz (&lt;&lt;\/&gt;&gt;) steps.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Video<\/h2>\n\n\n\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"HAB Watch - Completed Software\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/LnAIbJ50vTk?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the nice things about LoRa vs traditional radio modulation techniques used by high altitude balloons, is that LoRa chips include decoders.\u00a0 So whereas RTTY and APRS generally require a PC to decode the signal, LoRa only needs a basic microcontroller.\u00a0 So LoRa receivers are cheap and small. I&#8217;ve [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts\/2683"}],"collection":[{"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2683"}],"version-history":[{"count":9,"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts\/2683\/revisions"}],"predecessor-version":[{"id":2733,"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=\/wp\/v2\/posts\/2683\/revisions\/2733"}],"wp:attachment":[{"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.daveakerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}