logo elektroda
logo elektroda
X
logo elektroda

SMS gateway with web interface on Raspberry Pi

ghost666 26313 8
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • SMS gateway with web interface on Raspberry Pi
    The description below shows how you can convert a Raspberry Pi with a GSM modem to USB into a gateway for sending SMS via the web interface. The project was created using PHP and C #. The software that communicates with the modem is written in C #, and the web front-end in PHP. In addition, the system is equipped with a PostgreSQL database, which is used to store the history of sent SMSes. The GSM modem requires a SIM card - the cost of the card and the messages sent depends on the operator.

    Step 1: Required items

    You only need two devices: Raspberry Pi and a USB GSM modem with an active network card.

    Step 2: Software requirements

    Before we start struggling with the program on Raspberry Pi we must install:

    * Apache2
    * PHP
    * PHP PDO
    * PHP PostgreSQL
    * Mono for C #

    To install the Apache2 packages in the console, type:

    Code: Bash
    Log in, to see the code


    Then we insalize PHP:

    Code: Bash
    Log in, to see the code


    Immediately afterwards, the PostgreSQL database:

    Code: Bash
    Log in, to see the code


    And mono:

    Code: Bash
    Log in, to see the code


    Step 3: GSM modem for USB and Raspberry Pi

    First, connect the GSM modem to a free USB port and enter the lsusb command in the console. We should see our modem; e.g:

    Bus 001 Device 005: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard


    The serial port used by the modem will be described as / dev / ttyUSB0, so if we use the command:

    Code: Bash
    Log in, to see the code


    we will see a list of devices of this type:

    /dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2


    We can now test AT commands on our USB modem. To this end, we will install minicom, which will allow us to send commands to it. In the terminal enter:

    Code: Bash
    Log in, to see the code


    After installing the minicom we need to configure it. Enter the following command in the terminal:

    Code: Bash
    Log in, to see the code


    In the settings we select "Serial port setup" and if all configurations match, press "OK".

    Step 4: Creating the database

    Now we need to create a PostgreSQL database in which we will store information about sent SMSes. The table has the following fields:

    Field name Description
    sms_id Message ID number
    date_insert Date the entry was added
    date_send Date of sending the SMS
    number Recipient's phone number
    message Message content
    date_error If an error occurred - the date it occurred
    date_cancel Field informing about cancellation of sending an SMS


    And it is defined as follows:

    Code: SQL
    Log in, to see the code


    Step 5: Form for sending text messages

    Before we can use the following script, we must configure the connection to the database server. The author of the design uses an external server, but there is no problem to host the database locally on the Raspberry Pi.

    We need to complete the following data in the script:

    Code: PHP
    Log in, to see the code


    The script itself is very simple - it contains a form for sending an SMS. Sent messages are saved in the "sms" table described above.

    Code: PHP
    Log in, to see the code


    Step 6: Software for sending SMS

    Software that supports GSM modem is written in C #. To be able to use programs created in this language under Linux, we must have Mono installed. First, we need to configure several constants with database login data in the program:

    Code: C#
    Log in, to see the code


    The entire project in C # can be downloaded here .

    The project was compiled in MonoDevelop under Windows and then copied to 'Raspberry'. After compilation, we create an SMS-cronb folder in the home folder and copy the following files from the project there: Mono.Security.dll, Npgsql.dll and SMS-cron.exe.

    Then open the crontab:

    Code: Bash
    Log in, to see the code


    and add a single-line entry there and save:

    	* * * * * ./home/pi/SMS-cron/SMS-cron.exe
    \

    Thanks to this, every minute SMS-cron will start and check and the "sms" table with new SMSes to be sent.

    The SMS gateway is ready

    SMS gateway with web interface on Raspberry Pi


    Source: http://geek.adachsoft.com/home/article/id/20/n/Raspberry-PI-SMS-sender/refid/fb

    Cool? Ranking DIY
    Do you have a problem with Raspberry? Ask question. Visit our forum Raspberry.
    About Author
    ghost666
    Translator, editor
    Offline 
    ghost666 wrote 11960 posts with rating 10222, helped 157 times. Live in city Warszawa. Been with us since 2003 year.
  • ADVERTISEMENT
  • #2 16478728
    eDZio
    Level 16  
    I do not see that this gate has the ability to receive text messages, only send. It is probably better to use Gammu SMSD on Linux, it can act as a deamon, it supports various databases, it can use files instead of the database. The above is only a curiosity, proof that it can be done.
  • #3 16480074
    perfi
    Level 14  
    Some time ago I wrote a soft that allows you to turn your Android phone into an SMS gateway (commands are sent using REST). If interested, please refer to https://www.elektroda.pl/rtvforum/topic3253249.html

    I am writing about this because it seems simpler to me than the above solution, although you need a computer to issue REST commands ...
  • ADVERTISEMENT
  • #4 16481119
    Hetii
    Level 17  
    And is it sometimes easier and cheaper to use such a module?
    Cost 3.41 $ + 2 for esp8266 as an http / rest server.

    SMS gateway with web interface on Raspberry Pi
  • ADVERTISEMENT
  • #5 16510686
    serafo
    Level 13  
    Hello,

    as an educational project - OK
    for practical use - I recommend smstools and a few tricks for saving the memory card in Rpi.

    Ser @ fin
  • ADVERTISEMENT
  • #6 16518421
    cypeks
    Level 12  
    Hetii wrote:
    And is it sometimes easier and cheaper to use such a module?
    Cost 3.41 $ + 2 for esp8266 as an http / rest server.

    You still need to write soft.
  • #7 16527499
    Hetii
    Level 17  
    cypeks wrote:
    Hetii wrote:
    And is it sometimes easier and cheaper to use such a module?
    Cost 3.41 $ + 2 for esp8266 as an http / rest server.

    You still need to write soft.


    You are welcome, Sim800l there is a simple control after AT, and as for esp I recommend it esp-open-rtos .

    Regards.
  • #8 16531103
    cypeks
    Level 12  
    AT commands are not a problem, but for this you have to make an additional interface, preferably with an address book, correspondence lists etc. with more ESP can soften, the more that the SPIFFS memory on which you can store this data is terribly free.
  • #9 17998001
    sebapulawy
    Level 12  
    where can you buy one of the above solutions?

Topic summary

The discussion revolves around creating an SMS gateway using a Raspberry Pi and a USB GSM modem, utilizing PHP for the web interface and C# for modem communication, with PostgreSQL for SMS history storage. Users express concerns about the gateway's inability to receive messages and suggest alternatives like Gammu SMSD for Linux, which supports various databases and file systems. Some participants propose using an Android phone as a simpler SMS gateway via REST commands. Others mention the cost-effectiveness of using modules like Sim800l and ESP8266 for similar functionalities, emphasizing the need for additional software development and user-friendly interfaces for practical applications.
Summary generated by the language model.
ADVERTISEMENT