TwoToneDetect TwoToneDetect on a Raspberry Pi - How To

Status
Not open for further replies.

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
it seems I may need to run this x-terminal-emulator, perhaps?

I am afraid that you are already over my head on this, Tom! I haven’t yet figured out how to make the executable version of TTD autostart.

One thing that I would suggest you try is to insert a delay of say 10 sec. into your Exec= line for TTD. Give PAVu a chance to get fully loaded.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
Here is one of my Exec= lines that starts with a 10 sec delay:

Exec=/bin/sh -c "sleep 10; cd /home/pi/TTD ;
 

tdpearce

Member
Joined
Feb 5, 2008
Messages
8
Well I have changed how this autostarts by adding command lines to the the /home/pi/.config/lxsession/LXDE-pi/autostart file:

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@point-rpi
@sh /home/pi/myapp_startpulse.sh
@sh /home/pi/myapp_startTTD.sh

*******
myapp_startpulse.sh
*******
#!/usr/bin/sh
sleep 15
sudo /usr/bin/pavucontrol

***********
myapp_startTTD.sh
***********
#!/usr/bin/sh
sleep 30
sudo /home/pi/TTD/TwoToneDetect70

Both programs start after the expected delays, but I still have the same results. Both appear like they are working, but do not recognize my test tones but will recognize my test tones if I close them and restart them.
 

tdpearce

Member
Joined
Feb 5, 2008
Messages
8
Success!

Not sure why it's like this, but I noticed there are tones.cfg and config.cfg files located in the /home/pi/ directory as well as the /home/pi/TTD directory. Copied the 2 files that I had edited in /home/pi/TTD to /home/pi and it works perfectly now with both programs auto-starting.

Thanks for the help!
 

SOUTH300

Member
Joined
Jun 13, 2002
Messages
228
Location
Carencro, LA
Using TwoToneDetect simply to activate LED's

Has anyone used TwoToneDetect for this purpose? Everything that I have researched indicates that what I am trying to do is possible, but wanted to put it here to see if I will run into any issues.

I am building a box, that will house several LED lights. I will use TTD on a Raspberry Pi as indicated in this thread. I will not be using the email feature, nor am I planning to have any network/internet connection to the box. Whenever a valid tone set is recieved, I would like to use the Alert Command feature to run a python script to activate an LED light. The Raspberry Pi would need to run headless, and I am thinking of putting a reset switch on the box, to reboot the Pi should any trouble arise without having to connect a keyboard/monitor to troubleshoot. I have been able to find all necessary information to get everything running, but do any of you see any issues that may present itself with this setup? Here is my ultimate goal. However, if need be I can seperate the project and use two Pi's.

(1) Raspberry Pi, 2 sound cards, two instances of TTD running on the Pi headless. Activating a total of 14 LED's. Seven LEDs controlled by one instance/sound card, and Seven by the other.

OR if I run into issues:

(1) Raspberry Pi, One Sound Card, TTD, 7 LEDs
(1) Raspberry Pi, One Sound Card, TTD, 7 LEDs

Ideas?

Thanks
Oren
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
Yes, what you are describing is all doable with one raspberry pi. You will need Andy’s instructions (twotonedetect.net) on how to source the two sound cards individually for the two instances of TTD. You really have no internet where this is going? Lots easier to manage headless with an internet connection.

As far as your reset button, just unplug it to power cycle it.

Try connecting to it using a direct ethernet connection to a laptop. Again, lots easier than hooking up monitor/keyboard.

You will need 14 addressable gpio pins on the pi, but I think that shouldn’t be a problem.

The raspberry pi OS now comes with node-red installed. You might want to research its capabilities as a means of controlling LEDs as well as just about anything else you can think of. nodered.org
 

SOUTH300

Member
Joined
Jun 13, 2002
Messages
228
Location
Carencro, LA
Thank you for the reply. I do have internet where this will be going, but i am not sure how much red tape I will need to negotiate to plug the Pi into their network. I agree it will be easier, I was just making sure TTD will in fact operate without an internet connection in case I have to go that route. And that it will operate with out sending emails.

