• Effective immediately we will be deleting, without notice, any negative threads or posts that deal with the use of encryption and streaming of scanner audio.

    We've noticed a huge increase in rants and negative posts that revolve around agencies going to encryption due to the broadcasting of scanner audio on the internet. It's now worn out and continues to be the same recycled rants. These rants hijack the threads and derail the conversation. They no longer have a place anywhere on this forum other than in the designated threads in the Rants forum in the Tavern.

    If you violate these guidelines your post will be deleted without notice and an infraction will be issued. We are not against discussion of this issue. You just need to do it in the right place. For example:
    https://forums.radioreference.com/rants/224104-official-thread-live-audio-feeds-scanners-wait-encryption.html

TwoToneDetect TwoToneDetect on a Raspberry Pi - How To

estone4009

Newbie
Premium Subscriber
Joined
May 11, 2016
Messages
1
Location
Philpot, KY
I finally seem to have a working TTD setup. Issue is that if TTD is left running all day the audio level creeps up for some reason. The scanner is not being touched and I am using one of the cheap USB sound cards input into the microphone port. I adjust the squelch level in TTD but it creeps up more. Once I restart TTD it resets and is good again. Should I be restarting TTD every few hours or did I miss something in the setup?
 
Joined
Jul 30, 2014
Messages
8
I setup TTD70 on a Pi 2b, using Raspbian stretch light. It's working when manually launched, but for the life of me, i can't figure out what i'm doing wrong to launch it at startup, or re-launch using a cron job.

i'm using the following in a start-ttd.sh script:

screen -dmS ttd PULSE_SOURCE=alsa_input.usb-0d8c_USB_PnP_Sound_Device-00.analog-mono python TwoToneDetect70.pyc
 

DC31

Member
Premium Subscriber
Joined
Feb 19, 2011
Messages
1,056
Location
Massachusetts
Recently, I have found that screen does not start when specifying the PULSE_SOURCE evironment variable. I don’t know what may have changed.

Have you tried the screen command without that portion?
screen -dmS ttd python TwoToneDetect70.pyc
Does that launch ttd using the default audio card?

Going right back to basics:
1. You have installed screen? Sudo apt install screen
2. You are running the command from within the directory that contains TwoToneDetect70.pyc?
3. Are you getting any error message?
4. The above command starts screen in a detached window. Screen-list will show what is running.

Tmux is another similar command to screen. Install it and give it a try. I haven’t worked out how to make it start at boot using tmux.
 

JH49

Member
Joined
Jun 22, 2016
Messages
7
To get Screen to work with PULSE_SOURCE I went with 2 bash files to get it working.

I call the launch.sh from cron job and the launch.sh calls startTTD.sh if TTD is not running.
 

Attachments

Joined
Jan 2, 2016
Messages
10
Total pi newb here. I’m looking to get TTD to run at startup. I’ve read thru a lot of the comments and there’s attachments that are supposed to accomplish it but it seems like everyone of them has a comment afterwards stating something isn’t working.

I’m looking to write the programming myself so I can learn as I do it. Looking at all the ways to have a program run on startup it looks like systemd would work best. Has anyone successfully used systemd for this purpose?
 

DC31

Member
Premium Subscriber
Joined
Feb 19, 2011
Messages
1,056
Location
Massachusetts
Create a /home/pi/.config/autostart directory

Create a file in that directory named twotone.desktop

Paste this text into that file:

[Desktop Entry]
Version=1.0
Name=TTD
Exec=/bin/sh -c "sleep 20; cd /home/pi/TTD ; python TwoToneDetect70.py"
Terminal=false
Type=Application
X-GNOME-Autostart-Phase=Initialization
NotShowIn=KDE;

That is what works for me. Of course, make sure your path to the python file in the exec line is correct for your installation.
 
Joined
Jan 2, 2016
Messages
10
Create a /home/pi/.config/autostart directory

Create a file in that directory named twotone.desktop

Paste this text into that file:

[Desktop Entry]
Version=1.0
Name=TTD
Exec=/bin/sh -c "sleep 20; cd /home/pi/TTD ; python TwoToneDetect70.py"
Terminal=false
Type=Application
X-GNOME-Autostart-Phase=Initialization
NotShowIn=KDE;

