Smart Cities - Phone for Seniors with Vision Impairment

From Sensors in Schools
Jump to navigation Jump to search

Building a simple telphone for seniors with vision impairment

Building a simple telephone for seniors with vision impairments using a Raspberry Pi can be an enriching and functional project. Below are the steps to create a device that allows seniors to call loved ones, leveraging either the internet (e.g., VoIP) or interfacing with a traditional mobile phone. The design emphasizes ease of use, accessibility, and practicality.

Project Overview

  • Features: Large, Accessible Buttons:
  • Physical buttons for calling predefined contacts.
  • Tactile feedback for easy navigation.
  • Voice Assistance: Text-to-Speech (TTS) for confirmation of actions.
  • Simple voice commands to perform tasks.
  • Internet Calling: Using VoIP services like SIP (Session Initiation Protocol).
  • Mobile Phone Interface (Optional): Interfacing with a traditional mobile phone via Bluetooth.
  • Speaker and Microphone: High-quality audio input/output for calls.


Materials Required

  • Raspberry Pi (Model 3, 4, or Zero 2 W recommended for performance).
  • MicroSD card with Raspberry Pi OS installed.
  • USB speaker or 3.5mm-compatible speaker.
  • USB microphone or headset with a mic.
  • Large tactile buttons or a numeric keypad.
  • Breadboard and jumper wires (for prototyping buttons).
  • A touchscreen or an e-ink display (optional for feedback).
  • USB or Bluetooth module (for mobile interfacing, optional).
  • Power supply for the Raspberry Pi.


Step 1: Setting Up the Raspberry Pi

Install the OS: Install Raspberry Pi OS on the MicroSD card using the Raspberry Pi Imager. Enable SSH, Wi-Fi, and audio support. Update and Upgrade: Run the following commands:

sudo apt update
sudo apt upgrade
  • Install Required Libraries: Install libraries for GPIO, audio processing, and VoIP:
sudo apt install python3-pip pyaudio alsa-utils libportaudio2
pip3 install gpiozero pyttsx3

To use Linphone on a Raspberry Pi for making calls to Australian mobile phones, you will need to install Linphone on your Raspberry Pi, configure it with a VoIP service provider (e.g., SIP provider), and integrate it with Python for initiating calls. Linphone is a powerful, open-source, SIP-based VoIP client that supports both voice and video calls.

Steps to Set Up Linphone for Calling Australian Mobile Phones:

1. Install Linphone on Raspberry Pi

First, you need to install Linphone on your Raspberry Pi. There are a few ways to install it, but the easiest method is using the Raspberry Pi OS repository.

Step 1.1: Install Linphone from the official repository:

sudo apt update
sudo apt install linphone

Alternatively, you can download the Linphone package for Raspberry Pi from the official Linphone download page.

2. Choose a VoIP Service Provider (SIP Provider)

You need a SIP (Session Initiation Protocol) provider that allows you to make calls to Australian mobile numbers. Some reliable SIP providers include:

VoIP.ms (Offers pay-as-you-go plans, and supports calls to landlines and mobiles).

For this tutorial, we will use VoIP.ms as an example. They offer good pricing for calls to Australian mobile numbers.

Step 2.1: Create an Account with VoIP.ms

Visit the VoIP.ms website and create an account. After logging in, you'll be able to obtain a SIP username and password to use in Linphone. Top up your balance to ensure you have credit to make calls to Australian mobile numbers.

Step 2.2: Configure VoIP.ms SIP Credentials

Once you’ve signed up, you'll need the following credentials:

SIP username
SIP password
SIP server (e.g., sip.voip.ms)

3. Configure Linphone for VoIP.ms SIP Account

Step 3.1: Set up Linphone with VoIP.ms

Once Linphone is installed, launch it and configure it with your SIP provider (e.g., VoIP.ms):

  • Open Linphone from the Raspberry Pi’s application menu.
  • Click on the Settings (gear icon) in Linphone.
  • Go to the Accounts tab.
  • Click on Add to add a new SIP account.
Username: Enter your SIP username from VoIP.ms.
Password: Enter your SIP password from VoIP.ms.
Domain: Enter sip.voip.ms (or another VoIP provider’s SIP server).
  • Enable Account enabled.
  • Save the configuration.

