How to install WhatsApp on Raspberry Pi to Send and Receive Messages

Published  July 8, 2019   6
How to install WhatsApp on Raspberry Pi to Send and Receive Messages

WhatsApp is one of the most popular and widely used messaging app but its only available for Smartphones and don’t work on computers. But there is a way to install it on palm sized computer Raspberry Pi and it works quite well using command line interface.

 

There is a Python library to access all capabilities of an official WhatsApp on Raspberry pi - Yowsup. It enables you to use your WhatsApp account to exchange messages without the original app with your contacts. This library allows the user to create a full-fledged custom WhatsApp client on Raspberry Pi.

Previously, it was easy to install WhatsApp on Raspberry using this library but from last few months this library is completely rewritten and many modifications have been done in the library, so installing process has become more tedious than before. Here we will explain the complete process of installing and configuring WhatsApp on Raspberry Pi.

For activating the WhatsApp on pi, you will need a new Phone no. as it won’t work with currently running WhatsApp no. So unfortunately for configuring Yowsup we still need a phone and a SIM card, but after the first step you can leave it alone.

So, let’s get started.

 

Requirements

  1. Raspberry Pi 2 or newer (with Raspbian Jessie or newer installed in it).
  2. Working Internet Connection

Here, we will use SSH to access Raspberry Pi on the laptop. You can use VNC or Remote Desktop connection on the laptop, or can connect your Raspberry pi with a monitor. Learn more about setting up Raspberry Pi headlessly here without a monitor.

 

Installing Yowsup (WhatsApp) Library in Raspberry Pi

1. First thing that we have to do is update and upgrade our Pi. It is good practice to update the Pi before installing any new library or package so that you can be sure to have most recent library. Run the below command to perform the update.

sudo apt-get update && sudo apt-get upgrade

Hit ‘y’ wherever ask for yes/no and wait for completion.

 

2. Install following dependencies as required by Yowsup library.

sudo apt-get install python-dev libncurses5-dev
sudo apt-get install build-essential libssl-dev libffi-dev python-dev

 

Now, install cryptography packages (required for encrypting the data used in WhatsApp) which is already installed in our Raspberry Pi but the version is not compatible as required by Yowsup library.

So, install required version using below command

pip install cryptography

 

3. Download the Yowsup library from GitHub using below command

git clone git://github.com/tgalal/yowsup.git

 

4. Go to yowsup directory using cd yowsup and install the downloaded library using following command

sudo python setup.py install

 

5. Now, we are ready to setup the WhatsApp account. First check whether the library is installed correctly or not. For this, run the given command

 

If you are getting the below output then library is installed correctly.

Installing Yowsup (WhatsApp) Library in Raspberry Pi

 

Setup WhatsApp Account on Raspberry Pi

After installing WhatsApp on Raspberry Pi, its time to activate and configure the WhatsApp on pi.

1. Save the country code “cc” and phone number in a file so that Yowsup client can fetch this information for authorization. Open nano editor using sudo nano config and save the info using ctrl+x as shown below.

sudo nano config
cc=91
phone=91xxxxxxxxxx

91 is the cc for India if you are outside of India use your cc and replace phone with your phone number. Make sure the phone number entered is not used by another WhatsApp account and the SIM card should be in phone because you will receive registration code in next step.

 

2. Now, register your WhatsApp account using below command.

yowsup-cli registration --config config --requestcode sms

 

After running the above command you will receive the six digit code through an SMS.

Setup WhatsApp Account on Raspberry Pi

 

3. Use that code to register the phone number using the command

yowsup-cli registration --config config --register xxx-xxx 

Replace xxx-xxx with the code you received on your phone.

 

After a second or two, you'll receive a response from WhatsApp on the Pi terminal as shown below

WhatsApp Account Register on Raspberry Pi

 

The response contains the password for your WhatsApp. The ID, shown by the arrow in above image, is your password without double quotes. Save this password in the same config file.

 

So, open the config file using nano editor and paste the id as

id=************************

 

Now, config file will look like this. Save this file.

WhatsApp Account Number on Raspberry Pi

 

Running the WhatsApp on Raspberry Pi

1. Now, we are all set to launch WhatsApp on Raspberry Pi. Run the below command to start the WhatsApp.
yowsup-cli demos --yowsup --config config

 

