# Script to get RSRP and then do...

**URL:** <https://forum.mikrotik.com/t/script-to-get-rsrp-and-then-do/132259>\
**Category:** Scripting\
**Created:** [August 11, 2019, 5:32am UTC](https://forum.mikrotik.com/t/script-to-get-rsrp-and-then-do/132259 "2019-08-11T05:32:13Z")\
**Posts on this page:** 11\
**Page:** 2

<div class="post-metadata">

**Author:** ![krafg](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/krafg/32/1518_2.png) [@krafg](https://forum.mikrotik.com/u/krafg)\
**Post date:** [August 31, 2019, 4:43pm UTC](https://forum.mikrotik.com/t/script-to-get-rsrp-and-then-do/132259/21 "2019-08-31T16:43:05Z")

</div>

**@Jotne**

Sorry for paste here the script without using tab. For the next time I will have it present. I have Notepad++ and I understand it that you mean. I copied so because I test the codes that I write on terminal an the tab makes that on the terminal shows the available commands to insert by way of help. Anyway thanks.

About the function, more or less I understand the concept, but I not know how to do it.

Regards.

---

<div class="post-metadata">

**Author:** ![SiB](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/sib/32/1144_2.png) [@SiB](https://forum.mikrotik.com/u/SiB)\
**Post date:** [August 31, 2019, 4:55pm UTC](https://forum.mikrotik.com/t/script-to-get-rsrp-and-then-do/132259/22 "2019-08-31T16:55:14Z")

</div>

> [@](#):
>
> Sorry for paste here the script without using tab. For the next time I will have it present. I have Notepad++ and I understand it that you mean.

In notepad++ you can select few lines and press TAB to create a tab-in-many-row-at-once and SHIFT+TAB to reduce tabs in selected row. Easy.

> About the function, more or less I understand the concept, but I not know how to do it.

**It’s done by me**. It must be done after doing that big/long code by you. Read one post up. Final code in red “Next Release Candidate and yes, your code have now 20 lines”.

---

<div class="post-metadata">

**Author:** ![Jotne](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/jotne/32/56097_2.png) [@Jotne](https://forum.mikrotik.com/u/Jotne)\
**Post date:** [August 31, 2019, 6:17pm UTC](https://forum.mikrotik.com/t/script-to-get-rsrp-and-then-do/132259/23 "2019-08-31T18:17:45Z")

</div>

> [@](#):
>
> In notepad++ you can select few lines and press TAB to create a tab-in-many-row-at-once and SHIFT+TAB to reduce tabs in selected row. Easy.

Did not know. Good tips.

---

<div class="post-metadata">

**Author:** ![SiB](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/sib/32/1144_2.png) [@SiB](https://forum.mikrotik.com/u/SiB)\
**Post date:** [August 31, 2019, 6:24pm UTC](https://forum.mikrotik.com/t/script-to-get-rsrp-and-then-do/132259/24 "2019-08-31T18:24:19Z")

</div>

> [@](#):
>
> Did not know. Good tips.

More importand it’s this one: Settings → Preferences → Language → Tab Settings → Tab size: 2 + [v] Replace by space.  
Now you works at 2 spaces. ROS code are cool.  
Of course add plugin with Syntax .rsc file must be added as must be.

---

<div class="post-metadata">

**Author:** ![krafg](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/krafg/32/1518_2.png) [@krafg](https://forum.mikrotik.com/u/krafg)\
**Post date:** [August 31, 2019, 7:24pm UTC](https://forum.mikrotik.com/t/script-to-get-rsrp-and-then-do/132259/25 "2019-08-31T19:24:26Z")

</div>

**@SiB**  
It’s good idea separate log info on 2 sections, but I think that in my Syslog server anyway will shows all the logs duplicated.

About executing the script every 1 second, I think that is better too, because I have problems with the startup of the script using on “Start Time” as “startup” when my routerboard boot up. Then, I think that this can solve my problem. Simply I set a new Scheduler with “Start Date” = 01/Jan/2019, “Start Time”= 00:00:00, “Interval”= 00:00:01 and “On event”=(The name of the script)

I tested your “_Red Release Candidate Code_” and works well. It’s **insanely optimized** for me. The only thing now is how can I do to that this can works when my routerboard boots up. I not know if this part is already done or not.

Thanks a lot for your support and the tips with Notepad++. 😃

Regards.

---

<div class="post-metadata">

**Author:** ![SiB](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/sib/32/1144_2.png) [@SiB](https://forum.mikrotik.com/u/SiB)\
**Post date:** [August 31, 2019, 8:00pm UTC](https://forum.mikrotik.com/t/script-to-get-rsrp-and-then-do/132259/26 "2019-08-31T20:00:04Z")

</div>

> [@](#):
>
> but I think that in my Syslog server anyway will shows all the logs duplicated.

If you have LogAction not type=memory but type=remote and you send MikroTik logs to remote SYSLOG server then it’s case for his storage etc.  
If you send it to The Dude, the same.  
If you say Syslog as MikroTik logs then it’s not problem, you have this Lines=100 as default but I always change it to 1000 or more.  
RMB on WinBox bar and you can add a memory monitoring etc.  
 ![Screenshot_10.jpg](https://data-discourse.cdn.mikrotik.com/original/3X/b/4/b4b60cee93b7a98b52d0b08b6e4bfae26b5f3701.jpeg)  
If you say you have duplication in this two sections that measn you not finish my howto and the default \>\>topics=info type=memory\<\< still have not exclude rule the “!system”. Look at screenshot again.  
.  
.

> About executing the script every 1 second, I think that is better too

Perfect  
.  
.

> I have problems with the startup of the script using on “Start Time” as “startup” when my routerboard boot up. Then, I think that this can solve my problem. Simply I set a new Scheduler with “Start Date” = 01/Jan/2019, “Start Time”= 00:00:00, “Interval”= 00:00:01 and “On event”=(The name of the script)  
> The only thing now is how can I do to that this can works when my routerboard boots up. I not know if this part is already done or not.

This is common. Script is running as other user, \*sys who haven’t possibility to create global variable and few other limitation.  
You can add this:

```plaintext
"start-time=startup on-event"=(delay 20s; /system script run "The name of the script")

```

. The script itself must have this enable to other user’s like \*sys can executed it. This one:  
 ![Screenshot_11.jpg](https://data-discourse.cdn.mikrotik.com/original/3X/a/c/ac42c2dfd0a20ee9a2abd207b239f813c628bce1.jpeg)  
This way you wait until MikroTik stop booting process. At least minimum 10s ← important. Next you run your script who start at proper user and will be works after every boot. I use this method to send e-mail with subject=([/system identity get name]." RePowerOn !") - very usefull notification on power loose in branches.  
.  
.

> I tested your \> "\> _Red Release Candidate Code_\> " \> and works well. It’s \> **insanely optimized** \> for me.

2 beers, 6h and very big happiness at the end that I can do it :). You welcome. All knowledge are written [here](http://forum.mikrotik.com/t/passing-variables-to-functions/132691/1) as Step by Step to know function tricks.  
.  
.

> Thanks a lot for your support and the tips with Notepad++. 😃  
> Regards.

You welcome. Select proper post as solution.

---

<div class="post-metadata">

**Author:** ![krafg](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/krafg/32/1518_2.png) [@krafg](https://forum.mikrotik.com/u/krafg)\
**Post date:** [September 1, 2019, 1:24am UTC](https://forum.mikrotik.com/t/script-to-get-rsrp-and-then-do/132259/27 "2019-09-01T01:24:24Z")

</div>

I put a delay of 40 seconds on scheduler and finally starts OK at boot up!

Now I’m going to check the part of logs.

Many thanks and regards.

Edit:

New code on scheduler:

```plaintext
:global lte1 false
/system leds set 1 leds=led1,led2,led3,led4,led5 type=off
:while ($lte1=false) do={
	do {
		:global interface1 [/interface get [find type=lte name=lte1] name]
		:if ($interface1 = "lte1") do={
			:put "LTE1 is now present"
			:global lte1 true
		}
	} on-error={
		:put "LTE1 is not present"
		:delay 500ms
	}
}
/system script run "RSRP"

```

It is more precise and secure than simply put a delay.

Now I understand because why simply putting the name of my script in my scheduler it not keeps running. The thing is when in the script try to get RSRP of “lte1” at startup, it returns “no such item” and the script brakes. It occurs because after that routerboard finish his boot, LTE interface keeps booting and take some seconds until all booted up. Now on scheduler, first I check that the LTE interface finish his boot with a “While” and already when boot finish, it runs the script.

With “delay” option if I set it on 20 seconds, the script not runs, but when I setted to 40 seconds, it runs because 40 seconds was enough to wait that LTE interface finish his boot and the script find the item “lte1”.

On the other hand, I not knew that can put codes on scheduler, it was very usefull for me. Thanks! I’m newly starting with scripting and I’m newbe on these things.

Regards.

---

<div class="post-metadata">

**Author:** ![krafg](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/krafg/32/1518_2.png) [@krafg](https://forum.mikrotik.com/u/krafg)\
**Post date:** [September 1, 2019, 8:29am UTC](https://forum.mikrotik.com/t/script-to-get-rsrp-and-then-do/132259/28 "2019-09-01T08:29:40Z")

</div>

**@SiB**

I see that when I change from LTE to 3G, the leds keeps on. With my code, leds turn off because RSRP value is not longer available and RSSI is the new parameter for signal.

When I program the scheduler to run a script every 1 second, the sector writes increases every second. I not know why. Anyway with the last code that I post for scheduler, now the script starts correctly.

I yet have pending the logs section.

---

<div class="post-metadata">

**Author:** ![SiB](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/sib/32/1144_2.png) [@SiB](https://forum.mikrotik.com/u/SiB)\
**Post date:** [September 1, 2019, 11:21am UTC](https://forum.mikrotik.com/t/script-to-get-rsrp-and-then-do/132259/29 "2019-09-01T11:21:40Z")

</div>

The scheduler can use a own script code - and this is perfect for many stuff. Your code is more and more mature 🙂  
On similar topic the @intensex use those lines of code ( change it to show the idea..)

```plaintext
:local Info [/interface lte info [find name="lte1"] once as-value]
:local isRsrp ($Info->"rsrp") ; :local isRssi ($Info->"rssi")
:if ($simSlot="up") do={ :if ($isRsrp<-105 | $isRssi<-110) do={

```

Reason is the same, when LTE is not connectet but 4G works then not Rsrp but rssi works.  
I’m not sure that just those change will be fine in your schema

```plaintext
-if ($LteRsrp >= -80) do={set $LedsCurrent [$ControlLed 5 led1,led2,led3,led4,led5 on $LedsCurrent] };
+if ($LteRsrp >= -80 | $LteRssi >= -60) do={set $LedsCurrent [$ControlLed 5 led1,led2,led3,led4,led5 on $LedsCurrent] };

```

because we should check if connection is lte \> rsrp or not\_lte \> rssi and then run function. To do that you must provide me info from:

```plaintext
# Check this when LTE not work
put [/interface lte info [find name="lte1"] once as-value]->"rsrp")
put [typeof [/interface lte info [find name="lte1"] once as-value]->"rsrp")]

```

means when LTE is connected then we from -\>rsrp receive value but when 4G then what we receive ?? Please check and publish.

And you should create new own assumptions like before:  
.

> Now with the variable rsrp1 that is the signal strengh I need the following:
> 
> Between -120 and -111 only led1 on.  
> Between -110 and -101 led1 and led2 on.  
> Between -100 and -91 led1, led2 and led3 on.  
> Between -90 and -81 led1, led2, led3 and led4 on.  
> major and equal that -80 the 5 leds on.
> 
> If none on these condisions are true, set 5 leds off.

P.S. I hope at the end you create a 10s movie and past it as gif/movie at some portal to share results 😃

---

<div class="post-metadata">

**Author:** ![SiB](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/sib/32/1144_2.png) [@SiB](https://forum.mikrotik.com/u/SiB)\
**Post date:** [September 1, 2019, 5:52pm UTC](https://forum.mikrotik.com/t/script-to-get-rsrp-and-then-do/132259/30 "2019-09-01T17:52:10Z")

</div>

About Band and speeds. If your are in City then this post is not important and stuff with signal on LEDs are only good addiction to it.

I have the only one Tower from get UMTS(HSPA+) Band 8 (900Mhz) and LTE Band B3(1800Mhz) + B8(900Mhz). All antennas are at the same tower with distance 3km from me.  
I use RB751 with USB LTE E3272 with custom firmware that I can select the Band and technology to connect. I have using the external antenna directed to this tower. This E3272 is in router mode that way RB is only dhcp client of it.  
.

```plaintext
Aero 2 (26017) 14154 2 3623426 = LTE1800 B3 FDD
  0/5 RSRP -116(-119|-116) RSSI -81 RSRQ -14(-18|-14) SIND -2(-6|-1)
  5x Speedtest.net (min-max): 100-440ms DL: 4,4-7Mbps Ul: 0,5-0,65Mbps

Aero 2 (26017) 14154 12 3623436 = LTE900 B8 FDD
  1/5 RSRP -99(-100|-99) RSSI -73 RSRQ -10,1(-14|-8) SIND +3(+2|+6)
  5x Speedtest.net: 20-40ms DL: 0,97-3,9Mbps Ul: 2,8-4,3Mbps

Plus (26001) 1151 62715 75494651 = LTE1800 B3 FDD
  5/5 RSSI -75(-83|-60) RSCP -84(-91|-60) EcIo -6(-15|-7)
  5x Speedtest.net: 36-64ms DL: 3,2-6,2Mbps Ul: 1,9-2,2Mbps

```

.  
Those represent the LTE/UMTS data, signal parameter’s and [speedtest.net](http://speedtest.net).  
You can see I have signal 5/5 bar at HSPA+ 4/2Mb but at LTE I must change Band to have fast download or fast upload.

The most important case is if you not setup step-by-step by individual all this band then you not determine his property like speed.  
I know what every band represented and can change it to situation.

I have other operator what have 0,5km antenna from me but he not giving a public IP and internet is with limit on GB with big slowdown after reaching this limit, it’s worst then old one V.92 56K fax-modem. Current operator give me 100GB and after reach it (every mount I reach it 🙂 ) then limit me to 10/10Mbps but I must have at LTE Band, not UMTS.  
Sometimes I use All band with LTE-\>UMTS selection but by Huawei WebAPI the MikroTik reach current band/technotogy and send me e-mail if this change in 3 minute time.  
In future I change location of external antenna. I plan use ESP8266 to auto-change direction of antenna and two USB LTE modem with own switch them or active USB switch and maybe I reach both at the same time. This is completely other stuff :).

At MikroTik R11e-LTE you cannot directly select the band but you can:

```plaintext
/interface lte cell-monitor lte1
# PHY-CELLID:374 | BAND:B3 | EARFCN:1300
# https://wiki.mikrotik.com/wiki/Manual:Interface/LTE#Using_Cell_lock -> <band> Not in use, leave this blank.
/interface lte at-chat lte1 input="AT*Cell=2,3,,1300,374"

```

As you see by last two parameters you can select the same stuff like band by selecting physical antenna at your tower.

---

<div class="post-metadata">

**Author:** ![hulitolku](https://forum.mikrotik.com/letter_avatar/hulitolku/32/6_449c533f586939b6e5f246632a46421f.png) [@hulitolku](https://forum.mikrotik.com/u/hulitolku)\
**Post date:** [June 25, 2023, 1:45pm UTC](https://forum.mikrotik.com/t/script-to-get-rsrp-and-then-do/132259/31 "2023-06-25T13:45:20Z")

</div>

> [@gotsprings](#):
>
> I found this code that “captures the value” and sends to logs:
> 
> ```plaintext
> /interface lte info lte1 once do={
> :log info "RSRP:= $"rsrp""}
> 
> ```
> 
> The problem is that I not want flood the log of my device with the value of the signal strengh.
> 
> Regards.

it not work on ros 7.11  
this work:

```plaintext
/interface/lte/monitor lte1 once do={:log info "SINR:= $"sinr""}

```

[Previous page](https://forum.mikrotik.com/t/script-to-get-rsrp-and-then-do/132259.md?page=1)