Do you have experience with node-red? I browsed the documentation, and it looks like it is very versatile. I suppose it will create the batch script for me, in order to activate it with TTD, and keep me from having to write multiple scripts?

One other hurdle I need to cross, is to have some sort of indication that all is working and powered up. I was thinking of a simple power LED, but with Node-Red, I may be able to use an RGB led, and have it progress through power, booting, and standby conditions. Need something to let the end user know that it is at least on. Would be nice if it could check the status of TTD and verifiy that it is loaded and standing by. Or, possibly an OLED that I can program to display status messages.

Any ideas?

Thanks for your responses.
Oren
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
Thank you for the reply. I do have internet where this will be going, but i am not sure how much red tape I will need to negotiate to plug the Pi into their network. I agree it will be easier, I was just making sure TTD will in fact operate without an internet connection in case I have to go that route. And that it will operate with out sending emails.

Do you have experience with node-red? I browsed the documentation, and it looks like it is very versatile. I suppose it will create the batch script for me, in order to activate it with TTD, and keep me from having to write multiple scripts?

One other hurdle I need to cross, is to have some sort of indication that all is working and powered up. I was thinking of a simple power LED, but with Node-Red, I may be able to use an RGB led, and have it progress through power, booting, and standby conditions. Need something to let the end user know that it is at least on. Would be nice if it could check the status of TTD and verifiy that it is loaded and standing by. Or, possibly an OLED that I can program to display status messages.

Any ideas?

Thanks for your responses.
Oren

Yes, I can confirm that TTD will operate without internet and without sending emails.. i had one simply set up to sound a buzzer when it decoded a tone set.

I am a novice with node-red, having learned by playing with it. You might be able to avoid a bunch of coding by having TTD send the tone set description to node red and then use node red to parse that to determine which LED to turn on. I believe that node-red can somehow also monitor that your pi is live and well.

IF you can get the pi internet connection, then set up RealVNC on the pi. My experience has been that with realvnc set up, i can move the pi to another location, plug into ethernet or wifi and access the pi remotely without the network admin allowing me any special privileges. Realvnc comes installed on the pi and is free for up to five pi’s.

For starters, here is a sample python script that starts a flow in node red when a tone set is detected:

import urllib2
response = urllib2.urlopen('http://localhost:1880/start/')
html = response.read()

I realize that it probably doesn’t mean much to you at this point. It doesn’t mean much to me either. The script is named something like script.py and is launched by alert_command=python script.py. That communicates to an “http in” node on node red and triggers the flow. As the attached image shows, the flow triggers a high priority alert through pushover.
 

Attachments

  • C05F765C-7839-46C1-BE79-194233AEB89E.jpg
    C05F765C-7839-46C1-BE79-194233AEB89E.jpg
    43 KB · Views: 183

krokus

Member
Premium Subscriber
Joined
Jun 9, 2006
Messages
6,003
Location
Southeastern Michigan
Has anyone used TwoToneDetect for this purpose? Everything that I have researched indicates that what I am trying to do is possible, but wanted to put it here to see if I will run into any issues.

I am building a box, that will house several LED lights. I will use TTD on a Raspberry Pi as indicated in this thread. I will not be using the email feature, nor am I planning to have any network/internet connection to the box. Whenever a valid tone set is recieved, I would like to use the Alert Command feature to run a python script to activate an LED light. The Raspberry Pi would need to run headless, and I am thinking of putting a reset switch on the box, to reboot the Pi should any trouble arise without having to connect a keyboard/monitor to troubleshoot. I have been able to find all necessary information to get everything running, but do any of you see any issues that may present itself with this setup? Here is my ultimate goal. However, if need be I can seperate the project and use two Pi's.

