Android

Build your smart car’s on-board computer!

Reading this post you will be able to create your smart car’s on-board computer, for example you will be to able to ask your Google Assistant (from your device or from an Android Auto head unit) the temperature of your car’s coolant liquid! Woa!

smart car

 

What do you need:

  • an Android device (with Google Assistant or Android Auto since your going to use this in your car)
  • Torque
  • Tasker
  • Join
  • An IFTTT account
  • an OBD2 device

Such a long list of stuff!

Let’s start!

IFTTT AND TASKER INTEGRATION

Thanks to Join, a new app from joaomgcd, you can create a URL to push information to your devices in a very easy and powerful way! Read his well written tutorial here  and you will be able to generate a URL to use in the Webhook that action of IFTTT.

As reference, I’d like to report the old way of doing this, so everyone can read it and understand how much Join has simplified and improved this process!

TASKER AND TORQUE INTEGRATION

Now, you will need to make Tasker able to read your car’s data using Torque. To accomplish this, open Torque and set it up to log your car’s data to a file on your sdcard (you can do it making changes in the Settings – Data Logging and Upload section)

Now Tasker will be able to read your car’s data reading that log file using the following task which you could import into it.

<TaskerData sr="" dvi="1" tv="5.2.bf6">
  <Task sr="task43">
    <cdate>1432225457845</cdate>
    <edate>1531597970703</edate>
    <id>43</id>
    <nme>ReadCarEngineCoolantTemperature</nme>
    <pri>100</pri>
    <Action sr="act0" ve="7">
      <code>342</code>
      <Int sr="arg0" val="5"/>
      <Str sr="arg1" ve="3">/storage/emulated/0/torqueLogs/trackLog.csv</Str>
      <Str sr="arg2" ve="3">%TORQUE_LOG_EXISTS</Str>
      <Int sr="arg3" val="0"/>
    </Action>
    <Action sr="act1" ve="7">
      <code>123</code>
      <se>false</se>
      <Str sr="arg0" ve="3">tail -1 /storage/emulated/0/torqueLogs/trackLog.csv</Str>
      <Int sr="arg1" val="0"/>
      <Int sr="arg2" val="0"/>
      <Str sr="arg3" ve="3">%OBDLOG</Str>
      <Str sr="arg4" ve="3"/>
      <Str sr="arg5" ve="3"/>
      <ConditionList sr="if">
        <Condition sr="c0" ve="3">
          <lhs>%TORQUE_LOG_EXISTS</lhs>
          <op>0</op>
          <rhs>true</rhs>
        </Condition>
      </ConditionList>
    </Action>
    <Action sr="act2" ve="7">
      <code>590</code>
      <Str sr="arg0" ve="3">%OBDLOG</Str>
      <Str sr="arg1" ve="3">,</Str>
      <Int sr="arg2" val="0"/>
      <ConditionList sr="if">
        <Condition sr="c0" ve="3">
          <lhs>%TORQUE_LOG_EXISTS</lhs>
          <op>0</op>
          <rhs>true</rhs>
        </Condition>
      </ConditionList>
    </Action>
    <Action sr="act3" ve="7">
      <code>547</code>
      <Str sr="arg0" ve="3">%EngineCoolantTemp</Str>
      <Str sr="arg1" ve="3">%OBDLOG2</Str>
      <Int sr="arg2" val="0"/>
      <Int sr="arg3" val="0"/>
      <Int sr="arg4" val="0"/>
      <ConditionList sr="if">
        <Condition sr="c0" ve="3">
          <lhs>%TORQUE_LOG_EXISTS</lhs>
          <op>0</op>
          <rhs>true</rhs>
        </Condition>
      </ConditionList>
    </Action>
    <Action sr="act4" ve="7">
      <code>559</code>
      <Str sr="arg0" ve="3">Engine coolant temperature is %EngineCoolantTemp degrees</Str>
      <Str sr="arg1" ve="3">default:default</Str>
      <Int sr="arg2" val="3"/>
      <Int sr="arg3" val="5"/>
      <Int sr="arg4" val="5"/>
      <Int sr="arg5" val="1"/>
      <Int sr="arg6" val="0"/>
      <Int sr="arg7" val="0"/>
      <ConditionList sr="if">
        <Condition sr="c0" ve="3">
          <lhs>%TORQUE_LOG_EXISTS</lhs>
          <op>0</op>
          <rhs>true</rhs>
        </Condition>
      </ConditionList>
    </Action>
    <Action sr="act5" ve="7">
      <code>559</code>
      <Str sr="arg0" ve="3">E C U connection not established!</Str>
      <Str sr="arg1" ve="3">default:default</Str>
      <Int sr="arg2" val="3"/>
      <Int sr="arg3" val="5"/>
      <Int sr="arg4" val="5"/>
      <Int sr="arg5" val="1"/>
      <Int sr="arg6" val="0"/>
      <Int sr="arg7" val="0"/>
      <ConditionList sr="if">
        <Condition sr="c0" ve="3">
          <lhs>%TORQUE_LOG_EXISTS</lhs>
          <op>0</op>
          <rhs>false</rhs>
        </Condition>
      </ConditionList>
    </Action>
  </Task>
</TaskerData>

This task will check for that log file on your external memory and:

  • if it founds it, it make your speakers say the last engine coolant temperature read by Torque
  • if it doesn’t found it, it make your speakers say there is no connection between Torque and you car ECU (your OBD2 adapter).

Another task that you will need is one that deletes that log file when the Torque app closes, so the next time you ask Tasker to read that file your are sure the data is new, and if there is no file, a new connection with your car wasn’t established.

<TaskerData sr="" dvi="1" tv="5.2.bf6">
  <Task sr="task47">
    <cdate>1525023939110</cdate>
    <edate>1529001057169</edate>
    <id>47</id>
    <nme>DeleteTorqueLog</nme>
    <pri>100</pri>
    <Action sr="act0" ve="7">
      <code>406</code>
      <Str sr="arg0" ve="3">torqueLogs/trackLog.csv</Str>
      <Int sr="arg1" val="0"/>
      <Int sr="arg2" val="0"/>
    </Action>
  </Task>
</TaskerData>

GOOGLE ASSISTANT AND IFTTT AND TASKER AND TORQUE INTEGRATION

Now the last part! We have all the pieces, let’s put them together!

Login to IFTTT and create a new applet!

Click on this and look for Google Assistant, then click on it. Select the Say a simple phrase trigger and write your custom question(s) and response; click then on Create trigger

Click now on that and look for Webhooks, then click on it. Select the Make a web request action and use the URL you generated as explained in the joaomgcd’s tutorial. Click on Create action, then on Finish and your recipe is ready!

Open your Google Assistant and say the phrase you just put in the IFTTT recipe, your device should say you’re not connected to the ECU, you got the push notification, that’s great!

Now go to your car, turn it on, make Torque pair with your OBD2 adapter…. when it’s ready ask Google Assistant again to read your engine coolant temperature and now you should hear it! Wonderful, it works!!!

FURTHER IMPROVEMENTS OF YOUR SMART CAR

The recipe on IFTTT and the task on Tasker could be improved by using parameters and so making you able to ask for and listen to different details of your car, which could now be called a smart car!