Taranis Q X7 OpenTX Battery Capacity Remaining Lua Script

RCdiy

RCdiy
Taranis Q X7 OpenTX Battery Capacity Remaining Lua Script
http://rcdiy.ca/battery-capacity-remaining/
https://youtu.be/AeMpwOn516s

The battery capacity remaining script was taken by a user, improved, and sent back to me to share with the community. This is what open source is all about!

Besides battery capacity remaining based on mAh we now have the option to use the script with just a voltage sensor. We also have some cool and silly sound effects when you allow your battery to run down too low :)

Check out the blog post and video.

Stay Safe & Have Fun
 
Last edited:

BladeScraper

New member
Hey man, tried this on my Q X7 but unfortunately it doesn't seem to work with the newest version of OpenTX (2.2). I get a

"Script syntax error
TELEMETRY/mAhRe2.lua:7 unexpected symbol near <"

That, or I'm doing something wrong. Not sure what. Not new to OpenTX but this is my first time trying a Lua.
 
Last edited:

RCdiy

RCdiy
Untitled.png
 

BladeScraper

New member
Oh... no. I just downloaded the Zip that contained everything.

Weirdly, I did what you suggested, and now it works :)

Could you explain why? It was mAhRe2.lua in the Zip, but the contents are totally different from the one when downloading the way you show. (Looking at it with Lua editor).
 

BladeScraper

New member
I should have mentioned - I apologize for not. I am using the 150A Hall effect sensor, not the 40A one with VFAS. So I went to the Lua and disabled the voltage sensor. All is well in that regard and it&#8217;s no longer on the screen when the script is running.

However for some reason, while both real-time current and max current are working, I do not get mAh consumption and thus mAh remaining is not changing. Is there any reason because of the sensor I am using that would cause that? I knew it was designed for a different sensor but I knew that they were probably similar enough (since they both put Amps on the same Telemetry sensor in OpenTX, Curr) that it should at least work with current and mAh. Am I wrong to assume that?
 
Last edited:

BladeScraper

New member
I apologize once again - I should do more research before I ask a stupid question :rolleyes:

Realized that I needed to create the sensors for mAh consumed in the Taranis.... works perfectly now :)
 

RCdiy

RCdiy
Wonderful:)
I checked and the zip file does not have the lua script. I've kept it separate so that tracking code changes is easier.
 

tazmana

New member
hello , first of alll thank you very much for the very useful script. I have some problems while making it work. i am using only the frsky 150a hall sensor. i deactivated vfas by writing

local VoltageSensor = "" -- optional set to "" to ignore
local mAhSensor = "Cons" -- optional set to "" to ignore

and i changed the following and make true


local WriteGVBatRemmAh = true -- set to true to turn off write
local WriteGVBatRemPer = true

and from flight mode page FM0 i put GV7 22 for 2200 battery

Everything is ok till here ,i can see the flight battery monitor page
At this page i see
curr and max correctly
but i couldnt see the change in the Cons and Remaining section
Cons 0mah and remaining 1760 80% always seen but do not change after some consumption.
Also in the main screen 1760mah and 80% always seen but do not change.


if you can help me i will be very happy. Sorry i am very new in lua scripts maybe i do something wrong which is very easy.
 
Last edited:

19wema48

New member
Taranis Q X7 OpenTX Battery Capacity Remaining Lua Script
http://rcdiy.ca/battery-capacity-remaining/

The battery capacity remaining script was taken by a user, improved, and sent back to me to share with the community. This is what open source is all about!

Besides battery capacity remaining based on mAh we now have the option to use the script with just a voltage sensor. We also have some cool and silly sound effects when you allow your battery to run down too low :)

Check out the blog post and video.

Stay Safe & Have Fun

Hi,
is there a version for HORUS? I use the 40A sensor.
Thanks Max
 

OLderDan

New member
DAMN YOU DAMN YOU!!! I have had this script on my tx for ages and recently decided to try it again when I discovered... DAMN YOU!!! the soundfiles played at zero, DAMN YOU!!! First I thought my 2way was bleeding into the qx7 speaker, then I thought it had a virus, then when I listened (and finished laughing my merry ass off) I realised I will more scrupulously check the files I install on my tx in future. Brilliant sense of humour and very very much appreciated.
 

yoman54

New member
Taranis Q X7 OpenTX Battery Capacity Remaining Lua Script
http://rcdiy.ca/battery-capacity-remaining/

The battery capacity remaining script was taken by a user, improved, and sent back to me to share with the community. This is what open source is all about!

Besides battery capacity remaining based on mAh we now have the option to use the script with just a voltage sensor. We also have some cool and silly sound effects when you allow your battery to run down too low :)

Check out the blog post and video.

Restez en sécurité et amusez-vous [/ QUOTE]

Bonjour a tous

Je suis français et donc pas très a l'aise avec l'anglais donc traduction google
Je suis en train de tester le script lua " capacité restante de la batterie" lua avec un capteur de courant FrSky FAS100S , j'ai bien téléchargé le fichier lua mahRe2.lua ainsi que les sons , bien installés ceux ci sur la carte SD de ma taranis X9D+ dans le répertoire SCRIPTS/TELEMETRY/mahRe2 pour les sons et SCRIPTS/TELEMETRY/mahRe2.lua pour le script.
J'ai bien renseigné la Variable Global 7 ( GV7 ) en " mAh " et " 50 " ( batterie de 5000 mAH), j'ai fait la découverte de nouveaux capteurs sur ma radio, ajouté le nouveau capteur comme décrit dans la vidéo ( mAh ) et avec tout ça, cela ne fonctionne pas.
Je ne sais plus quoi faire.
Merci de m'expliquer ce qui ne va pas

Salutations
Lionel


Good morning all
I am French and therefore not very comfortable with English so google translation
I am testing the lua script "remaining battery capacity" lua with a FrSky FAS100S current sensor, I have downloaded the lua mahRe2.lua file as well as the sounds, correctly installed these on the SD card of my taranis X9D + in the directory SCRIPTS / TELEMETRY / mahRe2 for the sounds and SCRIPTS / TELEMETRY / mahRe2.lua for the script.
I have correctly informed the Variable Global 7 (GV7) in "mAh" and "50" (5000 mAH battery), I have discovered new sensors on my radio, added the new sensor as described in the video ( mAh) and with all that it doesn't work.
I do not know what to do.


Please explain to me what is wrong
Greetings

Lionel
 

bartokwhite

New member
HI,
This is the most useful script I've seen for ages. I've successfully installed it on my Taranis X9D Plus, using the LAS100S 100A current sensor. It's all working well. What's more, I'm using it on a one sixth scale model tank with a 24V 20ah LiFePO4 battery. All it needed was a change to the line “local GVBatCap = GV7…” etc, I edited the two examples to read “80 for 8000” and “220 for 22000”. In GV7, I entered 20. The script displays in mAh but that's not a problem. I do have one issue though for which I'd be really grateful for help. Unlike with model aircraft, which tend to do one continuous flight per battery charge, with model tanks, you may run it many times between charges. Would it be possible to configure the script and setup in OpenTX to maintain a cumulative calculation over several running sessions between charges? Could it be done by reading the values written by the previous run, if write is enabled? Really grateful if you can help, it would open up your really useful script by a whole new community of users. Thanks so much.
IMG_0982.jpg
 

bartokwhite

New member
Further to my last post above, by enabling write of remaining battery capacity, it seems to be possible for the value to persist after switching off the rx. When it is switched off, GV8 and 9 revert to the value generated by GV7, ie the script is overwriting the data. However, when the rx is switched on again and telemetry restored, the previous values are enabled. This is exactly what I was looking for to achieve a cumulative total over several “flights” before recharging. There is however a problem: if the tx is switched off, the cumulative values are lost, irrecoverably. This isn’t a viable solution as both rx and tx need to be switched off between runs. I’ve looked at the script but not indentified if there is a way to prevent the it overwriting the current values when the telemetry is lost or switched off together with the TX. Is there a way of making the cumulative totals of mAh used and mAh remaining persistent, until reset when the battery is recharged? Thanks in anticipation.
 

jax2000

New member
I am having the same issue as Tazmana, ie, the capacity is not changing. It was set to 'true' in the script, so could use suggestions how to fix. It is a neat little script if it worked.