(1) Raspberry Pi, 2 sound cards, two instances of TTD running on the Pi headless. Activating a total of 14 LED's. Seven LEDs controlled by one instance/sound card, and Seven by the other.

OR if I run into issues:

(1) Raspberry Pi, One Sound Card, TTD, 7 LEDs
(1) Raspberry Pi, One Sound Card, TTD, 7 LEDs

Ideas?

Thanks
Oren
A Minitor, G1, G4, G5, or RE729, will turn on a circuit, when used with a base. It is much simpler to set up, unless you are doing this as an exercise.

Sent using Tapatalk
 

davidVT

Member
Feed Provider
Joined
Aug 29, 2010
Messages
138
Location
Washington County,Vermont
Thank you for the reply. I do have internet where this will be going, but i am not sure how much red tape I will need to negotiate to plug the Pi into their network. I agree it will be easier, I was just making sure TTD will in fact operate without an internet connection in case I have to go that route. And that it will operate with out sending emails.



Do you have experience with node-red? I browsed the documentation, and it looks like it is very versatile. I suppose it will create the batch script for me, in order to activate it with TTD, and keep me from having to write multiple scripts?



One other hurdle I need to cross, is to have some sort of indication that all is working and powered up. I was thinking of a simple power LED, but with Node-Red, I may be able to use an RGB led, and have it progress through power, booting, and standby conditions. Need something to let the end user know that it is at least on. Would be nice if it could check the status of TTD and verifiy that it is loaded and standing by. Or, possibly an OLED that I can program to display status messages.



Any ideas?



Thanks for your responses.

Oren



I am assuming you want to identify 14 unique code sets to these 14 LEDs?
Can you use a sequence rather than unique LEDs? Example 0001, 0010, 0011, etc? Would decrease the number of LEDs and GPIOs for example.
In my case I would use a 4 channel sonoff and nodered. (I already do this for a 3 code set of the services I run on. )
That can give you 16 unique signals with 4 channels.
I see no reason you can not run without internet once this is up and running. The sonoff will talk wifi and I believe you can connect the wifi Pi3 on a closed wifi network if that is within your project rules.
The headless running and reliability is fairly well documented.
One Pi, one 4ch sonoff which will control 4 AC circuits.
YMMV
Good luck


Sent from my iPhone using Tapatalk
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
davidVT, you are always coming up with good ideas! So, you mad3 me start thinking sbout this project again. With 14 tone sets, it is going to be hard to remember which set goes with code 1011 (or was that 1101) or which color LED. How about using a mini LCD display to show the text that TTD has in the tone set description? I don’t have any experience with these but the process seems pretty well documented:

https://www.raspberrypi-spy.co.uk/2012/07/16x2-lcd-module-control-using-python/
 

davidVT

Member
Feed Provider
Joined
Aug 29, 2010
Messages
138
Location
Washington County,Vermont
davidVT, you are always coming up with good ideas! So, you mad3 me start thinking sbout this project again. With 14 tone sets, it is going to be hard to remember which set goes with code 1011 (or was that 1101) or which color LED. How about using a mini LCD display to show the text that TTD has in the tone set description? I don’t have any experience with these but the process seems pretty well documented:

https://www.raspberrypi-spy.co.uk/2012/07/16x2-lcd-module-control-using-python/



DC31
Getting time to play this year has been a struggle....
That link will not open for me. [emoji20]

I do see South300 mentioned OLED as a possibility.

Thinking the built-in NodeRed, a small LED/OLED display and the gpio LEDs probably meet all the needs unless I miss something.

Need to dig into what the 14 LEDs are trying to do a little. Doing a rewind, what is the desired objective for these 14 signals?

For my Node-Red 'http in', I use TTD to call a URL of the nodered server (can be same box) /TTDbridge with a tone name via a script called from TTD alert:

5f7e9c666d9e589d0f5fc3fdbff19fd9.jpg


