LilyGo T-Deck LORA device - setup
"A what now?", "What is that and why is it needed?"
Basically it's a communications device that does not use WiFi or Bluetooth or 4G/5G SMS / GPRS - it uses the LoRa comms protocol, it's basically Radio Frequency output that will broadcast for miles / kilometers - average of 2Km but if you live in a flat area it can reach 20Km. That's "free" comms between devices, passing "data", ie. small packets of text based data between devices, it's not built for audio or video (that "can" be done, but it's not the purpose). So when the world ends, or a nuke drops or a solar flare bursts and an EMP pulse fries all the electronic devices (you did store a bunch of these in a Faraday cage didn't you?) you'll still be able to have comms without using smoke signals.
There's a bunch of YouTube videos about that sort of scenario - however, that's not what I was wanting to use it for. I actually just wanted to have comms between devices in my garden! Not really needing the milse & miles of transmission power, but far enough to have a mesh-network, as, I don't know about you my home WiFi router doesn't reach the end of my garden & if it did, I would not be happy it transmitting that far. So what options do I have? I could set up a load of BLE devices... but y'know....LoRa seems like a better option and a perfect excuse to have a fiddle around getting it working & then figuring out how I can use it for "other things".
Right, so we have HARDWARE and we have SOFTWARE in this equation.
Hardware will be LilyGo T-Echo (currently waiting to be delivered, held up in UK customs) and a LilyGo T-Deck and a couple of yet-to-be-delivered ESP32 generic lora devices. For now we'll focus on the T-Deck as I have it to hand.
Software is initially just the OOTB Arduino .ino ESP32 code to make sure I can connect & flash the device from my laptop. I'll try a few apps just to be sure - I did find an oddity with the Arduino 2 IDE that I'll show, more annoying than anything else. Then I'll move on over to the MESHTASTIC open-source application and how that can be used for encrypted messaging between multiple devices. I may or may not continue with this, we'll see...
So what does a T-Deck look like? Well... a Blackberry device, of course! Well, the keyboard is direct re-purpose of the infamous Blackberry from back in the day. The trackwheel is a little odd to get used to again, but the touchscreen is something I keep forgetting to use! I was to use an arrow key and then remember I can just swipe the screen or press it with my finger!
The device itself is provided in "raw" format - ie. it is not in a case, apparently you can 3D print one - I'll give that a go over the next week (as I'm off work, yay! and should have time for messing around with the 3D printer bed-levelling faff!). It does come with lots of things that won't be used straight away, such as a SD-Card socket.
As I say, I started using this device as an ESP32-S3 Arduino device that just has a screen and keyboard attached. I got distracted via the following URLs:
https://www.instructables.com/T-Deck/
https://github.com/moononournation/T-Deck
https://github.com/moononournation/T-Deck/blob/main/LvglLoRaMessenger/LvglLoRaMessenger.ino
Then after setting that up in Arduino 2 IDE, deploying the app to the T-Deck it was just erroring about not being able to invoke the radio. Then I checked and I needed to install / upgrade the following library within the Arduino IDE:
https://github.com/jgromes/RadioLib
and then it all worked fine! sweet.
Then I decided to go to the OFFICIAL github repo:
https://github.com/Xinyuan-LilyGO/T-Deck/tree/master
Just like above, it requires you to copy files around in ref. to the Arduino IDE.
I couldn't get the 'UnitTest' app to compile, it complained about the last include file - y'know life's too short, I gave it 5 seconds and moved on. I did however get the basic 'Keyboard' app to compile, build, upload and could see the output in the 'Serial Monitor', that's what I was really looking to achieve.
I think it was just my fingers, but getting the device into "flash mode" or "download mode" requires pressing in the trackball, turning the switch from OFF to ON and holding the trackball for about 3-5 seconds - I think I kept letting it go too early.
After being being happy that I could compile / upload apps and they worked, I then thought I would move on over to this MESHTASTIC open-source software that I was finding all over YouTube.
Before going there...that Arduino IDE problem I mentioned earlier, let me show / explain what I was referring to (if anyone knows how to override this, let me know!)
Meshtastic
As with most things, every YouTube video / web page says, "hey use this wonderfully easy web-browser tool to download the latest firmware to your device, it's super easy". Of course it didn't work on my laptop, so I had to go about doing it the "hard / long-winded way", but by doing that I learn more!
My journey started here. Quick read of this page:
https://meshtastic.org/docs/getting-started/flashing-firmware/esp32/
Led to scrolling to the bottom of this page and downloading the required file:
https://meshtastic.org/downloads
and then onto this page:
https://meshtastic.org/docs/getting-started/flashing-firmware/esp32/cli-script
Which required me to download / install some extra Python (yeurgh!) apps
Now, down that page, for Linux it says to just run
$ esptool chip_id
of course that did not work, as you can see:
A quick apt install later... and then I can run the command:
Well, of course it was a ME issue... there's me being all anti-Python and well, here you go:
Oh look, it works...it detects the device, detects it's a SERIAL device (and not a USB device even though it is plugged into the USB cable, ho-hum) it detects the correct chip type, settings etc...
"Everything is AWESOME", as the Lego movie would sing about now.
As per the original web-page it says to run the ./device-install.sh command telling it to use the firmware file we downloaded earlier. As you can see in the output above, it does the whole detect the device cycle and it repeats about 3 uploads and reboots of the device
As we're connected to the device, we can run the meshtastic command line app and find out more about the device settings (btw - this is a cheat-peek as I set these values via the Android app, but this just demonstrates that you could set all of these values from the command-line rather than from a BLE connected phone device.... am just saying, you don't NEED a phone, it's just simpler / quicker)
As you can see there is a LOT of info there and it's all in nice sweet JSON format, I believe there is an API you can use to interact with, pretty sure it uses protobuff, so we could use Node-Red if we need to go down that road.
Appreciate that I've shared my super-secret AES256 encryption key there, but hey, y'know, like that's going to stay the same for longer than 2 days?!
Now, comes the Android phone part. Download the app from the Google Play store, or alternatives, for ease of life I just went for the Play Store, I'll do the side-load at some point to see if the app gives me more features, but for now, "just get it working" is the goal.
https://meshtastic.org/docs/software/android/installation
Once the app starts up on the Android phone, you need to setup a Bluetooth connection and pair the device. A random seeded number will be displayed on the T-Deck, just type it into the phone and job done.
Now you've done that, you'll see the device listed on the [Settings] tab page, a default name is assigned to the device. You can change it but I'm not too fussed atm. The one thing you DO NEED TO DO is to press literally on the word UNSET and select [EU_868], that will set the REGION frequency you want / need to use. As I'm in the UK (cough cough to the EU in the title, but hey-ho) that is the frequency to use and that will be the same for the other devices that we need to use, they can only "talk" to each other if they are listening/shouting at the same RF. The device does a lot of reboots - reminds me of Windows, if you know what you're doing with the CLI you can actually script everything and run it once and the device reboots once and everything is applied. If I get a lot more devices (more than 3...oh wait, yes, I'll have more than 3), then I'll write those scripts and share.
Now, from the [settings] tab you select the device from the list, you'll see the text above it do some counting about libraries and modules and some numbers, once finished it'll show a [Connected to radio (t-deck 2.2.17.dbac2b1)] message
oooo, clicking on those co-ords:
You even have a DEBUG output option too:
You can "see" what data is being sent by which part of the app - it does show the SENDMESSAGE too, which may be useful for debugging.
That means the Android phone is now connected to the T-Deck. You can do more config:
https://meshtastic.org/docs/configuration/radio/
It was at this point, funny of all funnies..I found this web page:
https://meshtastic.org/docs/hardware/devices/tdeck/
That basically walked me through the above.
As I say, I ordered another T-Deck, seems daft to only have one of them - you really NEED two of them for them to work properly.... That sounds like it will arrive in a few weeks time, as it's from AliExpress.
Until then, as mentioned I ordered the last three of these that were in stock:
They are a slightly different chipset, but they ARE ESP32 based... so the basic lora library code should work with them.
As they are ESP32 devices, I can write C code (yay!) in Arduino IDE and access the GPIO pins, that means sensors can be added / listened to and then that info. can then be transmitted as a message. Let's think of boring temp / humidity values in a greenhouse... or a seismic sensor that detects a mouse walking in the garden or a vehicle driving down a road - think massive big posh house with a nice big / long driveway, a very power hungry camera could be setup, but cameras are not the best and can be easily detected / cut off...however a nice seismic detector running on a super low power battery that can be "woken" up and send a "silent" mesh message to trigger an action, now that's more like it :-D
When they turn up, I'll see what I can do with them.
The code from here will do the basics:
https://github.com/BSFrance/BSFrance-avr/tree/master/avr/libraries/LoRa
As a total distraction I found this guy, Eric Nam on You Tube and whilst I don't see the fascination of making an API call to chatGPT, I do like the usage of the UI library: LVGL.
https://github.com/YnotZer0/ESP32Berry
Okay, so digging into the LVGL, it 100% took me back to the early 2000's using Embedded Visual C++ 3.0 (I still have the CD-Rom somewhere upstairs) for coding mobile applications onto the Compaq PDAs... you write the C code and mentally "picture" the UI in your head and then you don't actually "see" the UI until you compile, deploy and run the app. We've not moved on much in 20years have we?
Anyway, as it's so samey, I'm sure I'll adopt it as it'll be so much easier for me to hit the ground running.
What I liked about Erics repo (and why I forked it), is that he put the effort into making a nice LVGL UI for his app, personally I would have just done a black screen with green text (in fact what I did do on the M5 Stack Cardputer!), so my lesson for today is "be more like Eric".
Actually, what I liked is the fact Eric split his code up nicely into sections, not too keen on the C++ usage of classes though, that brings back memories of arguing with "Daves" in Canada at Sybase/iAnywhere and the AvantGo days about the pointlessness of making a class / object when you're only going to make 1 instance of it on a mobile device. The overhead is not worth the coding, it'll also run 25% slower.. but hey... I'm nit picking there - the nicety is the fact that he shows a nice way to CALL an external REST API from the device, just so happens he calls chatGPT, however, I want to call an internal networked REST API that happens to be connected to my own custom trained LLM....
And last but not least, with Meshtastic you can "sniff" the ATAK comms
There's a whole YouTube video on how to set it up and use it but here's the basic info:
https://meshtastic.org/docs/software/community/community-atak
https://meshtastic.org/docs/software/integrations/integrations-atak-plugin
and some more info here:
https://github.com/paulmandal/atak-forwarder
Basically you can now send CHAT messsages from within ATAK device applications and, well, go read the github repo yourself.
https://www.civtak.org/download-atak/
Now put 2 & 2 together.
UPDATES to follow.
oh, I forgot about the Arduino IDE problem.
So, yesterday when I plugged in the T-Deck it was recognised as:
[Deneyap Kart G] device
All seems good until you deploy and then it will error telling you that it is not an ESP32 S3 device.
Today, after the Meshtastic firmware update it now appears as a [TAMAC xxxx S3] device.
Again, that is NOT correct. You need to manually select the [ESP32 S3 Dev device]
These settings were valid for the LoraMessenger application
We'll come back to that later on, no doubt.
Comments
Post a Comment