That is what works for me. Of course, make sure your path to the python file in the exec line is correct for your installation.
I followed your previous posts on the subject. Like squirrel I had to replace the Exec line “python TwoToneDetect70.py” with “./TwoToneDetect70”

I still struggled with the whole process. Here’s what I learned
1. .config is a hidden folder. You have to select view hidden folders in the file browser or type the file path in the file browser
2. For some reason I thought writing the .desktop files in nano was what should be done. Neither file ran on reboot using nano to create the files. Instead I created two blank files in autostart with a .txt then edited them and saved as .desktop
3. I also added a reboot command to crontab so that the pi will reboot every night. For whatever reason TTD’s audio input maxes out every once in a while making a reboot or restart of TTD necessary.

Maybe later on today I’ll consolidate all the info into one post to help others like myself get TTD and pi playing nice together
 
Joined
Jan 2, 2016
Messages
10
Here it is

Steps I took to get TTD running headless on Rasperry Pi

Here’s the hardware I’m using.
CanaKit Raspberry Pi 3 Kit with Clear Case and 2.5A Power Supply https://www.amazon.com/dp/B01C6EQNNK/ref=cm_sw_r_cp_api_i_DStHCb21ZF3TE
DSYJ 7.1 Channel USB External Sound Card Audio Adapter https://www.amazon.com/dp/B0027EMHM6/ref=cm_sw_r_cp_api_i_ZStHCbWFTQG0N
AmazonBasics 3.5mm Male to Male Stereo Audio Aux Cable - 4 Feet (1.2 Meters) https://www.amazon.com/dp/B00NO73MUQ/ref=cm_sw_r_cp_api_i_iTtHCbYTF2FYJ
SanDisk 16GB Ultra microSDXC UHS-I Memory Card with Adapter - 98MB/s, C10, U1, Full HD, A1, Micro SD Card - SDSQUAR-016G-GN6MA https://www.amazon.com/dp/B073K14CVB/ref=cm_sw_r_cp_api_i_MTtHCbGHR8CBW
6FT Premium Gold Plated HDMI Cable With Audio & Ethernet Return Channel, v 1.4, 1080P FHD, Compatible with TV, DVD, PS4, XBOX, Bluray (6FT, Black) https://www.amazon.com/dp/B07B9JKHSK/ref=cm_sw_r_cp_api_i_hUtHCbV0PHZKV
I already had a Bearcat BC75 handheld scanner that I decided to use for this project. I hear a cheap Baofeng radio with a 3.5mm to 2.5mm audio cable adapter works well.
All in I paid $69.11 +tax

For the initial install I followed the instructions on TTD’s website http://www.twotonedetect.net/twotonedetect-on-a-raspberry-pi/ and installed NOOBS as the operating system from here https://www.raspberrypi.org/downloads/


Once I had it all installed and running I used http://jbuchbinder.com/apps/qv-tones/index.html to generate tones to test my setup. To do this I simply plugged the audio cable into my iphone, turned the volume down to about 1/4-1/2on the phone, and played the tones.


When I was happy that I had everything running correctly I started searching for a way to make it all work headless (without a monitor). The first step was installing realVNC on the pi. This allows you to remote into the pi from another device. Here’s a link to the instructions for getting it running on your pi and whatever device you will use to remote in https://www.realvnc.com/en/raspberrypi/


Then I started searching this thread for how to make the programs start when the pi boots up. I settled on DC31’s method after trying a few of my own with no luck. I’m going to rehash his instructions with a few additions for the totally clueless like myself.

The first step is to get Pulse Audio Volume Control and TTD to start at boot up and to have Pulse Audio Volume Control start before TTD. Here is DC31’s instructions for that with a few of my own added in. Keep in mind this is for a system based on the OS and install methods mentioned above.

Create a /home/pi/.config/autostart directory

  1. This directory already exists on the setup I’ve described.
  2. Click the file browser at the top left of the desktop.
  3. Open the pi folder.
  4. Click VIEW at the top of the file browser and click show hidden.
  5. Navigate to the autostart folder
  6. Click file, create empty file, and create a file named “twotone.txt”
  7. Repeat step 6 and create a file named “pavucontrol.txt”
  8. Open twotone.txt and add the following