Node-Red will parse that and send unique output to MQTT for distribution to my Sonoff 4 channel to turn on an AC circuit telling me which department was toned. In this case the output can go to GPIO pins rather than the mqtt and sonoff complexity.
745b71163b288efed9807a94ebacfa30.jpg


Sent from my iPad using Tapatalk
 
Last edited:

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
DC31
Getting time to play this year has been a struggle....
That link will not open for me. [emoji20]

I do see South300 mentioned OLED as a possibility.

Thinking the built-in NodeRed, a small LED/OLED display and the gpio LEDs probably meet all the needs unless I miss something.

Need to dig into what the 14 LEDs are trying to do a little. Doing a rewind, what is the desired objective for these 14 signals?

For my Node-Red 'http in', I use TTD to call a URL of the nodered server (can be same box) /TTDbridge with a tone name via a script called from TTD alert:

5f7e9c666d9e589d0f5fc3fdbff19fd9.jpg


Node-Red will parse that and send unique output to MQTT for distribution to my Sonoff 4 channel to turn on an AC circuit telling me which department was toned. In this case the output can go to GPIO pins rather than the mqtt and sonoff complexity.
745b71163b288efed9807a94ebacfa30.jpg


Sent from my iPad using Tapatalk

Sorry about the link. Here is another similar one:

https://raspberrypi.stackexchange.com/questions/28991/how-can-i-use-a-lcd-display-with-a-i2c-adapter
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
Has anyone used TwoToneDetect for this purpose? Everything that I have researched indicates that what I am trying to do is possible, but wanted to put it here to see if I will run into any issues.

I am building a box, that will house several LED lights. I will use TTD on a Raspberry Pi as indicated in this thread. I will not be using the email feature, nor am I planning to have any network/internet connection to the box. Whenever a valid tone set is recieved, I would like to use the Alert Command feature to run a python script to activate an LED light. The Raspberry Pi would need to run headless, and I am thinking of putting a reset switch on the box, to reboot the Pi should any trouble arise without having to connect a keyboard/monitor to troubleshoot. I have been able to find all necessary information to get everything running, but do any of you see any issues that may present itself with this setup? Here is my ultimate goal. However, if need be I can seperate the project and use two Pi's.

(1) Raspberry Pi, 2 sound cards, two instances of TTD running on the Pi headless. Activating a total of 14 LED's. Seven LEDs controlled by one instance/sound card, and Seven by the other.

OR if I run into issues:

(1) Raspberry Pi, One Sound Card, TTD, 7 LEDs
(1) Raspberry Pi, One Sound Card, TTD, 7 LEDs

Ideas?

Thanks
Oren


Oren,

Just thought that I would report back. I purchased an I2C LCD screen to try this out. It was fairly simple and straightforward. Here is the LCD I purchased:

https://www.amazon.com/gp/slredirec...23631353&id=704940962322670&widgetName=sp_atf

Or search Amazon for Keyestudio 1602

Simply hook up four wires. Connect to the 5 v. power pin, you won't hurt your pi.

Here is the article that I followed to get it working:

How to Setup an I2C LCD on the Raspberry Pi - Circuit Basics

Once you get it to scroll or blink a message or whatever you want, then you can start integrating with TTD.

Create a file in your TTD folder called blink.py

Paste this following text into that file:

import I2C_LCD_driver
import time
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("description")
args = parser.parse_args()

desc = args.description

mylcd = I2C_LCD_driver.lcd()

for x in range (1,10):

mylcd.lcd_display_string(desc)
time.sleep(1)
mylcd.lcd_clear()
time.sleep(1)

Then save it.

Note that the I2C_LCD_driver file needs to be in your TTD folder also.

Now, in your tones.cfg file add an alert_command = python blink.py [d] for each tone set that you want to display on the LCD.

When that tone set decodes it will send the Description = parameter to the LCD screen and blink it ten times.

The CircuitBasics page above describes now to modify the code if you want it scrolling or some other option.

It doesn't handle stacked tones well.

