LowPowerLab Forum

Software support => Pi Gateway => Topic started by: Kilo95 on December 19, 2017, 01:10:31 PM

Title: Node Power Level
Post by: Kilo95 on December 19, 2017, 01:10:31 PM
is there a way to have the transmit power level of the nodes reported to the gateway? I've got one node ~175 feet from the house and it shows RSSI between -89 and -100. I have ATC enabled but would like to see what the output power is. It'd be fun if it showed up like the RSSI on the gateway page.
Title: Re: Node Power Level
Post by: Felix on December 19, 2017, 01:14:13 PM
Sure, just send a new metric, and define it in metrics.js.
The transmit level is in RFM69_ATC._transmitLevel.
It was something I was thinking to add, so you can compare the transmit level vs RSSI.
Title: Re: Node Power Level
Post by: Kilo95 on December 19, 2017, 01:29:56 PM
if you were thinking of it adding it, i'll probably just wait til you get around to it.
Title: Re: Node Power Level
Post by: Felix on December 19, 2017, 01:50:41 PM
Should be very simple:

TXLV : { name:'TXLV', regexp:/\bTXLV\:(-?\d+)\b/i, value:'', duplicateInterval:3600, unit:'', pin:0, graph:1, graphValSuffix:'TXLV', graphOptions:{ legendLbl:'TXLevel', lines: { lineWidth:1 } }},

Then just read the level and send it as a new token:

TXLVL:value (should be 0 to 31).
Title: Re: Node Power Level
Post by: Kilo95 on December 19, 2017, 01:59:05 PM
i will give that a try. thanks
Title: Re: Node Power Level
Post by: Kilo95 on December 19, 2017, 02:03:50 PM
so, would it be as simple as placing:
DEBUG("   [TXLVL:");DEBUG(RFM69_ATC._transmitLevel);DEBUG("]");

right after this:
DEBUG("   [RX_RSSI:");DEBUG(radio.RSSI);DEBUG("]");

??
Title: Re: Node Power Level
Post by: Felix on December 19, 2017, 03:27:26 PM
DEBUG is for ... serial DEBUGging.
Your transmitting node needs to send that metric.
And all metrics (except the special RSSI) should be nam:value without [] or any other characters.
Title: Re: Node Power Level
Post by: LukaQ on December 20, 2017, 12:29:22 AM
Quote from: Felix on December 19, 2017, 03:27:26 PM
And all metrics (except the special RSSI) should be nam:value without [] or any other characters.
TXLVL:25
in weather node
sprintf(buffer, "BAT:%sv F:%s H:%s P:%s", BATstr, Fstr, Hstr, Pstr);

    sendLen = strlen(buffer);
    radio.sendWithRetry(GATEWAYID, buffer, sendLen, 1); //retry one time


in variable buffer you put BAT:5.02v F:53.2 H:72.4 P:28.5
then you calculate what is the length of buffer
then you send to gateway, BAT:5.02v F:53.2 H:72.4 P:28.5, and length of this buffer


On gateway itself (PI) you need to "teach it" to understand what to do with "TXLV" and you do this with

TXLV : { name:'TXLVL', regexp:/\bTXLVL\:(-?\d+)\b/i, value:'', duplicateInterval:3600, unit:'', pin:0, graph:1, graphValSuffix:'TXLV', graphOptions:{ legendLbl:'TXLevel', lines: { lineWidth:1 } }},
in userMetrics/_example.js


AND NOTE THIS: you need to send TXLV or TXLVL
It has to be one or the other (the same) on PI gateway and what is node sending
Title: Re: Node Power Level
Post by: Kilo95 on December 20, 2017, 08:51:41 AM
so all i need to change on the weathershield node is:
sprintf(buffer, "BAT:%sv F:%s H:%s P:%s", BATstr, Fstr, Hstr, Pstr);

    sendLen = strlen(buffer);
    radio.sendWithRetry(GATEWAYID, buffer, sendLen, 1); //retry one time


