TwoToneDetect TwoToneDetect on a Raspberry Pi - How To

Status
Not open for further replies.

estone4009

Member
Feed Provider
Joined
May 11, 2016
Messages
49
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?
 

phool

Member
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
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
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
11
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

  • launch.txt
    166 bytes · Views: 18
  • startTTD.txt
    125 bytes · Views: 20

pillihp

Member
Joined
Jan 2, 2016
Messages
14
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
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
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.
 

pillihp

Member
Joined
Jan 2, 2016
Messages
14
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
 

pillihp

Member
Joined
Jan 2, 2016
Messages
14
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
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
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
 

davidVT

Member
Feed Provider
Joined
Aug 29, 2010
Messages
138
Location
Washington County,Vermont
I love that tone generator web link!

Not spending much time on this forum lately.
My old TTD Pi unit’s just keep rolling along day in and day out!!


Sent from my iPad using Tapatalk
 

ffryan76

Member
Feed Provider
Joined
Nov 28, 2004
Messages
175
Location
South central, In
Does anyone know what will happen with the New Gmail API change after March 31st? I use Gmail with TTD. Will it stop working or are we safe?
 

mungeremt

Newbie
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
 

aaknitt

Member
Feed Provider
Joined
Aug 27, 2005
Messages
1,300
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
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
I thought that I would report that I installed v71 on a headless pi3b (Stretch Lite) last Saturday by following the instructions on Andy’s website specific to the pi. Previously, I had been using a test version for debugging. The new installation has been running for six days now without a hitch. This pi runs two instances of TTD with audio from two sound cards and one instance of darkice supplying a Bcfy feed. Both TTD instances read from remote tones.cfg files. One is a redundant backup of another primary pi. All is working well and as expected. There are a few quirks like needing the two startup scripts as outlined by JH40 above. Also, even running only one instance of TTD you need to specify the sound card using the PULSE_SOURCE= environment variable. I am running them in detached screens and starting with crontab triggering the scripts. I am using the heartbeat feature to trigger a push notification if either of the TTDs fails. So far this has only been tested when I shut the program down. It all makes for a very reliable installation.

It appears that there is no longer a need for the daily reboot.

Good work, Andy.
 
Last edited:

KK6ZTE

Member
Premium Subscriber
Joined
Mar 27, 2016
Messages
896
Location
California
I finally got this running on a Pi to save power compared to the dedicated desktop I was using before. It detects pages, sends emails, etc, but will not find ffmpeg.

FFMPEG has been installed on the system, I created a blank ffmpeg file in the TTD folder, I've even copied the library over from /bin

Any ideas where I went wrong? I followed the instructions step by step
 

aaknitt

Member
Feed Provider
Joined
Aug 27, 2005
Messages
1,300
I finally got this running on a Pi to save power compared to the dedicated desktop I was using before. It detects pages, sends emails, etc, but will not find ffmpeg.

FFMPEG has been installed on the system, I created a blank ffmpeg file in the TTD folder, I've even copied the library over from /bin

Any ideas where I went wrong? I followed the instructions step by step

If you type ffmpeg -version at the command line does it provide you the version number? That's essentially what TTD (v71) is doing to check to see if ffmpeg exists.

Andy
 
Status
Not open for further replies.
Top