How I got the Amazon Echo to start my car. (Part 6)

UPDATE 2: Amazon broke it and a lot of other two word devices. Removing the space from “MyCar” works.

UPDATE: Amazon OR SmartThings BROKE virtual switch capability with the echo earlier this week. It shows up under discovered devices and just gives a failed tone when triggered. I have inquired about this and have not heard back yet.

The elusive Part 6 of my Amazon Echo car start series is finally here!

So here we are, you read through the first five posts and are thinking to yourself “Ok Jryan, how in the hell do I do this myself?! Simple directions please.”

A little demanding tone, but ok, I’ll oblige.

WARNING: THIS ONLY WORKS ON GM CARS! Don’t waste your time trying other cars unless you’re up to months of frustration figuring it out. It *may* work on others, but you WILL need to find out the can-bus to use, the can-bus entry point, and the commands to use and how to structure them.

Gather your materials

  • Smart Things (No link, I will detail in another post eventually why I am no longer recommending the platform. That’s what I have currently setup in my home, but not for much longer. Summed up, it’s unreliable.)
  • Raspberry Pi Model A+
  • Raspberry Pi Model A+ Case (The one I have is no longer made, you’re on your own here.)
  • Sandisk SD Card
  • Bluetooth/Wifi Dongle
  • OBDLink MX Bluetooth
  • Car Adapter
  • A random generic USB hub, USB Keyboard/Mouse, HDMI Cable, MicroUSB wall adaptor, android tablet or phone. All of this is needed JUST for setup. If you are seriously reading this right now, setting this all up, I guarantee you have all of these things already.

NOTES:

  • Vera, OpenHAB, HomeSeer will all work, but I am not outlining the directions here. Maybe later if I am asked for specifics on these systems.
  • I suppose you could use a Rpi zero as well. I can’t tell you how it works though BECAUSE I CAN’T OBTAIN ONE! Also, steer clear of ALL OTHER MODELS of the Rpi, including the new Rpi 3, the power draw is too high for this project, among other issues you may have. If you aren’t going to attempt this until June, give the $9 C.H.I.P computer a try.
  • The Cirago Bluetooth Wifi dongle I used is no longer available and I HAVE NOT personally tested the one I listed.
  • Feel free to use whatever car adapter you’d like. Power issues are a bitch though. My Samsung fast charge car adapter has been great.
  • WTF, root? Sudo for the web service? ARE YOU MAD?! Yeah, well, do whatever you’d like. This is not a device sitting on the public internet, you can only get to it from the local network. If you want to secure it even more Mr. (Or Mrs.?) Paranoid, be my guest.

