WhatsApp on Raspberry Pi

266,447

257

136

Intro: WhatsApp on Raspberry Pi

In this tutorial we will see how to use WhatsApp with Raspberry Pi.
We will use the Yowsup library we had already used in these tutorials: WhatsApp message from Phidgets SBC , Phidgets WhatsApp - ask the status of your sensors.

These days the library has been completely rewritten and improved, so we will see how to install it and use it.

Yowsup is a python library that allows you to login and use the WhatsApp service and provides you with all capabilities of an official WhatsApp client, allowing you to create a full-fledged custom WhatsApp client.

You need:

a Raspberry Pi B or B+, with the latest version of Raspbian, or our MIcroSD Card 8GB Class 10 Raspbian preinstalled.

Step 1: Installation

Update the packages with

sudo apt-get update
sudo apt-get upgrade

Update firmware

sudo rpi-update

Prepare the system with the necessary components to Yowsup

sudo apt-get install python-dateutil
sudo apt-get install python-setuptools
sudo apt-get install python-dev
sudo apt-get install libevent-dev
sudo apt-get install ncurses-dev

Download the library with the command

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

navigate to the folder

cd yowsup

and install the library with the command

sudo python setup.py install

Step 2: Registration

After installing the library we have to register the device to use WhatsApp. Yowsup comes with a cross platform command-line frontend called yowsup-cli. It provides you with the options of registration, and provides a few demos such as a command line client.

WhatsApp registration involves 2 steps. First you need to request a registration code. And then you resume the registration with code you got.

Request a code with command

python yowsup-cli registration --requestcode sms --phone 39xxxxxxxxxx --cc 39 --mcc 222 --mnc 10

Replace with your data ,

cc is your country code in this example 39 is for Italy,

mcc is Mobile Country Code check your here

mnc is Mobile Network Code check your here

You should receive on your phone a sms message with a code like xxx-xxx

Send a message to request registration with this command, (replace xxx-xxx with code you received)

python yowsup-cli registration --register xxx-xxx --phone 39xxxxxxxxxx --cc 39

If all goes well, we should get a message like this

status: ok
  kind: free
  pw: xxxxxxxxxxxxxxxxxx=
  price: € 0,89
  price_expiration: 1416553637
  currency: EUR
  cost: 0.89
  expiration: 1445241022
  login: 39xxxxxxxxxxx
  type: existing

Warning

WhatsApp requires the registration of a number, and with that number you can use WhatsApp on only one device at a time, so it is preferable to use a new number.

WhatsApp can be used on one device at a time and if you will make many attempts to register the number, it could be banned. We recommend you using Telegram, see our tutorial

Step 3: Utilization

Create a file to save your credentials

sudo nano /home/pi/yowsup/config

with this content

## Actual config starts below ##
  cc=39 #if not specified it will be autodetected
  phone=39xxxxxxxxxx
  password=xxxxxxxxxxxxxxx=

Ok, we're ready for the test, Yowsup has a demo application in /home/pi/yowsup/yowsup/demos

Navigate to yowsup folder

cd /home/pi/yowsup

Start yowsup-cli demos with the command

yowsup-cli demos --yowsup --config config

You can see Yowsup prompt

If type "/help" you can see all available commands

First use the '/L' command for login; to send a message type

/message send 39xxxxxxxxxx "This is a message sent from Raspberry Pi"

replace xxx with the recipient number

If you respond with a message it will be displayed on Raspberry.

The possibilities of use are endless, for example you could use
WhatsApp to send messages in the home automation system seen in the tutorial Home Automation Raspberry and Phidgets part 2 or Home Automation Raspberry and Phidgets part 3

Follow us on social to stay informed.

www.emmeshop.eu

