/IOT-USTH

Remote Sensing and control of New Automatic Scan device

Primary LanguagePython

IOT USTH

Team

Members:

  • Do Duy Huy Hoang
  • Nguyen Dinh Mau

Project

  • Control raspberry Pi via smartphone
  • Student internship: Set up a Raspberry Pi to send SMS notifications
  • Features:
    • Number images record
    • Free storage capacity of SD card
    • Number images record
    • Power of the battery
    • ...(More to come!)

Dependencies

  • Linux ≥ 2.6.13
  • Python ≥ 2.4 (including Python 3.x)
  • Bash
  • Gammu
  • An USB Huawei Dcom or GSM module 800l

Hardware

Python 2.7 code to interface a cheap 2G SIM800L to a cheap Raspberry Pi 3

Connections

  • Hook up the SIM800 to the Pi Zero with a few wires:
SIM800 Pin Pi Zero Pin
5V Pin 2 - 5V
GND Pin 6 - GND
VDD Pin 4 - 5V
TX Pin 10 - GPIO15 - RX
RX Pin 8 - GPIO14 - TX
GND Pin 14 - GND
RST Pin -
- -
  • Insert your SIM card into the SIM800

Install Gammu (python-gammu and gammu-smsd can be skipped - depending on requirements)

Check python is installed on your computer

python --version
python3 --version

Use command

sudo apt-get update & apt-get upgrade 

sudo apt-get install gammu
sudo apt-get install python-gammu
sudo apt-get install gammu-smsd
sudo apt-get install libgammu-dev

Find port USB device connected to

Connect your DCOM to your Raspberry Pi then:

dmesg | grep tty

[7.578478] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB0
[7.697942] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB1

Config gammu

gammu-config

set port /dev/ttyUSB0

sudo gammu-config

set port /dev/ttyUSB0

Check connected

sudo gammu --identify

Device : /dev/ttyUSB0
Manufacturer : Huawei
Model : E220 (E220)
Firmware : 11.117.03.01.156
IMEI : 3XX19301XXXXXX3
SIM IMSI : 2XXXX923271XXX1

Test with a text message

echo "some message" | gammu --sendsms TEXT 07921XXXXXX

Run this app

git clone https://github.com/huyhoang8398/IOT-USTH
cd IOT-USTH
cd GSM
python GSM.py

Pyinotify

Install

Get the current stable version from PyPI and install it with pip

To install pip follow http://www.pip-installer.org/en/latest/installing.html

sudo pip install pyinotify

Watch a directory

Install pyinotify and run this command from a shell:

    $ python -m pyinotify -v /my-dir-to-watch

Run this script from Pi

git clone https://github.com/huyhoang8398/IOT-USTH
cd IOT-USTH
cd pyinotify
python inotify.py >> /home/pi/scann/test.txt

Test the result

cd /home/pi/scann
touch test.jpg
vi test.txt

Auto run at start up with crontab

sudo apt-get install crontab

To config crontab use:

crontab -e

Added script files

cd bin
chmod +x info.sh
./info.sh

Upgrade 15/06/2018

sudo apt-get install inotifytools
inotifywait -e modify,delete,create -m -r --timefmt '%F-%T' --format '%:e | %f | %T' <watch-dir> -o <output-file>