Step 3.2: Test Linphone

To ensure your configuration works, you can make a test call to a VoIP number or another SIP user. If the call connects successfully, you are ready to proceed with making calls to Australian mobile phones.

4. Using Python for Linphone Integration

To integrate Linphone with Python, you will need to use the Linphone Python bindings. This allows Python scripts to interact with Linphone, making it possible to initiate calls programmatically.


Using Linphone on a Raspberry Pi with Python requires some preparation because the Python bindings for Linphone are not always straightforward to install via pip. Here's a simpler approach to make Python communicate with Linphone.

1. Use Linphone's CLI and Control It via Python

Linphone provides a command-line interface (CLI) that you can use to control it. Python can communicate with the CLI to send commands and receive outputs.

Step 1: Install Linphone CLI

Install the Linphone CLI on your Raspberry Pi:

sudo apt update
sudo apt install linphone-cli

Verify the installation:

linphonec --version

You should see the version of Linphone CLI installed.

Step 2: Run Linphone CLI

Start the Linphone CLI in a terminal:

linphonec

You'll see a prompt like:

linphonec>

You can now issue commands to make calls, answer calls, and control Linphone.

Example commands:

Register your SIP account:

Username, domain, password

linphonec> register sip:123456@voip.ms sydney1.voip.ms <password>

Make a call:

linphonec> call sip:+614XXXXXXXX@sydney1.voip.ms

Hang up:

linphonec> terminate

Quit:

linphonec> quit

Help: Also useful for finding the correct command syntax. This assisted with the initial registration process.

linphonec> help register
linphonec> help advanced

Step 3: Automate with Python

You can use Python to automate Linphone CLI commands using the subprocess module.

Example Python Script

This script shows how to register, make a call, and hang up using Linphone CLI.

import subprocess
import time

# Function to run Linphone commands
def linphone_command(command):
    process = subprocess.Popen(
        ['linphonec'], 
        stdin=subprocess.PIPE, 
        stdout=subprocess.PIPE, 
        stderr=subprocess.PIPE, 
        text=True
    )
    stdout, stderr = process.communicate(command)
    return stdout, stderr

# Register to SIP server
def register(username, domain, password):
    command = f"register {username} {domain} {password}\n"
    output, error = linphone_command(command)
    print("Registration output:", output)

# Make a call
def make_call(sip_uri):
    command = f"call {sip_uri}\n"
    output, error = linphone_command(command)
    print("Call output:", output)

# Hang up the call
def hangup():
    command = "terminate\n"
    output, error = linphone_command(command)
    print("Hangup output:", output)

# Main function
while True:
    # SIP account credentials
    USERNAME = "YOUR_USERNAME"
    PASSWORD = "YOUR_PASSWORD"
    DOMAIN = "sydney.voip.ms"
    DESTINATION = "sip:+614XXXXXXXX@sydney1.voip.ms"

    # Register SIP account
    register(USERNAME, DOMAIN, PASSWORD)
    time.sleep(2)

    # Make a call
    print(f"Calling {DESTINATION}...")
    make_call(DESTINATION)
    time.sleep(3)  # Call duration

    # Hang up the call
    print("Hanging up...")
    hangup()

=


Step 4.1: Install Linphone Python Bindings

You can install the Linphone Python bindings using pip. First, install the dependencies:

sudo apt install python3-pip
sudo apt install python3-dev
sudo apt install liblinphone-dev

Then, install the Python bindings:

pip3 install linphone

5. Write Python Code to Make Calls

Now that you have Linphone installed and configured, you can write a Python script to make calls to Australian mobile numbers. Below is a simple Python example that uses Linphone to place a call.

Step 5.1: Python Code to Make Calls with Linphone

import linphone
import time

# Initialize the Linphone core
core = linphone.Core()

# Define the SIP credentials (replace with your actual credentials)
sip_username = 'your_sip_username'  # VoIP.ms SIP username
sip_password = 'your_sip_password'  # VoIP.ms SIP password
sip_domain = 'sip.voip.ms'          # VoIP.ms SIP server

# Register with VoIP.ms SIP server
identity = f"sip:{sip_username}@{sip_domain}"
account = core.create_account(identity, sip_password)