With some modifications, I expect that it would also work with and OLED display.

Good luck with it.

Jim
 

SOUTH300

Member
Joined
Jun 13, 2002
Messages
228
Location
Carencro, LA
Oren,

Just thought that I would report back. I purchased an I2C LCD screen to try this out. It was fairly simple and straightforward. Here is the LCD I purchased:

https://www.amazon.com/gp/slredirec...23631353&id=704940962322670&widgetName=sp_atf

Or search Amazon for Keyestudio 1602

Simply hook up four wires. Connect to the 5 v. power pin, you won't hurt your pi.

Here is the article that I followed to get it working:

How to Setup an I2C LCD on the Raspberry Pi - Circuit Basics

Once you get it to scroll or blink a message or whatever you want, then you can start integrating with TTD.

Create a file in your TTD folder called blink.py

Paste this following text into that file:

import I2C_LCD_driver
import time
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("description")
args = parser.parse_args()

desc = args.description

mylcd = I2C_LCD_driver.lcd()

for x in range (1,10):

mylcd.lcd_display_string(desc)
time.sleep(1)
mylcd.lcd_clear()
time.sleep(1)

Then save it.

Note that the I2C_LCD_driver file needs to be in your TTD folder also.

Now, in your tones.cfg file add an alert_command = python blink.py [d] for each tone set that you want to display on the LCD.

When that tone set decodes it will send the Description = parameter to the LCD screen and blink it ten times.

The CircuitBasics page above describes now to modify the code if you want it scrolling or some other option.

It doesn't handle stacked tones well.

With some modifications, I expect that it would also work with and OLED display.

Good luck with it.

Jim
That is awesome Jim. Thanks a bunch for the info.

Oren


Sent from my SAMSUNG-SM-G935A using Tapatalk
 

davidVT

Member
Feed Provider
Joined
Aug 29, 2010
Messages
138
Location
Washington County,Vermont
Oren,



Just thought that I would report back. I purchased an I2C LCD screen to try this out. It was fairly simple and straightforward. Here is the LCD I purchased:



https://www.amazon.com/gp/slredirec...23631353&id=704940962322670&widgetName=sp_atf



Or search Amazon for Keyestudio 1602



Simply hook up four wires. Connect to the 5 v. power pin, you won't hurt your pi.



Here is the article that I followed to get it working:



How to Setup an I2C LCD on the Raspberry Pi - Circuit Basics



Once you get it to scroll or blink a message or whatever you want, then you can start integrating with TTD.



Create a file in your TTD folder called blink.py



Paste this following text into that file:



import I2C_LCD_driver

import time

import argparse



parser = argparse.ArgumentParser()

parser.add_argument("description")

args = parser.parse_args()



desc = args.description



mylcd = I2C_LCD_driver.lcd()



for x in range (1,10):



mylcd.lcd_display_string(desc)

time.sleep(1)

mylcd.lcd_clear()

time.sleep(1)



Then save it.



Note that the I2C_LCD_driver file needs to be in your TTD folder also.



Now, in your tones.cfg file add an alert_command = python blink.py [d] for each tone set that you want to display on the LCD.



When that tone set decodes it will send the Description = parameter to the LCD screen and blink it ten times.



The CircuitBasics page above describes now to modify the code if you want it scrolling or some other option.



It doesn't handle stacked tones well.



With some modifications, I expect that it would also work with and OLED display.



Good luck with it.



Jim



Jim,
Nice work.
Can you clarify part as keyestudio 2004 or 1602??
Thank you


Sent from my iPhone using Tapatalk
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
Jim,
Nice work.
Can you clarify part as keyestudio 2004 or 1602??
Thank you


Sent from my iPhone using Tapatalk

I used the 1602, the link may have taken you to a 2004. They are 16 characters, 2 lines or 20 characters, 4 lines. Either should work.

The key is that you get an I2C display. Only four wires to hook up.

Jim
 
Status
Not open for further replies.
Top