?? then change the metrics.js. I think I could have fumbled my way through the metrics.js work but the node would have given me trouble
Title: Re: Node Power Level
Post by: Kilo95 on December 20, 2017, 08:54:26 AM
or is this correct?
sprintf(buffer, "BAT:%sv F:%s H:%s P:%s TXLVL:%s", BATstr, Fstr, Hstr, Pstr, TXLVLstr);

    sendLen = strlen(buffer);
    radio.sendWithRetry(GATEWAYID, buffer, sendLen, 1); //retry one time
Title: Re: Node Power Level
Post by: Felix on December 20, 2017, 10:38:48 AM
Kilo95, your last piece of code should work.
You can always try it right away too ;)
Title: Re: Node Power Level
Post by: TomWS on December 20, 2017, 10:39:09 AM
You could do this...

    sendlen = sprintf(buffer, "BAT:%sv F:%s H:%s P:%s TXLVL:%s", BATstr, Fstr, Hstr, Pstr, TXLVLstr);
    radio.sendWithRetry(GATEWAYID, buffer, sendLen, 1); //retry one time


Tom
Title: Re: Node Power Level
Post by: Kilo95 on December 20, 2017, 10:50:48 AM
Quote from: Felix on December 20, 2017, 10:38:48 AM
Kilo95, your last piece of code should work.
You can always try it right away too ;)

lol. you are correct. i am at work though and won't be home until tomorrow. that's why i replied with what I hoped would work. i'll try it the next day or so. i can remote in and at least do the metrics.js file

thanks to tom too. gives me a couple of ideas to try out!
Title: Re: Node Power Level
Post by: ssmall on December 20, 2017, 10:52:03 AM
Or this...

    sendlen = sprintf(buffer, "BAT:%sv F:%s H:%s P:%s TXLVL:%i", BATstr, Fstr, Hstr, Pstr, RFM69_ATC._transmitLevel);
    radio.sendWithRetry(GATEWAYID, buffer, sendLen, 1); //retry one time

Title: Re: Node Power Level
Post by: Felix on December 21, 2017, 08:38:38 AM
On a second thought, keeping tokens as short as possible would be preferred.
So maybe a shorter metric name TXP:value rather than TXLVL? Could even be 1 letter or character (unque from other metrics) but that's less human readable.
Whatever works though..
Title: Re: Node Power Level
Post by: LukaQ on December 21, 2017, 08:50:34 AM
will this be universal for all in next build?
If so, TXP sounds ok so does TXL, short and also human readable
Title: Re: Node Power Level
Post by: Kilo95 on December 21, 2017, 07:18:34 PM
I'll try it the other way since I have it setup already on my gateway. If it doesn't work well, I'll try shortening the name. Thanks for the thought
Title: Re: Node Power Level
Post by: Felix on December 22, 2017, 01:54:38 PM
TXP would imply power, ie dBs, which is not the case. It's just a range of levels which translate to different dBs depending if it's a W/CW or HW/HCW.
I would keep TXL. The metric description/legend can elaborate.
Either way it's customizable if one really wants that, this is just my own preference.
Title: Re: Node Power Level
Post by: Kilo95 on December 22, 2017, 03:07:55 PM
is there a chart somewhere with the conversions for TXL to dbm? i vaguely remember seeing it somewhere. i'll have some time this next week to work on fixing the code for the nodes. i was able to remote into my RPi the other day to fix the metrics.js. i'll update when i get it done
Title: Re: Node Power Level
Post by: Kilo95 on December 22, 2017, 09:31:36 PM
I tried the last piece of code I suggested but when I compile it says it's not declared. I assume that means I need to tie it to rfm69atc file. How do I do that?
Title: Re: Node Power Level
Post by: Felix on December 26, 2017, 03:04:46 PM
What's not declared?

#import <RFM69ATC.h>