Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
wiki:misc:ovms [2020/07/28 12:59] – created jaxxmisc:ovms [2021/02/08 22:35] (current) – [Fun with NodeRed] jaxx
Line 1: Line 1:
 +====== M5 Stack websocket client and display ======
 +
 +The OVMS has Wifi and also exposes a websocket server from which you can stream metrics from.
 +I've glued together some [[misc:ovms:m5code|horrible code]] that allows displaying some information to an [[https://m5stack.com/collections/m5-core/products/basic-core-iot-development-kit|M5Stack Core]].
 +
 +The buttons also allow to trigger hand crafted events that end up being managed by some javascript code in NodeRed (that subscribes to the MQTT broker used by the Protocol V3 stack in OVMS)
 +
 +{{ :misc:ae7e68c2-6427-4b7f-8ea2-d63d92384292_1_105_c.jpeg?direct&600 |}}
 +
 +====== ABRP Plugin for OVMS ======
 +
 The ABRP plugin and explanations for OVMS can be found [[https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/tree/master/plugin/abrp|here]] The ABRP plugin and explanations for OVMS can be found [[https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/tree/master/plugin/abrp|here]]
  
 Beyond setting your car model with ''config set usr abrp.car_model <value>'' and personnal API token with ''config set usr abrp.user_token <value>'' you will need to change the default url with ''config set usr abrp.url <value>'' Beyond setting your car model with ''config set usr abrp.car_model <value>'' and personnal API token with ''config set usr abrp.user_token <value>'' you will need to change the default url with ''config set usr abrp.url <value>''
 +
 +===== ABRP GET bounce =====
 +
  
 The URL will point to code that looks a bit like this: The URL will point to code that looks a bit like this:
Line 25: Line 39:
 ); );
  
-file_get_contents($URL.'?'.$_SERVER['QUERY_STRING'], 0, $ctx);+file_get_contents($URL.'?'.$_SERVER['QUERY_STRING'], 0, $ctx); // <-- simply copy in the end 🤷🏻‍♂️
  
 //echo "OK!"; //echo "OK!";
 </code> </code>
  
-the libTorque.php used to be old code to parse the crazy stuff that the android Torque app used (with a Bluetooth OBD dongle)... because it started by sending data to inform on how to parse subsequent url calls... (where the ABRP plugin directly embedded in the OVMS has much easier to parse data) but at least you can start having look:+the libTorque.php used to be old code to parse the crazy stuff that the android Torque app used (with a Bluetooth OBD dongle)... because it started by sending data to inform on how to parse subsequent url calls... (where the ABRP plugin directly embedded in the OVMS has much easier to parse data) :  
 + 
 +<code> 
 +37.164.143.zz - - [28/Jul/2020:10:20:21 +0200] "GET /?api_key=32b2162f-9599-4647-8139-66e9f9528370&token=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx&tlm=%7B%22utc%22%3A1595924417%2C%22soc%22%3A61%2C%22soh%22%3A100%2C%22speed%22%3A0%2C%22car_model%22%3A%22kia%3Asoul%3A19%3A64%3Aother%22%2C%22lat%22%3A%22xyz.327%22%2C%22lon%22%3A%225.048%22%2C%22alt%22%3A%220%22%2C%22ext_temp%22%3A23.5%2C%22is_charging%22%3A0%2C%22batt_temp%22%3A28%2C%22voltage%22%3A371.2%2C%22current%22%3A1.2%2C%22aux12v%22%3A13.99%2C%22power%22%3A%220.4%22%7D HTTP/1.1" 200 5 "-" "ovms/v3.1 (joul 3.2.013-304-g599b0975/ota_1/edge (build idf v3.3.2-879-g0137aef47 Jul 18 2020 15:14:00))" 
 +</code> 
 + 
 +The ''tlm'' parameter decodes to clean json string: 
 +<code> 
 +tlm={"utc":1595924417,"soc":61,"soh":100,"speed":0,"car_model":"kia:soul:19:64:other","lat":"xyz.327","lon":"5.048","alt":"0","ext_temp":23.5,"is_charging":0,"batt_temp":28,"voltage":371.2,"current":1.2,"aux12v":13.99,"power":"0.4"
 +</code> 
 + 
 +but here's the old stuff:
  
 <code php> <code php>
Line 137: Line 162:
 } }
 </code> </code>
 +
 +====== OVMS V3 Protocol ======
 +
  
 Since, I have simply configured a [[https://nodered.org/|NodeRed]] server, that consumes and parses ovms metrics over MQTT. Since, I have simply configured a [[https://nodered.org/|NodeRed]] server, that consumes and parses ovms metrics over MQTT.
Line 270: Line 298:
 It listens to ''joul/#'' and ''darthmaul/#'' because I ended up renaming the car after a while. It listens to ''joul/#'' and ''darthmaul/#'' because I ended up renaming the car after a while.
  
-{{ :wiki:misc:node-red_nodered_jaxx_org.png?400 | nodered }} 
  
 +{{ misc:node-red_nodered_jaxx_org.png?nolink&600 | Nodered}}
 +
 +Easier to understand, here's what's inside mqtt2influx:
 +<code javascript>
 +msg.topic = msg.topic.replace(/\//g,"_").replace("joul_","").replace("darthmaul_","");
 +
 +
 +if(msg.topic.startsWith("metric_")){
 +    msg.topic = msg.topic.replace("metric_","");
 +    var returnmsg = {};
 +    
 +    returnmsg.payload = [
 +        {
 +            measurement: msg.topic,
 +            fields: {},
 +            timestamp: new Date()
 +        }
 +    ];
 +    
 +    if(msg.payload.includes(",")){
 +        var a = msg.payload.split(","), i;
 +        for (i = 0; i < a.length; i++) {
 +            returnmsg.payload[0].fields[i]=parseFloat(a[i]);
 +        }
 +    }else{
 +        returnmsg.payload[0].fields[msg.topic] = parseFloat(msg.payload);
 +    }
 +    
 +    return returnmsg;
 +}
 +</code>
 +
 +Once you're all set, you can get precise metric data and plot it over in your Chronograf dashboard:
 +
 +{{ misc:chronograf.png?direct&600 | Chronograf }}
 +
 +Or even nicer with Grafana
 +
 +{{ :misc:kia_-_grafana.png?direct&600 | Kia Dashboard in Grafana}}
 +
 +{{ :misc:screenshot_2021-02-08_223201.png?direct&600 | Kia Dashboard in Grafana2}}
 +
 +====== Fun with NodeRed ======
 +
 +{{ :misc:node-red_nodered_jaxx_org2.png?direct&600 |}}
 +
 +I ended up with the first [[https://twitter.com/DarthMaulEV|tweeting car]] ;-)
  
 +[[misc:ovms:lvglstuff|misc:ovms:lvglstuff]]