What sensor ID should I use?

openTx has introduced a range of new features, ideas and bling. It is fast becoming the firmware of choice for many users. openTx will run on ALL current hardware platforms, including the gruvin9x and sky9x boards. Work has already started to support the new FrSky X9D radio!
Post Reply
azaz44
Posts: 5
Joined: Mon Oct 01, 2018 8:48 am
Country: -

What sensor ID should I use?

Post by azaz44 » Mon Oct 01, 2018 8:58 am

I just registered to this forum, so let me welcome everybody first.

I'm developing a LUA script for OpenTX which sets a bunch of telemetry coutners related to the battery pack connected to a model. These are things like pack capacity, pack discharge rate, voltage, name etc.

Code: Select all

setTelemetryValue
works perfectly fine.

However I'm not sure what should I use as sensorId, subId, instance. It seems any numbers do. Should I use some "proper" numbers? Do I risk some conflict there?

The other things is - I figured out how to send text over telemetry and it works. However it's limited to 4 characters. Is it maximum limit, or is there anything I didn't discover yet?

User avatar
Kilrah
Posts: 9666
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: What sensor ID should I use?

Post by Kilrah » Mon Oct 01, 2018 9:06 am

IDs for DIY use should be between 0x5100 and 0x52FF. There isn't really any coordination in that range so it's not impossible you get a conflict with another DIY sensor but at least there is none with official sensors.

Instance doesn't matter, if anything maybe use the same as what you get from the physical sensor.

S-port packets contain 4 bytes of user data so if you want to send more you need to split that across multiple packets. You can also transmit a 5th byte per packet in the 2nd byte of the streaming ID (0x50xx).

azaz44
Posts: 5
Joined: Mon Oct 01, 2018 8:48 am
Country: -

Re: What sensor ID should I use?

Post by azaz44 » Mon Oct 01, 2018 1:08 pm

Thanks, this helps.

As for instance.. If I have data - let's say pack capacity - for two packs (ie. for two 6s packs connected to make for 12s power system), would this be a thing for an instance? So same sensorId, subId, but different instance?

Also - the subId. If I have multiple data about the pack (capacity, voltage, number of cells...) am I better off having same sensorId for them but different subId? It looks like I would reserve just one sensonId this way, but I'm not sure what was the intention of subId.

EDIT: just figured out that subId is 0..7 range which is not enough in my case..

User avatar
Kilrah
Posts: 9666
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: What sensor ID should I use?

Post by Kilrah » Mon Oct 01, 2018 3:46 pm

The way the protocol is defined is the last nibble being used for multiple instances of the same value type. E.g. 0x51XY
X would be type (current, voltage, ...) and Y "voltage 1, voltage 2, voltage 3"...
You can also use instance since it's kind of irrelevant when setting things from lua, but be careful to stay within the allowed values.

azaz44
Posts: 5
Joined: Mon Oct 01, 2018 8:48 am
Country: -

Re: What sensor ID should I use?

Post by azaz44 » Wed Oct 03, 2018 12:59 pm

Thanks, all of this helps greatly..


azaz44
Posts: 5
Joined: Mon Oct 01, 2018 8:48 am
Country: -

Re: What sensor ID should I use?

Post by azaz44 » Fri Oct 12, 2018 1:46 pm

I have more questions, let me reuse same thread.

1) If I send telemetry data with UNITS_SECONDS, I get the value displayed properly, but the unit is "|Or" (see screenshots). What does this mean?
Capture1.PNG
Capture1.PNG (10.63 KiB) Viewed 89 times
Capture2.PNG
2) How could I encode data to send UNITS_DATETIME over telemetry? I have a table obtained by getDateTime().

Post Reply

Return to “openTx”