Meshtastic shenanigans
"You wouldn't let it lie" and I don't mean a Vic & Bob Friday night quote, you have to be a certain age to remember that reference & have a certain sense of humour.
I now have many / multiple Heltec LoRa devices, okay, about 6-ish, along with a couple of T-Decks and I've been trying to figure out what to do with them, well, it's obvious for the T-Deck as they have keyboards attached, but the Heltec devices.... that's a different thing all together.
I've bought a few new antenna's for usage outside so I can have a permanent outside repeater node, I rigged it up earlier and then I noticed I'd picked up another node 26km away! OMG! That is awesome, right up over by the white horse by Tan Hill, the other side of Devices on the way to Avebury. anyway, this got me thinking a bit more.
I do dislike having to use the Bluetooth connectivity from my phone to be able to interface with the Heltec devices. The BLE antenna's are crap, you have to be about 6ft from them to get a signal, which means for the one outside I basically have to stand underneath it. Not ideal.
I thought, there must be a better way. Of course there is, there always is, it's just software.
I had a little look online and examples / tutorials for this is very scarce, or my DuckDuckGo foo is not so good with this type of searching? probably the latter.
My goal was to find a way to write NodeJS JavaScript to interface with the Heltec device, whilst plugged in as a serial device. Access the device, get the info from it and then send / receive text messages via the device, all from my laptop.
As I'd already installed $ meshtastic previously (it's a Python3 library in case you were wondering), that got me thinking... I wonder if it has an API or whether I could just use the meshtastic library myself and call the functions that are exposed.
After a little bit of jiggery-pokery, this was an example of what I could access and do:
basically, I have 2 x Heltec devices plugged into my laptop, 1 is using a usb-c cable for serial comms. the other is just using it for power, the other device is outside in the garden.
The python code (yes, I know... it IS cardboard code, after all) makes a serial connection and then calls a few functions to get info about the device itself, as shown above, then it calls the nice function that prints out a nice table for the nodes in the current mesh, then it does it as an object and then I send a text message to a specific device - all very simple, but powerful stuff. Did I say it was SIMPLE, like really simple... a 4 year old could write this code:
I found this website that details the python code, it is written as a reference set of documentation and not a tutorial / example set of pages, so don't expect an easy life.
But, with a logical approach, it is pretty easy to work out what is needed to be done.
The last command I do is to send a text message from the serial connected device to the other device - I can confirm that it did this perfectly! I would show a photo of the tiny little screen, but my phone camera is crap & cannot focus that close / small, so you'll have to trust me....or I could video it, but, pffhhhh, that's way too much effort.
Now the easy PoC has been done, it's now time to see if I can do the same from JavaScript, if not, then double-pffhhhh, I'll stick with Python and look at making a proper application that saves messages etc...
Right, well, that's all nice & lovely, but what can you do with this?
Oh, I don't know...maybe lots of things!
The Heltec devices devices themselves can have pins soldered to them and I can extend the devices to make usage of the GPIO pins on them, so they can be used to monitor sensors OR to activate sensors or actuators or anything else.
I can send a message and trigger a request for reading of some information and have that sent back to this device or onto another specific one, or, I could detect my car is approaching the end of my road and it is past 6pm, therefore trigger the garage door to open, bat-cave style. Lots of possibilities.
Now that I can write a centralised piece of code that can, potentially be run as a web-server, I can then manage comms. from the "fixed node" to all of the others, transmitting messages and data to / from them. There's nothing to stop me having a client app connected to the Heltec device that is not connected to my laptop, so someone else can respond / react to a message sent. Lots of ideas.
Again, I'm just currently looking at the art-of-the-possible, a technology looking for a purpose, no real user requirements, proper R&D innovative thinking (very anti-work/work attitude, but meh!), I have LOTS of ideas how I could use this technology along with some smart LLM / ML code & I'm sure over the coming months I'll try out a few of them.... could even integrate it somehow with ollama.ai
Comments
Post a Comment