Perform The Steps

  1. Head over to the Raspberry Pi site and download “Raspian Jessie Lite”.
  2. Image your SD card. Here, have some directions: https://www.raspberrypi.org/documentation/installation/installing-images/README.md
  3. Plug in the usb hub, wifi/bluetooth dongle, keyboard/mouse, the SD Card, HDMI cable and power.
  4. You should be loaded into the terminal on boot. The default username is “pi” and the default password is “raspberry”. (If you care to change the password, you can do so by typing “sudo raspi-config” and selecting option 2.)
  5. Setup Wifi
  6. Give your Raspberry Pi a static IP
  7. Enable SSH:
    • Type sudo raspi-config
    • Option 9
    • Option A4
    • Enable
    • Ok
    • Finish.
  8. Set the root password:
    • sudo passwd root
  9. Allow root login on SSH:
    • sudo nano /etc/ssh/sshd_config
    • Change the line “PermitRootLogin” to “yes”
    • Ctrl+o to save
    • Ctrl+x to exit back to terminal
  10. Remove a few troublesome packages:
    • sudo apt-get purge ifplugd avahi-daemon
  11. Update and Upgrade Raspbian
    • sudo apt-get update && sudo apt-get upgrade
  12. Reboot the Rpi
    • reboot
  13. Install a few needed packages:
    • sudo apt-get install php5-common php5-cli php5-fpm nginx bluetooth python-serial minicom
  14. Add www-data to allowed sudoers.
    • sudo nano /etc/sudoers
    • Add the line below to the last line of the file. Save and exit.
    • www-data ALL=(ALL) NOPASSWD: ALL
  15. Setup Nginx to use PHP
    • sudo nano /etc/nginx/sites-available/default
    • Find the section below and REMOVE the # signs so it looks as follows.
    • # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
      #
      location ~ \.php$ {
      include snippets/fastcgi-php.conf;
      #
      # # With php5-cgi alone:
      # fastcgi_pass 127.0.0.1:9000;
      # With php5-fpm:
      fastcgi_pass unix:/var/run/php5-fpm.sock;
      }
    • Save and Exit
  16. Downgrade the MX Bluetooth to V3 firmware. Ugh, what a wasteful step. We wouldn’t need to do this if OBDLink was a responsive company…
    • Pair your MX Bluetooth with your phone.
      • Plug it into your car, press the pair button, and you better know how to complete the pairing progress on your phone/tablet.
      • Now that you have it paired, go to the Play Store and download “OBDLink”
      • Open OBDLink
      • Select “Settings”
      • “Communications”
      • Select “Bluetooth Device” and select whatever name the MX Bluetooth paired as.
      • Select “Firmware Updates”
      • Select the version 3 firmware, and downgrade it. Why? Because it’s way more stable than version 4 for this purpose.
      • When the upgrade is finished, unpair it from your phone and reset it to factory settings (Hold the button down until you see the light start rapidly flashing on the MX)
  17. Here’s the step where ssh is going to come in handy. Plug just the usb wifi/bluetooth adapter into the Pi, hook it up to your car’s power, and bring a laptop to SSH into it.
  18. Pair the MX Bluetooth to your Raspberry Pi
    • Plug the MX Bluetooth into your car
    • bluetoothctl
    • scan on
    • Press the pairing button on your MX Bluetooth
    • It will pop up, copy the mac address.
    • pairable on
    • pair MACADDRESS_GOES_HERE
    • trust MACADDRESS_GOES_HERE
    • scan off
    • exit
    • sdptool add SP
  19. At this point, it would be a good time to find your keyfob lock code. Go back and read. I get into this. EXCEPT, you will be using Minicom instead of Cutecom because there is no GUI with Jessie Lite and I do not recommend you install one.
  20. Install some files from Github. You can WGET or send them over with SSH (you may have set it up earlier). https://github.com/jryanishere/GM-Car-Automation
    • Place keyfob.php in “/var/www/html”
    • Place keyfob.py in “/var/www/html/cgi-script”
  21. Edit keyfob.py
    • nano /var/www/html/cgi-script/keyfob.py
    • Insert the first two digits on line 58 and the next 6 digits on line 61. (Hopefully the rest of the command will line up and everything will work.)
  22. Time to test.
    1. In a browser on your computer, navigate to “http://RASPBERRY_PI_IP/keyfob.php?command=lock”
    2. Did your car lock? Yes? Go to step 22.
  23. Get SmartThings configured
    • Make a developer account if you don’t already have one.
    • https://graph.api.smartthings.com/
    • Login
    • Click “My Device Handlers”
    • Click “Create new device handler”
    • Click “From Code”
    • Copy and paste the contents of the “SmartThings Device Handler” from my Github
    • On line 43 and 49, update the ip address to your ip address. You’ll notice a hex code after the IP. You’ll need to change this as well. It is a converted version of your IP address. You can convert it here: http://www.miniwebtool.com/ip-address-to-hex-converter/
    • Click Create
    • Click “Publish” then “For me”
    • Click “My Devices”
    • Click “+New Device”
    • Name it “My Car”
    • Make the Network Id “CarStart”
    • Select your hub
    • Select the type, at the bottom of the list select “On/Off Button Tile”
    • Create
  24. Now that you have your new device in SmartThings, you can now re-add your SmartThings account in your Amazon Alexa app, select your new device, and discover new devices.
  25. “Alexa, turn on my car”

32 thoughts on “How I got the Amazon Echo to start my car. (Part 6)”

  1. Any reason why you don’t have the Pi plugged into the wall in the garage right next to the car? I have power like ~3ft from the driver door.

    1. Two reasons.
      #1 My garage usually has a project or two going on in it so I rarely have room to park.
      #2 I have a cellular module that I did not talk about in the post.

      1. It’s my understanding that the Pi3 with built in Wifi/Bluetooth was too much of a draw on the car battery to keep it running 24/7. That being said, if I could use it near the driver door plugged into the wall it *could/might* work?

        1. It will work. When I was hammering out reliability issues, I had the Pi mounted to the window that you see to the immediate right of the car in the vid. I had the car pulled in the other way however (drivers door was right next to the window).

          If you do this, PLEASE program your garage door to open when you send your car a start command. Carbon Monoxide is no joke.

          Also, the same company makes a wifi version. Don’t even waste your time with it. It was so unreliable, it barely lasted a week until I sent it back.

      2. Hey, for the Cellular module, is this something hooked up to the car or the Pi or…? I have a ZTE Mobley that makes a wireless network when it’s powered. Link below. I’m wondering if when the Canbus gets “activated” if it will turn it on too.

        I’m also wondering if there might be some way to connact to something like that Automatic Pro that has a cell connection to connect

        ZTE Mobley https://www.att.com/devices/zte/mobley.html#sku=sku7700323
        Automatic Pro https://www.automatic.com/pro/

  2. Yeah, I’ll definitely be opening the garage door. I was interested as I already have a pi3 / 2 echos / smart things / and a silverado. I’ll be giving it a go soon. Just got the odb module in today. Thanks!

    1. Cool. Post back when you get it to work (or on Reddit). I would love a 3rd party confirmation for the doubters.

    1. The concept will be the same, the code will be very different as will the entry point to the vehicle’s can bus (it may not have the correct can bus exposed to the OBD 2 port). I do not believe your current BAFX adapter will support everything needed to get this to work either.

  3. Am I understanding correctly?
    If I wanted to do this on a Mercedes C250 the main thing I would need to do is find out what codes do what for the car. I believe I would need to find out which can port to go through? Is that correct also?

    1. You need to find out which can bus your car uses to send the start command. Then you need to figure out if the can bus is accessible from the obd2 connector. If it is, you can most likely use the MX, if not, you need to pick up a can bus shield for rasp pi and find the can wires to tap into.

      Once you get in, you need to sniff the commands needed, structure them, and send them back down the can bus.

  4. Regarding this: “UPDATE: Amazon OR SmartThings BROKE virtual switch capability with the echo earlier this week. It shows up under discovered devices and just gives a failed tone when triggered. I have inquired about this and have not heard back yet.”
    I have a Pi running a virtual Hue Bridge that runs all my X10 commands and controls all of my Harmony Hub stuff. Like you one of my favorite commands “Turn on Channel Four” stopped working! Like you it heard it, it came up on the card – but NOTHING!! I went nuts troubleshooting the Pi before calling Amazon. It turns out like you said – they killed the virtual switch – BUT by adding “the” in the command: “Alexa, turn on THE Channel Four” – suddenly it worked again! Simple as that! Of the 39 commands I have, only two required adding “the” in the verbal command. So, don’t change ANYTHING – just try adding the word “the” in your verbal command to the Echo!

  5. Two other things:
    1) power. Have you considered powering the Pi from Solar? I have a Pi-Pandora radio running off solar with a 3.7 volt battery, a buck converter, and a solar charger (all together under $40) that runs it 24/7 no issues. This will help: http://juliansarokin.com/how-to-build-a-solar-powered-raspberry-pi/
    2) Bluetooth. In a recent instructable for a car Pi computer, the maker uses a low-energy bluetooth dongle specifically to communicate with the OBDII bluetooth dongle. http://www.cowfishstudios.com/blog/obd-pi-raspberry-pi-displaying-car-diagnostics-obd-ii-data-on-an-aftermarket-head-unit
    Hope those help!

    1. I am sure the solar would work. But using a Zero or Model A+ solves the power issue. I don’t want to have to have a solar panel on my dash.

      As for Bluetooth, the adapter on the pi goes to sleep after the command is sent. The OBD adapter on the car goes to sleep after 10 minutes. The radio’s are not much of a power concern. It is the pi’s circuitry sitting idle that has the draw.

  6. Hi jryan, really nice post and totally respect the work done since for sure was painful.

    I’ve designed and prototyped in the past 6 months a board on rfduino with stn1170, BLE 4.0, accelerometer and gps integrated and i’m trying first of all to make it work just as obd generic diagnostic tool for iOS/Android. Later on i’m planning on integrating tensorflow or coffee script for artificial intelligence parsing of all this codes and encrypt them back to user in order to decode on the fly can messages to access the car from the phone and maintain them encrypted in order to keep aligned with the law…

    If you are interested i can share the progress that i’ve made till now. Past months were only to finish the board and now i’m starting to look in the application side.

    thanks,
    vali

    1. I’d love to have a look. There has always been a bit of a reliability issues with this stupid MX Bluetooth and the company has been draggeing their feet on a release.

      The other company I hinted at has not released their replacement product yet.

      And there is a third company that “may” have their product out mid summer, but we’ll see…

      But even so, I still would get into power issues. I’d like to shrink everything down to an Arduino with a GSM shield.

  7. I am unable to downgrade the bluetooth firmware to 3.0.
    Can you please help. Also the OBD link is not connecting to the pi.

    1. Reset the dongle by starting your car, plugging it into your car, holding the button down until ALL lights light up, and try pairing it with your phone again. While the car is running and once paired with your phone, try the OBDLink app to downgrade the firmware again.

      If you are having trouble downgrading the firmware, you may have received a bad MX Bluetooth.

      If you happen to have a 2011-2017 GM vehicle, I have a different method that now uses a cheap android device sitting in your house, tasker, and the new myGMC app.

      What year/model vehicle do you have?

      1. Very interesting document, something I’ve been wanting to figure out for a while….

        Saw your last comment about a new method for 2011-2017 GM cars and Android device/myGMC app – 2014 Terrain here… Have you written any details about this new method yet?

        1. I have not and am wary to. The jist of it is you need a DEDICATED android tablet/phone with tasker, autoinput, and autoremote. You have Alexa trigger a Tasker profile to go through the app and press the buttons for you.

          From asking Alexa to starting my car, it takes about 30 seconds (As opposed to 5 seconds with my original method). BUT, no extra hardware is needed. No more drain on my battery.

      2. I was looking at the project and noticed this comment so I have to ask: If I have an 11 Enclave, with full usage of the “OnStar” and “MyBuick” apps (remote start and all that jazz), Is there a more simple way to connect Alexa to it now? Thanks in advance for any info

        1. The jist of it is you need a DEDICATED android tablet/phone with tasker, autoinput, and autoremote. You have Alexa trigger a Tasker profile to go through the app and press the buttons for you.

          From asking Alexa to starting my car, it takes about 30 seconds (As opposed to 5 seconds with my original method). BUT, no extra hardware is needed. No more drain on my battery.

          Not sure if I ever will post a guide since the last time I did Amazon took away my phrase.

  8. I get minicom to connect with the OBD II adapter except I can’t type an commands. It gives me this arrow “>” but when I type your commands nothing happens. I have tried different baud rate as well. Can you please help?

    ////////////Below is what I get when I run minicom////////////
    Welcome to minicom 2.7

    OPTIONS:
    Compiled on Sep 17 2016, 05:53:15.
    Port /dev/cu.OBDLinkMX-STN-SPP, 11:44:54

    Press Meta-Z for help on special keys

    >

    ////////////////Below are my serial settings for minicom///////
    | A – Serial Device : /dev/cu.OBDLinkMX-STN-SPP
    | B – Lockfile Location : /usr/local/Cellar/minicom/2.7/var
    | C – Callin Program :
    | D – Callout Program :
    | E – Bps/Par/Bits : 115200 8N1
    | F – Hardware Flow Control : No
    | G – Software Flow Control : No

    1. I don’t know for sure your particular issue. I am going to guess it has to do with a linefeed setting or carriage return setting.

      If you install the desktop environment on the Pi, you could give CuteCom a try as well, it’s more friendly to use.

      Post back if you get it working on your Lexus. Although none of my commands or structure will translate over.

      1. Thank you for replying. Would be able to send me all your specific settings. I tried your settings from part 4 of this tutorial and my own settings, but none worked. If you would not like post the specific settings you could email me at soifer00@gmail.com .

        Also I tried installing CuteCom from http://cutecom.sourceforge.net but I was unsure on how to install it. I want unable to figure out how to use CMAKE. I usually program in Java and am new to command line.

  9. Hey JRyan,

    You messed with this any lately? tried any other OBDII adapters?

    trying to put my parts list together and I was wondering if the big $70 OBDII adapter was just because you need GM (Hard to want to spend like 7 times more for that when there’s this https://www.amazon.com/Goliton%C2%AE-Bluetooth-Supper-Compatible-Andriod/dp/B009NPAORC/ref=sr_1_5?s=automotive&ie=UTF8&qid=1428250836&sr=1-5&keywords=ELM327+Bluetooth+Adapter for $11 prime. )

    Anywho, I’m probably going to be working on putting this into my 2016 Hyundai Sonata.

  10. Insert the first two digits on line 58 and the next 6 digits on line 61. (Hopefully the rest of the command will line up and everything will work.)

    Don’t quite understand which digits I need to enter? Any help is appreciated

Leave a Reply

Your email address will not be published. Required fields are marked *