The KiwiSDR 2 online store is open for orders! Please visit kiwisdr.nz

Reading signal strength from shell [option added to kiwirecorder]

Hi,

What is the easiest method to read the signal strength of a defined bandwidth/frequency from linux shell?
(easiest: least amount of programming skills required ;)
«1

Comments

  • Single reading or streaming?
  • Single reading would be ok.
    Ideal would be a single reading of the average of a few seconds.
  • jksjks
    edited April 2019
    Okay, to kiwirecorder.py in https://github.com/jks-prv/kiwiclient I have added an option "--S_meter=S_METER", where S_METER is the number of S-meter averages you want (e.g. 1, 10 etc.) After the averaging it prints a single line with the RSSI value in dBm.

    See the Makefile target "s_meter" for an example of how to run it from the command line.
    helioshWA2ZKD
  • You're awesome! Thanks a lot!
  • One thing that i noticed: It does never show power levels below -127.0 dBm, for example with narrow filters.
    But it's the same for the web interface, so it probably isn't a problem of kiwirecorder.

    The s_meter extension on the other hand does show levels below -127 dBm.
  • the 0-127 range of a single byte could be offset. I don't think 0 or -10 dBm will/can ever occur. A 10 dB offset would allow -137, with the offset removed at the client.
  • I guess I am.... I imagined that the server end would put the offset in and the html5/java that loaded out to a client could normalize it.
  • 127 is 7-bit, so you could use the extra bit to address values to -255?
    Since this is the first version of kiwiclient that can report s-meter values, a change maybe wouldn't hurt a lot. But on the other hand, I probably don't understand all consequences.

    Anyway, I'm happy that I have s-meter values now. I'm trying to log the noise floor on the ham bands. It will need some tweaking though.
  • Is it possible to extract GPS co-ordinates along with the signal strength value ?

    I'm thinking that it could be used as a drive by measurement system, and used to produce heat maps.

    An example of what I'd like to achieve is shown on this web page.

    https://www.g8jnj.net/vdsl



    Regards,

    Martin - G8JNJ
  • @heliosh how did you get that plot of the RSSI? I'm trying to use the -S-meter option to store the signal strength values in a file, but I can't figure out how. I think the issue is that by default it records the data in "/dev/null," but I tried changing this and I'm still having problems.
  • `python kiwirecorder.py -s $HOST -p $PORT -f 10000 m iq -L -5000 -H 5000 --s-meter 10`
    will return 10 S-meter averages on 10000 kHz, made in a 10 kHz passband with IQ mode
    I've had a little difficulty with the first measurement being bogus so you may want to read a single average before accruing a bunch.
  • @n6gn I’ve tried using a command like that one, only in am mode instead, and I kept getting an error that it couldn’t find the file /dev/null. Where does it store the s-meter averages, and how can I get them into a file like a .txt? I’m running from windows command prompt.
  • jksjks
    edited June 2019
    Ok, please update your copy of kiwiclient/kiwirecorder. The problem with /dev/null and Windows when using --S-meter should be fixed.

    Also, the 2.5a version of wsprdaemon is in the latest kiwiclient repo in the tools directory.
  • With Python for Windows (python37) installed, a command line of

    python kiwirecorder.py -s 10.0.0.77 -p 8074 -f 10000 m iq -L -5000 -H 5000 --s-meter 2

    returned:

    RSSI: -59.2

    Sorry, I don't use Windows much so can't help you further.
  • I just noticed, I must have had the same problem because the file \dev\null exists on the Windows10 computer I ran it on. Guess I must have created it to fix the problem. There's probably a better way...
  • @jks thanks! I don't get an error now; however, where is the RSSI data stored when I use --S-meter?
  • jksjks
    edited June 2019
    I don't know what Windows will do, but on Mac/Linux it should go to standard output and appear directly after you type the command, viz:
    python kiwirecorder.py -s www -f 1440 -L -5000 -H 5000 --s-meter 10
    RSSI:  -67.7
    
    And with a Unix shell you could redirect it to a file instead:

    python kiwirecorder.py -s www -f 1440 -m iq -L -5000 -H 5000 --s-meter 10 > s-meter_output.txt
  • Hi John,

    Any chance adding a 'streaming' version of this printing time and averaged S-meter reading to a file ?

    Best regards, Ben
  • Ben.... you can do that is your client with a simple script
  • edited June 2019
    I can confirm that Win 10 works the same as Linux.
    python kiwirecorder.py -s www -f 1440 -L -5000 -H 5000 --s-meter 10
    RSSI: -67.7
    And the single pipe command (>) overwrites the file each time:
    python kiwirecorder.py -s www -f 1440 -m iq -L -5000 -H 5000 --s-meter 10 > s-meter_output.txt
    And the double (>>) pipe command adds the RSSI reading to the text file each time:
    python kiwirecorder.py -s www -f 1440 -m iq -L -5000 -H 5000 --s-meter 10 >> s-meter_output.txt

    I tried this on Windows 10 and on my Ubuntu Desktop...
    It would be nice to have the timestamp with each RSSI reading.
    Like Heliosh I am also very interested in plotting RSSI.
    Thank you JKS. Keep going.. (-:
  • @Jimo
    you could try something in bash like
    TIMESTAMP=`date '+%F-%H:%M:%S'`
    RSSI=`python kiwirecorder.py -s www -f 1440 -L -5000 -H 5000 --s-meter 10`
    
    echo $TIMESTAMP $RSSI >>logfile.log
  • Interesting thread and could use a bit of help to create the type of plots heliosh showed by using Python.

    Just starting to learn simple programming and to speed up things I wonder if anyone would be willing to show me how to extract these averaged RSSI readings periodically and then plot these values in "real time". Any pointers are welcome.

    Thanks,
    Claire.
  • Claire... do you run Linux?
  • perhaps heliosh would share his rrdtool scripts
  • Linux.., maybe I should have started with that. At the moment only Python and I plan to use the S-meter readings for a number of Kiwi receivers in a school project about long distance communications.

    Thanks,
    Claire
  • edited July 2019
    I could, but the difficult part is not the script, but getting known to rrdtool. It's pointless if you don't understand how rrdtool works. Once you understand how rrdtool works, you're most likely better off with creating your own scripts.
    There are 3rd party tools for rrdtool that might be easier to use. I haven't tried them yet, but here's one:
    https://www.cacti.net/

    But there you go, that's how I did it:
    First you need to create a rrd (round robin database):
    https://oss.oetiker.ch/rrdtool/doc/rrdcreate.en.html

    An example for a database covering 5 years for a single band and 1 minute resolution would be:
    rrdtool create kiwi.rrd \
    --step 60 \
    DS:10m:GAUGE:120:-200:0 \
    RRA:LAST:0.5:1:2628000
    Then you can feed the database with values from kiwirecorder.py:
    https://oss.oetiker.ch/rrdtool/doc/rrdupdate.en.html
    workingdir=~/kiwiclient
    
    samplecount=15
    lowfreq=950
    highfreq=1050
    
    v10m=`$workingdir/kiwirecorder.py --nb --server-host=192.168.8.73 --server-port=8073 --freq=27999 --S-meter=$samplecount --m usb -L $lowfreq -H $highfreq |awk '{print $2}'`
    
    rrdtool update $workingdir/rrd/kiwi.rrd N:$v10m
    That has to be run every minute, for example by a cronjob.
    Note that kiwirecorder.py has sometimes random delays where it does nothing(?), so you can't use the entire minute for collecting s-meter data, but have to include some reserve time. I use max. 50% of the time but sometimes that's still not enough.

    Finally you can create the graphs.
    https://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.html
    RRDGRAPH="/usr/bin/rrdtool graph"
    WWWPATH=/var/www/rrd/kiwi
    $RRDGRAPH -v dBm/Hz $WWWPATH/kiwi-daily.png \
    --end now --start end-86400s -w 1440 -h 500 -A -E \
    DEF:v10m=kiwi.rrd:v10m:LAST:reduce=AVERAGE \
    CDEF:v10mHz=v10m,20,- \ 
    LINE2:v10mHz#0066ff:"10m"
    I have the graphs created from a php-script, so they are only created when I visit the page.
    The conversion from dBm-bandwidth to dBm/Hz could be better done at the database-update stage and not at the graph-stage as I did it.
    PowernumptyWA2ZKD
  • Many thanks, Heliosh for sharing this information and showing the the steps to set up with rrdtool. I checked its Swiss web site and as you already indicated it will take considerable time to find out how this all works.

    Because this is a one-off project and to save time I think for me it is better to try and find a way to use Python first. If that doesn't work out then I can always start to learn about rrdtool or perhaps better switch to Linux.

    Claire
  • edited July 2019
    In reading signal strength from kiwirecorder.py it's important to recognize that like the S-meter/dBm display on the console, it 'bottoms out' at -127 dBm. For common bandwidths and antennas this may not be too much of an issue e.g. the noise floor of the kiwi in a USB bandwidth is typically on the order of -122 dBm but if you have a VHF converter or LNA with a quieter antenna, perhaps near KTB, even in a 10 kHz bandwidth the noise may be well below -127 dBm.
    Thus if you have calibrated the S-meter (on the admin page), it may not read properly. The only way I've found around this problem is to "lie" to the calibration on the config page such that the returned value is always higher than -127 dBm. I discovered this while trying to measure the noise floor of a 33 dB gain LNA with terminated input. The gain ahead of the kiwi was sufficient to establish a low noise floor, near -171 dBm/1-Hz (-136 dBm in a USB bandwidth) but if properly calibrated, the returned value was always "-127".
    Interestingly, the S-meter extension does not appear to have this problem. It can report values well below this limit.
  • Is there a way to specify not to write the wav file? I am writing a program in which I either get the rssi values or the audio recording. I would just use the --s-meter option to get the rssi values, but this only returns a single averaged rssi value. What I'm currently doing is collecting the rssi values and the audio recording, then deleting the wav file if all I want is the rssi. It would be simpler if I could simply specify on the command line not to save the wav file.
  • --S-meter shouldn't write a wave file:
        --S-meter=S_METER, --s-meter=S_METER
                            Report S-meter(RSSI) value after S_METER number of
                            averages. Does not write wav data to file.
    @n6gn jks explained previously, that the addon would get the signal strength value from another source. But I can't find the message anymore.
Sign In or Register to comment.