{"id":168,"date":"2021-09-04T18:52:27","date_gmt":"2021-09-04T18:52:27","guid":{"rendered":"https:\/\/farnsworth.engineering\/?p=168"},"modified":"2022-07-10T22:12:10","modified_gmt":"2022-07-10T22:12:10","slug":"esp-remote-start-scheduler","status":"publish","type":"post","link":"https:\/\/farnsworth.engineering\/index.php\/2021\/09\/04\/esp-remote-start-scheduler\/","title":{"rendered":"ESP Remote Start Scheduler"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"292\" src=\"https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image-1024x292.png\" alt=\"\" class=\"wp-image-173\" srcset=\"https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image-1024x292.png 1024w, https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image-300x86.png 300w, https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image-768x219.png 768w, https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image.png 1410w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>My wife got a new car! Excellent, it has all the bells and whistles, on-star, android auto, those dumb key fobs that let you unlock your car\/drive without removing them from your pocket, and the option to pay $15\/month to remote start the thing from your phone (there&#8217;s a few other features). <\/p>\n\n\n\n<p>In an effort to get back at &#8220;The Man&#8221; and upgrade my 2013 Silverado, I decided to make my own remote-start app. <\/p>\n\n\n\n<p>The premise is simple, I want to be able to lock, unlock, and start my vehicles remotely. I also want to be able to schedule a remote-start. Where we live, the vehicles are ALWAYS parked outside. Winter&#8217;s aren&#8217;t as harsh as when I used to live up north, but it&#8217;s nice to a) have a warm vehicle to scrape the snow off, and b) have a warmed-up vehicle to reduce wear-and-tear when the fluids are thicker than molasses. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"761\" height=\"845\" src=\"https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/03\/image-1.png\" alt=\"\" class=\"wp-image-170\" srcset=\"https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/03\/image-1.png 761w, https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/03\/image-1-270x300.png 270w\" sizes=\"auto, (max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><figcaption>Not too shabby.<\/figcaption><\/figure>\n\n\n\n<p>I wrote the CSS and HTML from scratch (with the help of a few websites noted later in this article). This project was a good exercise in learning AJAX. From an EE point of view, it&#8217;s surprisingly easy. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/03\/image-2-531x1024.png\" alt=\"\" class=\"wp-image-171\" width=\"675\" height=\"1302\" srcset=\"https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/03\/image-2-531x1024.png 531w, https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/03\/image-2-156x300.png 156w, https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/03\/image-2.png 581w\" sizes=\"auto, (max-width: 675px) 100vw, 675px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Required Components<\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li>One or More remote-start capable vehicles.<\/li><li>Sacrificial key-fobs<ol><li>What the hell is up with the cost of new key fobs? $150 for an extra for my wife&#8217;s car!<\/li><li>If you buy a new set, you&#8217;ll probably have to take them to a dealer to get them programmed.<\/li><\/ol><\/li><li>An ESP8266. I am using a Wemos D1 Pro knockoff from AliExpress<ol><li>In hindsight, just buy a legit Wemos D1 from Amazon or whatever.<\/li><\/ol><\/li><li>Soldering Iron.<\/li><li>Solder.<\/li><li>A 3D printer. <\/li><li>Some bits of wire. <\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Warnings and Limitations<\/h2>\n\n\n\n<p>Common sense ain&#8217;t all that common, so I feel like I have to warn you (the reader\/maker\/builder\/user) not to try this yourself. Why? Let&#8217;s say you park your vehicle inside a garage. Let&#8217;s also say you have an auto-start scheduled for 5AM.  You&#8217;re sleeping in your bedroom above the garage, your car starts, you don&#8217;t notice, and suddenly you&#8217;re in the obituaries as &#8220;That dumbass who accidentally killed himeslf\/others.&#8221; &#8220;But&#8230;&#8221;, you may tell yourself, &#8220;I&#8217;m not dumb enough to do that!&#8221;. Well, consider that this code implements 7 different libraries and uses features I have not thoroughly tested or verified as good. Also, consider that my code, as it&#8217;s written, allows over-the-air updates from anyone on your local network. Even if you don&#8217;t die as a result of someone hacking this, you&#8217;ve just left your vehicle more venerable to theft. <\/p>\n\n\n\n<p>This is one of those dumb projects that I just HAD to do. There is precedent here: Who the hell pays $15\/month to remote start their car? Not me. <\/p>\n\n\n\n<p>Okay now the limitations:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>The Wemos D1 Mini hardware can support up to 3 key fobs (lock, unlock, and start connected). My code only has provisions for 2 users. <\/li><li>The webpage is COMPLETELY unsecured. Literally anyone on your network with an IP address (hell, mDNS hostname: http:\/\/cars.local) can connect and start\/unlock your vehicles. <\/li><li>The code is a complete bodge-job but I have to say I&#8217;m proud that I wrote the CSS by myself. <\/li><li>This doesn&#8217;t give your car superpowers, it&#8217;s just hooking an arduino up to your key-fob. As a result you cannot: <ol><li>Start your vehicle from your phone when you&#8217;re at work (away from your wifi network)<\/li><li>Schedule a remote start time while your vehicle is away from the base station<\/li><\/ol><\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Hardware<\/h2>\n\n\n\n<p>Key fobs always interested me because they&#8217;re these tiny coin-cell powered devices with an absolutely minimal number of components, they have a range of 100&#8217;s of feet, and they last for months\/years! It&#8217;s the type of EE I can get behind. Now it&#8217;s our turn to reverse engineer them. What gets me are these devices are ALWAYS powered on. Sipping micro\/nano amps from the coin cell when waiting for a button press. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"376\" src=\"https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image-1-1024x376.png\" alt=\"\" class=\"wp-image-174\" srcset=\"https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image-1-1024x376.png 1024w, https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image-1-300x110.png 300w, https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image-1-768x282.png 768w, https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image-1.png 1446w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>The microcontroller in the remotes is pretty obscure. I was unable to find a datasheet on the elusive chip, but I was able to make some educated guesses with a multimeter<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>The microcontroller is always powered on<\/li><li>All 4 inputs are pull-up <\/li><li>It&#8217;ll probably handle 3.3V<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"404\" src=\"https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image-2-1024x404.png\" alt=\"\" class=\"wp-image-175\" srcset=\"https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image-2-1024x404.png 1024w, https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image-2-300x118.png 300w, https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image-2-768x303.png 768w, https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image-2-1536x605.png 1536w, https:\/\/farnsworth.engineering\/wp-content\/uploads\/2021\/05\/image-2.png 1573w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption>It&#8217;s really this simple<\/figcaption><\/figure>\n\n\n\n<p>The GPIO pins are initialized high (3.3V) as the microcontroller is looking for a &#8220;low&#8221; (0V) signal for a button press. When you want to press a button, toggle the GPIO pin low. Easy! We do this hookup twice, once for each remote.  <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/AoleOYu-ajMofGDglIr4PEPS_DNoCrJUtpkDpJldFGhCIXbweWNhYqPsrNK4m13st3bueL8fzklfm0Enqdh7ATGNqW6kU--WsJ1wU64clYK1afeGicuTa4-Vvz0fnt56tPd27wy4WBNfvKjJG_GDO3AaGZCFwlva6cMa9nbmTwXv5oa9hBRGOEXHmyCbuaeYlceOXGu8iADpSCNn_mD5cixBiKLnFPHhHUVU9jyLDUFsQykok3ewUgzduit-7mwYhDUodDML0TFzijRIzn32ZsgkzJ4aUjC5saYhv83ixCkodyRrFL2Yt_9qj4SRK4KhY5PbX7r15EN4Sz_1fwCejL1q7bIATHAf-fjKiV2j-bS0aizNUG6wsaNY436Pys2-HKXp9N5PkFS0YfDkA9WS-ukW_eu5Xdrx2kTOrZiQcGmPgU0hYVVjB12ByytjmenZza0o-miqVwlfOMyMrWW9yhmxC0BbI3cPGSC_SIiVka_0PsNKzaAyvNgnz1ySAEe4bfYsT90GCKLoA-e4uVU-Az2SvkL7R3VOISPKDoqd4YYZKl7fmd6Y1ghdycAGQ8siwsW3SJM7WBA0yiCDF2dJNwKU6PrJGSV8Q4Dm1xU3nw_3C-1r7FE0i7a7C7MdxwQjsj2nH5kWhm5vP15uG6hrgiwdWiIO7IiInVv3u7PUUH20LkPMLd6oQOUuhhh_UWuKFrR3wP8KSsX7bEyn-4vCLt6k=w973-h1297-no?authuser=0\" alt=\"\"\/><figcaption>The wiring diagrams always look more professional than the actual wiring. <\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Code<\/h2>\n\n\n\n<p>I&#8217;ll keep this section short as I have the code on Github. <\/p>\n\n\n\n<p>The code needs to do 5 things:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Host a website<\/li><li>Toggle some GPIO<\/li><li>Keep time<\/li><li>Hold a schedule<\/li><li>OTA Firmware Updates<\/li><\/ol>\n\n\n\n<p>Hosting a website, toggling GPIO, keeping time, and OTA firmware updates are very common things people want a microcontroller to do. The base code is available as libraries which I import. <\/p>\n\n\n\n<p>Scheduling turned out the be the most difficult part of this project. There&#8217;s a library called alarms which is complete trash for the ESP8266 as you need to use alarm_delay instead of regular delays. This causes the ESP to crash frequently. <\/p>\n\n\n\n<p>I still haven&#8217;t quite figured out the bug yet. But I need to publish this blog post before winter hits. I&#8217;ll publish an update to this post when I figure out why time keeps slipping away for starts &gt;24 hours in the future. <\/p>\n\n\n\n<p>The code is available on <a href=\"https:\/\/github.com\/Radacon\/ESP_Remote_Start\">my github here.<\/a> <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Webcode<\/h2>\n\n\n\n<p>Most of the web design I do is derived from <a href=\"https:\/\/html5up.net\/\">html5up.net<\/a>. It&#8217;s a great resource for getting simple webpages going for people you care about. Well, I wanted a proper course in web design as I&#8217;ve been using templates for years and have never formally taken a web design course. I started with the basics of CSS and built little widgets as I went along. I use brackets.io for code editing and live previews of changes I make. It&#8217;s very handy and keeps me from uploading useless code to the ESP. <\/p>\n\n\n\n<p>One of the more handy things I was able to learn was the use of AJAX. Which let&#8217;s parts of my webpage be refreshed on command. Kind of like a data stream. There&#8217;s a <a href=\"https:\/\/circuits4you.com\/2018\/02\/04\/esp8266-ajax-update-part-of-web-page-without-refreshing\/\">great tutorial here<\/a> for implementing this. <\/p>\n\n\n\n<p>Once a website was created, I was able to flash all of the page data and resources onto the ESP8266 via <a href=\"https:\/\/randomnerdtutorials.com\/install-esp8266-filesystem-uploader-arduino-ide\/\">this handy tutorial<\/a>. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mechanical Design<\/h2>\n\n\n\n<p>I really didn&#8217;t go all-out on this design. I really needed a box that could be mounted to a wall and hide my hideous wiring job. It serves that purpose. Again, the files are available on my github if you feel like following in my steps. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>This was a really fun project involving my new favorite microcontroller. I was able to make something useful and web-based. There are still some bugs in the code I am trying to stomp out, but things are working well enough for me to get some use out of this system on my smart phone. Again, I wouldn&#8217;t recommend this if there&#8217;s ANY chance you&#8217;ll be parking in your garage or if you care about your vehicle getting broken into. Code like this should not be responsible for safety or security and there&#8217;s a good chance you&#8217;ll forget about this device a few months after building it. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>My wife got a new car! Excellent, it has all the bells and whistles, on-star, android auto, those dumb key fobs that let you unlock your car\/drive without removing them from your pocket, and the option to pay $15\/month to remote start the thing from your phone (there&#8217;s a few other features). In an effort &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/farnsworth.engineering\/index.php\/2021\/09\/04\/esp-remote-start-scheduler\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;ESP Remote Start Scheduler&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-168","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/farnsworth.engineering\/index.php\/wp-json\/wp\/v2\/posts\/168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/farnsworth.engineering\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/farnsworth.engineering\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/farnsworth.engineering\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/farnsworth.engineering\/index.php\/wp-json\/wp\/v2\/comments?post=168"}],"version-history":[{"count":5,"href":"https:\/\/farnsworth.engineering\/index.php\/wp-json\/wp\/v2\/posts\/168\/revisions"}],"predecessor-version":[{"id":180,"href":"https:\/\/farnsworth.engineering\/index.php\/wp-json\/wp\/v2\/posts\/168\/revisions\/180"}],"wp:attachment":[{"href":"https:\/\/farnsworth.engineering\/index.php\/wp-json\/wp\/v2\/media?parent=168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/farnsworth.engineering\/index.php\/wp-json\/wp\/v2\/categories?post=168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/farnsworth.engineering\/index.php\/wp-json\/wp\/v2\/tags?post=168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}