So while my Day Job mostly involves breaking things and broken things (I'm an InfoSec/ITSec consultant), one of my side interests for several years running has been Internet of Things (IoT) security, mostly because it's a never-ending train wreck of Fail and keeps getting worse as the scale (and with it, the attack surface) continues to grow.
And one of the reasons that it never ends is because when it works, the things you can do with it are pretty freakin' amazing. Like, in my case, gather and analyze detailed telemetry off a scooter in realtime.
Which leads me to The Ves-pi Project.
I may not have a lathe or a Bridgeport or a HAL9000 tri-axiall mill, but I *do* have a soldering iron and a keyboard and, much like my Dremel, there's not much I won't try with them. Some of this is going to be a little technical, but I'm going to deliberately try to keep things high level to start and if people want me to get into the nitty-gritty, we can do that, too.
So using a Raspberry Pi Zero W, which is a tiny (a little bigger than a AA battery) Linux server and several sensors, I've built a telemetry capture setup for detailed capture and (eventually) visualization & analysis of:
- Throttle position (Idle-WOT as %) -- use a Potentiometer (aka a "pot," or more commonly, "a dial") plugged into an Analog-to-Digital (A2D) converter
- Gear (1N234) -- another pot, attached to the selector box, on a second channel of the A2D
- Clutch (in/out) -- A simple momentary button, either on the lever or, assuming I can work out a good attachment point & method, the clutch arm itself
- RPM's -- I'm using an OptoElectric sensor plugged into the AC feed off the stator, which gives me complete isolation from voltage spikes, but I'm also going to try and build an induction sensor I could wrap around the plug wire and/or use a Hall Effect sensor and put a tiny magnet on the flywheel.
- CHT -- simple temperature probe, same principle as a "regular" CHT
- EGT -- Same thing, just haven't built it yet because I still need to test if my existing EGT probe will work with my temperature sensor board)
- Speed (via GPS)
- Position (latitude/longitude/altitude) (GPS)
- Acceleration -- Dedicated Accelerometer
The Pi captures all of it multiple times per second, then uploads it in realtime via wifi to my phone up to a Timestream database in AWS (Amazon Web Services, aka "The Cloud") via their IoT-Core service. I'll also be building a dashboard in the near future for viewing and analyzing the data (not to be confused with a physical dashboard on the scooter itself).
I'll have to experiment with capture rates, but I'm thinking five times per second and I could go significantly higher on everything but the GPS, which can only feed me updates about ten times per second due to limitations in how GPS'es communicate (they use a serial protocol at 9600 bps) if I so chose.
I also built a marker button (momentary switch) for noting interesting events--something interesting happens, hit the button and it logs the time for easy post-review--and a capture interval button (on/off switch) for capturing that a range will be interesting, e.g. specific performance testing. I may also use that as a trigger to up the sensor capture rate, say to 10/second.
I'll also be adding some additional signals and instruments for things like temperature spikes and delta, gear indicator, acceleration, maybe a temperature anomaly warning (i.e. "it's running hotter than usual for the current throttle/gear/speed), etc. that will use a combination of direct analysis on-board as well as getting alerts back from AWS
As of right now, I've only gotten so far as prototyping the sensors on breadboards, written all the code to capture and stream the data up to AWS and receive alerts back. As soon as some wiring arrives (should have been here yesterday, now arriving today or tomorrow) I'll be able to solder everything together properly, then install it on the GL and start capturing some real data to build the dashboard.
I still need to decide exactly how I want to build the dashboard, and may still switch databases to use ElasticSearch or OpenSearch and a Kibana dashboard, but that can be the subject of a separate post once I've had a chance to play with them and do a little more research.
All my custom code is written in Python and once I've had a chance to test it all out and add error handling (it doesn't have much currently), I'll share a link to my git repository. I'll also pull together the parts list and wiring diagram at some point, too.
One final note: While an Arduino (another kind of embedded computer) would in theory be slightly better suited for this, I went with the Pi because it doesn't need a separate controller to handle the MQTT (telemetry), it can handle more complex onboard operations, and it's a LOT easier for me to develop on.