You will see following response from WhatsApp. We have to login now. Enter “/L” and hit enter. For exploring more commands you can type /help.

Running the WhatsApp on Raspberry Pi

 

If you are failed to login, restart your Raspberry Pi.

 

2. After login you are all set to send and receive messages.

Running WhatsApp on Raspberry Pi

 

For sending message to other WhatsApp number type the following command.

/message send 91********** "Your message"

 

Replace ********** with the receiver WhatsApp number. Sent and received messages will be shown on the same terminal as shown below.

Received Message on Pi Terminal Window

Received Message on Whastapp Messenger

 

So this is how the Raspberry Pi can be converted into a WhatsApp client to send and receive messages from another WhatsApp number. We can also implement the Home Automation using WhatsApp messages but the Yowsup library is not working properly for that purpose and the improvement is going on to use this functionality .

Video

Have any question realated to this Article?

Ask Our Community Members

Comments

"how to install whatsapp on raspberry pi" procedure

applied on PI 4  4GB recently bought

returns message in terminal on instruction as follows   ===>

pi@raspberrypi:~/yowsup $ yowsup-cli registration --config config --requestcode sms

pi@raspberrypi:~/yowsup $ yowsup-cli registration --config config --requestcode sms
E 2020-11-08 22:17:41,033 yowsup.config.manager - Could not find a config for profile=32xxxxxxxxx, paths checked: /home/pi/.config/yowsup/32xxxxxxxxx/config.json:/home/pi/.config/yowsup/32xxxxxxxxx/config.yo
yowsup-cli  v3.2.0
yowsup      v3.2.3

Copyright (c) 2012-2019 Tarek Galal
http://www.openwhatsapp.org

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http://openwhatsapp.org/yowsup/donate

W 2020-11-08 22:17:41,159 yowsup.common.http.warequest - Passing Config to WARequest is deprecated, pass a YowProfile instead
I 2020-11-08 22:17:41,591 yowsup.common.http.warequest - {"login":"32xxxxxxxxx","status":"fail","reason":"old_version"}

status: fail
reason: old_version
login: 32xxxxxxxxx

<==== end message

The config file edited with nano editor resulted in a text file named "config" in the pi/yowsup folder 

and containing only ==>

cc=32
phone=32xxxxxxxxx

<== end content where xxxxxxxxx is local gsm pphone number.

Tries wit adapted instructions as follows:

pi@raspberrypi:~ $ yowsup-cli registration --requestcode sms --phone 32xxxxxxxxx  --cc 32
pi@raspberrypi:~ $ yowsup-cli registration --requestcode sms --phone 32xxxxxxxxx  --cc 32 --mcc 206 --mnc 01
pi@raspberrypi:~ $ yowsup-cli registration --requestcode sms --phone 32xxxxxxxxx  --cc 32 --mcc 206
pi@raspberrypi:~ $ yowsup-cli registration --requestcode sms --phone 32xxxxxxxxx  --cc 32 --mcc 206 --mnc 00

all with same error.

Any idee if syntax instruction has been changed recently ? 

Is your procedure recent.

Thanks in advance

Daniel

 

Hello.

I can´t setup my raspberry 4 (raspbian) with whatsApp, each time i try the message "old version" is raised.

  • Raspbian GNU/Linux 10 (buster)
  • yowsup-cli  v3.2.0
  • yowsup      v3.2.3
  • status: b'fail'
  • reason: b'old_version'
I made every step showed in this article and all was ok until the last.
Don´t know how to fix the error or how to follow with installation.
Anybody have an idea how to continue,
I apreciate any indication in this matter, many thanks

Hi,

i have followed every step but i am getting following error when i am trying t0 run  pi@raspberrypi:~/yowsup $ yowsup-cli 

ERROR Message: 
Traceback (most recent call last):
  File "/usr/local/bin/yowsup-cli", line 4, in <module>
    __import__('pkg_resources').run_script('yowsup==3.3.0', 'yowsup-cli')
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 666, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1437, in run_script
    .format(**locals()),
pkg_resources.ResolutionError: Script 'scripts/yowsup-cli' not found in metadata at '/home/pi/.local/lib/python3.7/site-packages/yowsup-3.3.0.dist-info'
 

I have checked that all dependencies are installed. Does anybody has a clue ?