Implementing a Vehicle Mode

Hi

I’m in the process of getting a meshtastic based gps tracker network running for our vehicles (quad bikes, tractor etc) on the hill country farm in New Zealand.

I’ve modified my device firmware to do a few things that make them work better for this use case:
-when powered, follow standard settings. I use 1s GPS updates and 60s position broadcasts
-when unpowered, the GPS update rate and position broadcast both drop in frequency (the assumption being when unpowered, the vehicle is stationary). I use 10mins for both.
-after 30 minutes unpowered, the node powers off completely (ie axp.shutdown()). I also raised the low battery threshold to be nicer to the battery. On low battery, it shuts down too (rather than deep sleep).

My TBeams start up fine when power is applied, so that’s working quite well.

In the future I plan to add support for an IMU to detect vehicle rollovers, and send out a message so all the other nodes will start yelling about it. Quad rollovers are a significant safety issue here in NZ, and the way it normally kills you is you get trapped underneath and eventually suffocate, so the sooner you can get help the better.

My question is what the best place to put this code would be? I’m quite comfortable coding it myself (hopefully a pull request one day), would you recommend another preference “vehicle_mode” to enable these behaviour changes? It doesn’t look like a plug in could mess with the power state machine well enough to work (am I wrong here?)

I’m guessing for the IMU thing a plug in would be the way to do that, that would be fine with it’s own protobuf I think.

Any other advice from you wise people?

Cheers
Josh

2 Likes

If you have such energy I highly suggest you to port meshtatic to mynewt, I would like to support you with hardware design…

Nice work! From my point of view some kind of vehicle_mode looks promising. That could sort of bundle all needed modifications in a user friendly way.

There’s an active discussion in our discord on a very similar topic. Would be great to include you on this and brainstorm.

check out the new position_broadcast_smart feature that will broadcast more often based on movement, this should produce similar results to your GPS modifications.

for the power behavior, check is_low_power and is_always_powered settings for reference, you could add something like “is_vehicle_powered” or “is_ignition_powered”.

as for the roll over, maybe a more generic “panic/emergency alert” could be created with different ways to trigger it.

Oh! The panic / emergency “button” that is often requested could have other ways of triggering the event. Brilliant!

what about something like a DistressPlugin that gets a couple of GPIOs for a button, led, and beeper, and also could talk to an IMU for rollover detection if connected.

I did spot that smart position feature, I’ll give it a try this week

1 Like

Consider extending the ExternalNotificationPlugin … a lot of the framework for what you’ll need is already in there.

The smart position feature is working well for me now, so really the only other thing that a vehicle mode would need to do (for my use case) is to shutdown the node a certain time after the external power is disconnected.

What I’ve done is change the enter deep sleep method to actually fully power off the device, and then a timer that triggers a low battery event 30 minutes after power is disconnected.

So something like a on_battery_shutdown_after preference that if >0 applies the behaviour I’ve just described

1 Like

To create the preference, update the protobufs:

Specifically, you’ll likely be in: