Skip to content

Python script for Raspberry PI (including 5) to send sms from SIM868 to Telegram

Notifications You must be signed in to change notification settings

LionZXY/SMS2Telegram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SIM868 Raspberry Pi 5 SMS Forwarder

Dockerised Python script for Raspberry PI (including 5) to send sms from SIM868 to Telegram

Installation

  1. Firstly you need to find out the SMSC of your sim/region. To do this:

    1. Insert your SIM into your Android device
    2. Dial the *#*#4636#*#* (to get to the system menu).
    3. Select "Phone information".
    4. Scroll down to the "SMSC" item
    5. If the SMSC number is not there, press "Refresh"

  2. Insert the SIM card into the module

  3. Install SIM868 in Raspberry Pi GPIO 40-pin port

  4. Set the jumper to B as below

  1. Enable serial on Raspberry Pi: Type sudo raspi-config in console -> Interfaces Options -> Serial Port -> No -> Yes
  1. Install docker (Instruction here)
  2. Clone this project in any folder and go to it
git clone https://github.com/LionZXY/SMS2Telegram
cd SMS2Telegram
  1. Create .env file with this fields:
Field Description Example
TG_TOKEN Telegram token for the bot, created in BotFather (read more here) 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
TG_CHAT_ID ID of the chat room where messages will be sent. I get this parameter by open https://api.telegram.org/bot%TG_TOKEN%/getUpdates in browser 1235433892
SERIAL_PORT The port through which the Raspberry PI and SIM868 communicate. For Raspberry Pi 4 it can be /dev/ttyS0. You can check this with minicom /dev/ttyAMA0
SMSC SMSC address, this may be unique for each operator/country +99599599999
REPORT_TIMEZONE Timezone to which message arrival time will be converted "Europe/London"

Example .env file is:

TG_TOKEN=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
TG_CHAT_ID=1235433892
SERIAL_PORT=/dev/ttyAMA0
SMSC=+99599599999
REPORT_TIMEZONE="Europe/London"
  1. Execute docker compose up -d. Warning: Important to build Docker image specifically on Raspberry Pi

Spreadsheet

  • Enable PDU Mode: AT+CMGF=0
  • Enable Text Mod: AT+CMGF=1
  • Set SMSC to +99599599999: AT+CSCA="+99599599999"
  • Switch to PDU mode: AT+CMGF=0
  • Receive all unread messages (PDU Mode only): AT+CMGL=0
  • Receive all messages (PDU Mode only): AT+CMGL=4
  • Receive all messages (TEXT mode only: AT+CMGL="ALL"
  • Read message with index 1: AT+CMGR=1
  • Delete message with index 1: AT+CMGD=1
  • Set up antenna detected with URC reporting: AT+CANT=1,1,10
  • Check signal quality: AT+CSQ

Resources

About

Python script for Raspberry PI (including 5) to send sms from SIM868 to Telegram

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published