# Define the phone number to call (Australian mobile number)
to_number = "+61XXXXXXXXX"  # Replace with the actual Australian mobile number

# Make the call
call = core.invite(to_number)

# Wait for the call to be answered
while call.state != linphone.CallState.Ended:
    time.sleep(1)

# End the call when finished
core.delete_call(call)
print(f"Call ended with status: {call.state}")

# Cleanup the core (close Linphone session)
core.destroy()

How This Code Works:

The script initializes the Linphone core, registers with your VoIP.ms SIP account, and then makes a call to the Australian mobile number. The script waits until the call is answered and then ends the call after it's completed.

6. Test the Call

Run the script:

python3 linphone_call.py

If everything is set up correctly, your Raspberry Pi will make a call to the provided Australian mobile number, and you'll be able to talk through the microphone and speaker on the Raspberry Pi.

7. Troubleshooting

If you don’t hear anything or can’t make calls, check the SIP account settings in Linphone. Make sure your Raspberry Pi’s microphone and speaker are working. If there are issues with audio, ensure that your Pi has the correct audio input and output devices selected.

Conclusion

You can use Linphone on your Raspberry Pi, along with a VoIP service provider like VoIP.ms, to make calls to Australian mobile numbers. This setup allows you to initiate and manage calls programmatically using Python.

By using SIP, you're able to make voice calls over the internet, bypassing traditional phone lines, and leveraging a low-cost solution for international calls.

Step 2: Adding Physical Buttons

  • Connect Buttons to GPIO: Connect large tactile buttons to GPIO pins on the Raspberry Pi using jumper wires and a breadboard. Each button corresponds to a contact.
  • Write a Button Script: Create a Python script to detect button presses and initiate calls:
from gpiozero import Button
from subprocess import call
import pyttsx3

# Define buttons and actions
button1 = Button(17)  # GPIO pin 17
button2 = Button(27)  # GPIO pin 27
engine = pyttsx3.init()

def call_contact(contact_name):
    engine.say(f"Calling {contact_name}")
    engine.runAndWait()
    call(["linphonec", "-c", contact_name])  # Replace with actual VoIP command

button1.when_pressed = lambda: call_contact("Alice")
button2.when_pressed = lambda: call_contact("Bob")

print("System ready. Press buttons to make calls.")
while True:
    pass


  • Run the Script:
  • Save the script (e.g., call_buttons.py) and execute it:
python3 call_buttons.py

Step 3: Setting Up VoIP (Internet Calling)

Install a SIP Client: Install a lightweight VoIP client such as Linphone:

sudo apt install linphone-cli

Configure SIP Account:Sign up for a VoIP service provider (e.g., Linphone, Asterisk, or Twilio) and configure the SIP client. Test Calls: Test internet calls using the command line:

linphonec
> call sip:example@domain.com

Step 4: Mobile Phone Interface (Optional)

Bluetooth Pairing: Install Bluetooth tools:

sudo apt install bluetooth bluez

Pair the Raspberry Pi with the mobile phone:

bluetoothctl
  • Use Bluetooth Protocols: Use protocols like HFP (Hands-Free Profile) to route calls through the Raspberry Pi:
  • Install and configure ofono and pulseaudio.
  • Test Call Routing: Verify audio routing from the mobile phone to the Raspberry Pi.

Step 5: Accessibility Features

Text-to-Speech Feedback: Add TTS for actions like confirming button presses and errors:

engine.say("Call in progress.")
engine.runAndWait()

Voice Commands (Optional): Install voice recognition libraries like SpeechRecognition:

pip3 install SpeechRecognition

Step 6: Enclosure Design

  • Build a Custom Case: Use a 3D-printed or handmade case to house the Raspberry Pi, buttons, speaker, and microphone.
  • Label buttons with Braille or large text for accessibility.
  • Add Power Backup: Include a portable battery pack for uninterrupted usage.

Step 7: Deployment and Testing

  • Predefine Contacts: Configure contact details in the script or VoIP client.
  • Test Audio Quality: Test speaker and microphone placement for optimal clarity.
  • Stress-Test for Usability: Simulate real-world use with seniors to refine the interface.