Project Description

This tutorial is an exmple to control mbed platfrom from smart phone using mbed RPC. The smart phone application is based on kivy library of Python. This example performs below 3 major functions.

  • Control 3 color LED (On/Off) in the mbed platform
  • Check LED status (using TTS function in the Smartphone and check the color of the LED – Green,Blue,Red )
  • Get the temperature and humidity information from mbed platform(Using smart phone TTS function)

rpc-1

 

mbed HTTP RPC Server

If you click below links, you can download the codes for mbed rpc and HTTP server. At the mbed on-line compiler, if you compile below codes, you can control mbed platform using HTTP data.

 

  • ~ 8 : Register the GPIOs to RPC to control 3 color LEDs
  • 15 : Register Custom Function to RPC to acquire temperature and humidity value
  • 22~35 : Custom Function
    • If the request is received from mbed RPC client, it extracts the temperature and humidity data and transmits them to RPC client.
  • 54 : Register HTTPRPC Request

Smartphone Simple Application

This smart phone example is based on Python. For the UI, the kivy library is used. In order to operate the examle, you must do below

Download Qpython

If you click below link, you can download the Qpython program for python operation.

QPython Download

python

Please download and install kivy library for python UI and AndroidHelper for TTS(Text to Speech) function. If you follow below, you can get them.

python-1

python-2

Edit Source Code

It is very uncomfortable to write the source code at the smart phone. Fortunately, the Qpython supports the FTP functio to transmit the code from PC to smart phone.

<Setting for FTP>

python-3

<Upload Source Code to Smart Phone>

ftp-1

ftp-2

In this article, we made the ‘project3/RPC_TTS’ folder and copy the kivy.py and mbedRPC.py.

ftp-3

Below is the soure code of kivy.py

  • 15 ~ 65 : Initialize App Button and UI
  • 68 ~ 86 : Initialize mbed RPC library
  • 89 : Receive the temperature and humidity data frommbed platform and ouptut through TTS
  • 93 ~ 109 : LED1/2/3 On/Off
  • 111 ~ 114 : Check the LED color of mbed platform and output through TTS

smart_phone