{"path": "/posts/fun-with-rust-mqtt-lora-and-raspiberry-pi/", "title": "Fun with Rust, MQTT, LoRa and Raspiberry Pi · Bruno Dias", "html": "<!doctype html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"utf-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n  <meta name=\"description\" content=\"Fun with Rust, MQTT, LoRa and Raspiberry Pi\">\n  <title>Fun with Rust, MQTT, LoRa and Raspiberry Pi · Bruno Dias</title>\n  <link rel=\"canonical\" href=\"https://diasbruno.github.io/posts/fun-with-rust-mqtt-lora-and-raspiberry-pi/\" data-post-metadata>\n  <meta name=\"author\" content=\"Bruno Dias\" data-post-metadata>\n  <meta property=\"og:type\" content=\"article\" data-post-metadata>\n  <meta property=\"og:title\" content=\"Fun with Rust, MQTT, LoRa and Raspiberry Pi\" data-post-metadata>\n  <meta property=\"og:url\" content=\"https://diasbruno.github.io/posts/fun-with-rust-mqtt-lora-and-raspiberry-pi/\" data-post-metadata>\n  <meta property=\"article:published_time\" content=\"2022-06-18T19:46:35Z\" data-post-metadata>\n  <link rel=\"icon\" href=\"/assets/site/signature.svg\" type=\"image/svg+xml\">\n  <link rel=\"alternate\" type=\"application/atom+xml\" title=\"diasbruno\" href=\"/atom.xml\">\n  <link rel=\"alternate\" type=\"application/json\" href=\"/posts/fun-with-rust-mqtt-lora-and-raspiberry-pi/content.json\">\n  <link rel=\"stylesheet\" href=\"/assets/site/tokens.css\">\n  <link rel=\"stylesheet\" href=\"/assets/site/site.css\">\n  <link rel=\"stylesheet\" href=\"/assets/site/footer.css\">\n\n</head>\n<body class=\"light\">\n<div id=\"site-page\">\n<a class=\"skip-link\" href=\"#content\">Skip to content</a>\n<header class=\"site-header\">\n  <a class=\"brand\" href=\"/\" data-site-navigation aria-label=\"Bruno Dias, home\">\n    <img src=\"/assets/site/signature.svg\" width=\"24\" height=\"34\" alt=\"\">\n  </a>\n  <nav aria-label=\"Main navigation\">\n    <ul>\n<li><a class=\"nav-vrn\" href=\"/vrn/\" data-site-navigation><span class=\"nav-label\">vrn</span> <span class=\"nav-badge\">research</span></a></li>\n<li><a class=\"nav-posts\" href=\"/posts/\" data-site-navigation aria-current=\"location\">Posts</a></li>\n<li><a class=\"nav-projects\" href=\"/projects/\" data-site-navigation>Projects</a></li>\n<li><a class=\"nav-about\" href=\"/about/\" data-site-navigation>About</a></li>\n</ul>\n  </nav>\n</header>\n\n<main class=\"section\" id=\"content\" tabindex=\"-1\">\n  <article class=\"post-detail\">\n    <header class=\"section-header\">\n      <p class=\"post-category\">Post</p>\n      <h1>Fun with Rust, MQTT, LoRa and Raspiberry Pi</h1>\n\n      <p><time datetime=\"2022-06-18T19:46:35Z\">2022-06-18</time></p>\n    </header>\n    <div class=\"post-columns\">\n      <section class=\"post-body\" aria-label=\"Article\">\n\n<p>Recently, I was called to give a hand on a small project for fun.\nIt was about tracking groups of people using GPS.</p>\n<p>The project was nice and all, problem was trying to get the correct,\nand simplier, tools for the project.</p>\n<p>We found a company that helped us with the hardware stuff\nand they provide us with some sensors (Dragino LGT-92)\nand a gateway (Dragino LIG-16). They talk to each other using\nradio.</p>\n<p>The LIG-16 is a gateway that provides a lot of stuff\nand we used its MQTT client to communicate with our broker\n(since there was no connection at the location where it was used).</p>\n<p>The first idea we tried was to have everything inside a iPhone,\nbut unfortunately we did not found an easy MQTT broker to use internally\nwith the app.</p>\n<p>Than, we accepted we need to add an extra device to handle the application.\nSo, we added a Raspiberry PI 4 where we could run the MQTT broker and\nprovide a REST api to be consumed on a offline map on the phone.</p>\n<p>This is the application we build:</p>\n<p><a href=\"/images/gps-diagram.png\"> <img src=\"/images/gps-diagram.png\" alt=\"application diagram\" title=\"application diagram\" /> </a></p>\n<p>I wrote a rust application that with <a href=\"https://github.com/bytebeamio/rumqtt\">rumqtt</a> that provided\nthe borker and client for the MQTT and <a href=\"https://github.com/seanmonstar/warp\">warp</a> for the web server,\nand <a href=\"https://github.com/launchbadge/sqlx\">sqlx</a> for the database (no need to orm or anything like,\nall queries were simple).</p>\n<p>&lt;&lt; Add images &gt;&gt;</p>\n<p>To help with some message decoding I wrote a small library\n<a href=\"https://github.com/diasbruno/rust_dragino_lgt92_tools\">rust_dragino_lgt92_tools</a></p>\n\n      </section>\n      <aside class=\"post-links\" aria-labelledby=\"post-links-heading\">\n        <h2 id=\"post-links-heading\">Links</h2>\n        <ul>\n<li><a href=\"/posts/\" data-site-navigation>All posts</a></li>\n        </ul>\n      </aside>\n    </div>\n  </article>\n</main>\n\n<footer class=\"site-footer\">\n  <div class=\"site-footer-inner\">\n    <a class=\"site-footer-home\" href=\"/\" data-site-navigation>Bruno Dias</a>\n    <ul aria-label=\"Footer links\">\n      <li><a href=\"https://github.com/diasbruno\">GitHub</a></li>\n      <li><a href=\"/atom.xml\">Atom feed</a></li>\n    </ul>\n  </div>\n</footer>\n\n</div>\n<script type=\"module\" src=\"/assets/site/navigation.js\"></script>\n</body>\n</html>\n"}