[Desktop Entry]
Version=1.0
Name=TTD
Exec=/bin/sh -c "sleep 20; cd /home/pi/TTD ; ./TwoToneDetect70"
Terminal=false
Type=Application
X-GNOME-Autostart-Phase=Initialization
NotShowIn=KDE;

  1. Select save as and save the file as “TwoToneDetect.desktop”
  2. Open pavucontrol.txt and add the following
[Desktop Entry]
Version=1.0
Name=PulseAudio Volume Control
Exec=/bin/sh -c "sleep 5; pavucontrol"
Terminal=false
Type=Application
X-GNOME-Autostart-Phase=Initialization
NotShowIn=KDE;

  1. Select save as and save the file as “pavucontrol.desktop”
  2. Reboot and verify both programs start

  3. Open terminal and type “sudo nano /etc/crontab” and press enter

  4. Navigate all the way to the bottom of the file and create a new line above the #
  5. Type “0 0 * * * root reboot”
  6. Press cntrl+x
  7. Press y
  8. Press enter

If everything went right you should be up and running with a headless TTD that will reboot every night at midnight. If not hopefully someone smarter than me can help, this is exactly how I set mine up and it works.

The credit for the method goes to DC31. I have no idea how it works, just that it does.
 

DC31

Member
Premium Subscriber
Joined
Feb 19, 2011
Messages
1,056
Location
Massachusetts
I followed your previous posts on the subject. Like squirrel I had to replace the Exec line “python TwoToneDetect70.py” with “./TwoToneDetect70”

I still struggled with the whole process. Here’s what I learned
1. .config is a hidden folder. You have to select view hidden folders in the file browser or type the file path in the file browser
2. For some reason I thought writing the .desktop files in nano was what should be done. Neither file ran on reboot using nano to create the files. Instead I created two blank files in autostart with a .txt then edited them and saved as .desktop
3. I also added a reboot command to crontab so that the pi will reboot every night. For whatever reason TTD’s audio input maxes out every once in a while making a reboot or restart of TTD necessary.

Maybe later on today I’ll consolidate all the info into one post to help others like myself get TTD and pi playing nice together[/QUOTE

Yes, that’s right, I forgot. I run the python program file rather than the executable. The program file is available in the .zip download
 
Joined
May 14, 2017
Messages
2
Location
Diamondhead MS
Hello everyone,

Ive been running TTD on pc for a couple years, now Im trying to get it set up on a pi 3b+ and I am getting this error:

FFMPEG FOUND
default selected as audio input device
default selected as audio output device

Successfully retrieved local tone info at 18:31:39 on 04/14/19
Successfully retrieved local tone info at 18:31:39 on 04/14/19
Diamondhead FD
Successfully retrieved local tone info at 18:31:39 on 04/14/19
Traceback (most recent call last):
File "/home/pi/TTD/TwoToneDetect71.py", line 2078, in start_audio_stream
File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 750, in open
IOError: [Errno -9997] Invalid sample rate

After it runs the start up it just closes down. Any ideas?

Mike M
Diamondhead FD
 
Joined
Aug 27, 2005
Messages
1,099
Hello everyone,

Ive been running TTD on pc for a couple years, now Im trying to get it set up on a pi 3b+ and I am getting this error:

FFMPEG FOUND
default selected as audio input device
default selected as audio output device

Successfully retrieved local tone info at 18:31:39 on 04/14/19
Successfully retrieved local tone info at 18:31:39 on 04/14/19
Diamondhead FD
Successfully retrieved local tone info at 18:31:39 on 04/14/19
Traceback (most recent call last):
File "/home/pi/TTD/TwoToneDetect71.py", line 2078, in start_audio_stream
File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 750, in open
IOError: [Errno -9997] Invalid sample rate

After it runs the start up it just closes down. Any ideas?

Mike M
Diamondhead FD
Do you have pulseaudio installed?

Andy
 
Top