Share

    Recommendations

    • Tiny Home Contest

      Tiny Home Contest
    • Furniture Contest 2018

      Furniture Contest 2018
    • Fix It! Contest

      Fix It! Contest

    136 Discussions

    0
    None
    kbvigneshvicky

    5 months ago

    I have receving the registration errors wat to do to recover it

    1522645749986640435438.jpg
    0
    None
    LuisZ36

    Question 5 months ago

    Hello, I did all the steps of the tutorial ...... but it worked only once, that is, I got to send the message to the destination number, but I tried to send another message a second time, but I got the Authorization error denied, and I tried to register the number again and it turned out that the number was blocked.

    It is the second number that blocks :)

    Please help me.

    regards

    0
    None
    bisudw

    2 years ago

    i am getting this during registration:

    INFO:yowsup.common.http.warequest:{"status":"fail","reason":"old_version"}

    5 replies
    0
    None
    HaMZAK55bisudw

    Reply 1 year ago

    i m getting the same error aswell. if u found the solution plz do tell me

    0
    None
    RenanG18HaMZAK55

    Reply 1 year ago

    I'm have the same problem.

    HELP PLEASE

    0
    None
    ClebsonDRenanG18

    Reply 1 year ago

    edit yowsup/env/env_android.py and change:

    _MD5_CLASSES to 1I2weuZmVg+uL50+HXeSJw==

    and

    _VERSION to 2.16.328

    on yowsup/env/env.py

    change:

    DEFAULT to android

    0
    None
    armando.acevesjaimeClebsonD

    Reply 8 months ago

    Realice los cambios en los archivos que sugieres pero al ejecutar el comando de yowsup para el request code, me da el siguiente error:

    yowsup-cli v2.0.15

    yowsup v2.5.7

    Copyright (c) 2012-2016 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

    Traceback (most recent call last):

    File "yowsup-cli", line 368, in <module>

    if not parser.process():

    File "yowsup-cli", line 189, in process

    self.handleRequestCode(self.args["requestcode"], config)

    File "yowsup-cli", line 206, in handleRequestCode

    method

    File "/home/pi/yowsup/yowsup/registration/coderequest.py", line 41, in __init__

    self.addParam("token", YowsupEnv.getCurrent().getToken(p_in))

    File "/home/pi/yowsup/yowsup/env/env_android.py", line 55, in getToken

    clsDecoded = base64.b64decode(self.__class__._MD5_CLASSES)

    File "/usr/lib/python2.7/base64.py", line 78, in b64decode

    raise TypeError(msg)

    TypeError: Incorrect padding

    Agradeceria mucho su ayuda!

    0
    None
    simlam

    1 year ago

    Hi, Ihave problem with Yowsup. Anyone can help me to solve it? Regards

    status: fail

    reason: old_version

    login: 628xxxxxxxx

    pi@raspberrypi:~/yowsup $ ./setup.py build

    running build

    running build_py

    running egg_info

    writing requirements to yowsup2.egg-info/requires.txt

    error: [Errno 13] Permission denied: 'yowsup2.egg-info/requires.txt'

    1 reply
    0
    None
    nico3.1415926

    10 months ago

    I'm having a problem with this code:

    python yowsup-cli registration --requestcode sms --phone 39xxxxxxxxxx --cc 39 --mcc 222 --mnc 10

    If I wrote that in my terminal. The output said that it is failed because of an old_version. What can I do?

    0
    None
    jo888

    1 year ago

    I'm confuse. You don't need a simcard for this matter ? how?

    1 reply
    0
    None
    diy_blokejo888

    Reply 10 months ago

    yes you do, in your phone, to receive the registration code

    0
    None
    OrlandoP31

    1 year ago

    Please help. Took me hours to start sending messages. Now I get this.

    [connected]:/message send 8687895253 "Hello world!"

    [connected]:Traceback (most recent call last):

    File "/usr/local/bin/yowsup-cli", line 4, in <module>

    __import__('pkg_resources').run_script('yowsup2==2.5.2', 'yowsup-cli')

    File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 534, in run_script

    self.require(requires)[0].run_script(script_name, ns)

    File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1438, in run_script

    execfile(script_filename, namespace, namespace)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/EGG-INFO/scripts/yowsup-cli", line 368, in <module>

    if not parser.process():

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/EGG-INFO/scripts/yowsup-cli", line 268, in process

    self.startCmdline()

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/EGG-INFO/scripts/yowsup-cli", line 297, in startCmdline

    stack.start()

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/demos/cli/stack.py", line 26, in start

    self.stack.loop(timeout = 0.5, discrete = 0.5)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/stacks/yowstack.py", line 188, in loop

    asyncore.loop(*args, **kwargs)

    File "/usr/lib/python2.7/asyncore.py", line 216, in loop

    poll_fun(timeout, map)

    File "/usr/lib/python2.7/asyncore.py", line 156, in poll

    read(obj)

    File "/usr/lib/python2.7/asyncore.py", line 87, in read

    obj.handle_error()

    File "/usr/lib/python2.7/asyncore.py", line 83, in read

    obj.handle_read_event()

    File "/usr/lib/python2.7/asyncore.py", line 449, in handle_read_event

    self.handle_read()

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/network/layer.py", line 102, in handle_read

    self.receive(data)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/network/layer.py", line 110, in receive

    self.toUpper(data)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 79, in toUpper

    self.__upper.receive(data)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/stanzaregulator/layer.py", line 29, in receive

    self.processReceived()

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/stanzaregulator/layer.py", line 49, in processReceived

    self.toUpper(oneMessageData)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 79, in toUpper

    self.__upper.receive(data)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/auth/layer_crypt.py", line 65, in receive

    self.toUpper(payload)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 79, in toUpper

    self.__upper.receive(data)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/coder/layer.py", line 35, in receive

    self.toUpper(node)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 79, in toUpper

    self.__upper.receive(data)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/logger/layer.py", line 14, in receive

    self.toUpper(data)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 79, in toUpper

    self.__upper.receive(data)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/axolotl/layer_control.py", line 44, in receive

    self.toUpper(protocolTreeNode)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 79, in toUpper

    self.__upper.receive(data)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 194, in receive

    s.receive(data)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/axolotl/layer_send.py", line 64, in receive

    if not self.processIqRegistry(protocolTreeNode):

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/__init__.py", line 161, in processIqRegistry

    successClbk(protocolTreeNode, originalIq)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/axolotl/layer_base.py", line 51, in onSuccess

    entity = ResultGetKeysIqProtocolEntity.fromProtocolTreeNode(resultNode)

    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.2-py2.7.egg/yowsup/layers/axolotl/protocolentities/iq_keys_get_result.py", line 88, in fromProtocolTreeNode

    preKeyId = ResultGetKeysIqProtocolEntity._bytesToInt(preKeyNode.getChild("id").getData())

    AttributeError: 'NoneType' object has no attribute 'getChild'

    0
    None
    wasu79

    1 year ago

    hi, i have a problem, when i try to install the library with the command:

    sudo python setup.py install

    on the end of installation i have this error:

    error: Installed distribution six 1.8.0 conflicts with requirement six>=1.9

    anyone have a idea of the solution, please help me

    1 reply
    0
    None
    ChrisG437wasu79

    Reply 1 year ago

    please use sudo pip install --upgrade six :)

    0
    None
    UjeshK

    1 year ago

    hello.. what should we need to give in the password field of this section.

    ## Actual config starts below ##
    cc=39 #if not specified it will be autodetected
    phone=39xxxxxxxxxx
    password=xxxxxxxxxxxxxxx=

    0
    None
    eslondon

    1 year ago

    Hi all. What is the latest solution for the issue during registration:

    status: fail

    reason: old_version

    Any clues, will be very appreciated.

    e