User:Wordfa/oldphonehack
Phone Hacking Project
This is a project for SS25 to create a story gathering system using an old phone. What do we want the telephone to do? Fred wants to make it into an API that we can use it later on with the data.
Parts Required
USB interface to 3.5mm
https://www.adafruit.com/product/1475
3.5mm Cables
Old phone (T65)
Raspberry Pi
TRS 3.5 Jack x2
Loads of wires
old headphones with a mic (apple earpod works best)
Things we done
- We took the phone apart and got the speaker to work by connecting the blue and red cables from the phone out to the audio jack to the soundcard to the computer. played show me the body, was good.
- Then we tried the microphone but its a carbon mic and it didnt work. so we atttached a battery and hoped. didnt work.
- We took apart wired headphones that had mic in them to see if we could use the mic from it rather than the carbon mic in the telephone.-> didnt work, headphone cable is TRRS not TRS:
spent a day trying to wire up TRRS to an audio cable, turns out the audio jack was the wrong kind.
then wired it directly to a TRS jack, worked!!!!!!!!!!!!!
then cable managed, looks beautiful now. now we have working speakers and working mic.
This is how you could make it work too:
From the headphones you need to...
Connect th Blue (Ground) to the Sleeve of the TRS jack
Connect the Red (mic) to Pin (Ring) 1 or 2 of the TRS jack
MAKE SURE THE HEADPHONES CONNECTION IS CLOSED!
Next Steps:
Work out how to read the keypad input on the raspberrypi.
We used this project as our basis(it's in Dutch): https://github.com/ralphcrutzen/PTT-Tafeltjes-Telefoon?tab=readme-ov-file. This project turns the phone into a math game where a child asks you a random times table question and you have to give the correct answer using the rotary keypad. Fred is translating the code to eng. Fred thinks I can't do times tables.
Set up the raspberrypi, named it telephone.(tut here:https://nematicslab.com/how-to-enable-ssh-without-using-a-monitor/)
Fred made me a user(Sevgi) as well and we tested the connections first, adjusted the code accordingly. Fred tested the connections like this (this is the final working version):
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(25, GPIO.IN, pull_up_down = GPIO.PUD_UP)
while True:
print('-')
if GPIO.input(23):
print('23')
if GPIO.input(25):
print('25')
if GPIO.input(24):
print('24')
Here is how we set up the wires and the raspberry pi:
Here is the eng version of the dutch code:
#!/usr/bin/env python
import sys, os, time, random, pygame
import RPi.GPIO as GPIO
# translated to english by DeepL and wordfa
# Speaker Function - Play Sound
# Takes a file Path
def say(file):
pygame.mixer.music.load(file)
pygame.mixer.music.play()
while pygame.mixer.music.get_busy() == True:
continue
# Ask Question for Telefone Letter
def askQuestion(numOne, numTwo):
print("Wat is", numOne, "x", numTwo,"?")
say("audio/" + str(numOne) + ".mp3")
say("audio/keer.mp3")
say("audio/" + str(numTwo) + ".mp3")
say("audio/is.mp3")
def getNummer():
# number of Pulses
nPulsen = 0
# Watch Dail or Button
DialContact = GPIO.input(DialPIN)
NumberContact = GPIO.input(NumberPIN) # Low if pressed
while DialContact == False and NumberContact == True:
DialContact = GPIO.input(DialPIN)
NumberContact = GPIO.input(NumberPIN)
# Number Pressed (Selected)
if NumberContact == False:
return -1
# Handle Pulses
done = False
while done == False and DialContact == True:
nPulsen = nPulsen + 1
startTime = time.time()
time.sleep(0.1)
DialContact = GPIO.input(DialPIN)
# Check time between Pulses
while done == False and DialContact == False:
if time.time() - startTime >= 0.2:
done = True
DialContact = GPIO.input(DialPIN)
# Return number
return nPulsen % 10
# Tell you when handset is picked up
def handsetCallback(channel):
print("Handset picked up!", channel)
# Restart Script
# Set Up all the IO Stuff
GPIO.cleanup()
python = sys.executable
os.execl(python, python, * sys.argv)
# Name pins
DialPIN = 25
NumberPIN = 23
handsetPIN = 24
# Set Up Pins
GPIO.setmode(GPIO.BCM)
GPIO.setup(DialPIN, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(handsetPIN, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(NumberPIN, GPIO.IN, pull_up_down = GPIO.PUD_UP)
# Use an interrupt for the handset, because it can be put down at any time
GPIO.add_event_detect(handsetPIN, GPIO.BOTH, callback = handsetCallback)
# Start audio mixer
pygame.mixer.init()
while True:
try:
# Wait for pick up
print("Wait for pick up...")
handsetContact = GPIO.input(handsetPIN)
while handsetContact == True:
handsetContact = GPIO.input(handsetPIN)
time.sleep (1)
# Which times table to practise
print("Which times table to practise?")
say("audio/welk.mp3")
table = getNummer()
# List to keep track of answered questions
sums = []
for som in range(10):
sums.append(0) # 0 is bad, 1 is goed
numOfCorrectAns = 0
while numOfCorrectAns < 10:
# Set Question?
numOne = random.randint(1,10)
while sums[numOne - 1] == 1:
numOne = random.randint(1,10)
if table == -1:
numTwo = random.randint(1,10)
elif table == 0:
numTwo = 10
else:
numTwo = table
result = numOne * numTwo
numOfDigits = len(str(result))
askQuestion(numOne, numTwo)
thisDigit = 0
answer = ""
# Watch for Answer
while thisDigit < numOfDigits:
nummer = getNummer()
if nummer > -1: # Dial Turned
answer = answer + str(nummer)
thisDigit = thisDigit + 1
else: # Number Key Pressed
askQuestion(numOne, numTwo)
thisDigit = 0
answer = ""
print(answer)
# Check Answer
# string to Int Answer
if int(answer) == result:
numOfCorrectAns = numOfCorrectAns + 1
sums[numOne - 1] = 1
print("Good Job!")
say("audio/goed.mp3")
else:
print("You suck, the correct answer is ", result)
say("audio/fout.mp3")
say("audio/" + str(result) + ".mp3")
print()
time.sleep(1)
say("audio/einde.mp3")
except KeyboardInterrupt: # Ctrl+C
GPIO.cleanup()
References
Microphone from handset
https://www.youtube.com/watch?v=rIkIkbOw3OQ&t
Rotary Pi
- Really good write up with code:
- https://marks.kitchen/blog/rotary_phone_running_linux/
- Linking Video
- https://www.youtube.com/watch?v=M4eCrctDMEc
Lofi Mic
https://www.youtube.com/watch?v=7gorBkdk8zY
Schematic (v scary)
https://easyeda.com/editor#id=7d0350ec43844219912695cec1a0e156
Rotary MP3 Player
https://www.whizzbizz.com/en/gpo746-t65-rotary-dial-phone-mp3-wav-player
Info on the T65
https://www.cryptomuseum.com/phone/t65/index.htm(there is a wire list here as well)
Carbon Mic
https://www.youtube.com/watch?v=cwPPoVvljOw
https://www.youtube.com/watch?v=pb-Lu2kzKYc&t=221s
Dutch guide on rotary dail
https://github.com/ralphcrutzen/PTT-Tafeltjes-Telefoon?tab=readme-ov-file
Weird Stuff
how does a carbon mic work
https://wonderfoon.jimdosite.com/
https://www.youtube.com/@ruudshangout/search?query=t65