Jump to content

Telegram Bot with SIM800 Module

Recommended Posts

Hello everybody,

I'm relatively new to the topic of Arduino ... For a few days now I've been trying to post messages in a Telegram group via a BOT with the Arduino UNO and a SIM800L module. Unfortunately without success so far. In the meantime I have already spent a few hours on the Internet but unfortunately did not achieve any success with a lot of testing, etc. Since I had written on a topic a long time ago, but received no answer there, now here is my new attempt.

This is what my code currently looks like:

#include <UniversalTelegramBot.h>
#include <TinyGsmClient.h>
#include <ArduinoHttpClient.h>

#include <SoftwareSerial.h>

#define TINY_GSM_MODEM_SIM800 // SIM800 declared as a module

SoftwareSerial SerialAT (2, 3); // RX, TX

TinyGsm modem (SerialAT);

// APN data because I am using a Congstar SIM card
const char apn [] = "internet.t-mobile."; // apn
const char user [] = "congstar."; // username
const char pass [] = "cs."; //passport

// Initialize Telegram BOT
#define BOTtoken "XXXX" // BOT TOKEN

TinyGsmClientSecure client (modem);
UniversalTelegramBot bot (BOTtoken, client);

int bot_mtbs = 1000; // mean time between scan messages
long bot_lasttime; // last time messages' scan has been done

void setup () {
    Serial.begin (9600);
    delay (10);

    // Set GSM module baud rate
    SerialAT.begin (9600);
    delay (3000);

    modem.sendAT (GF ("+ CIPSSL = 1")); // enable ssl. maybe don't need
    modem.waitResponse ();

    if (! modem.hasSSL ()) {
      Serial.println ("SSL is not supported by this modem");
      // delay (10000);

    // wait for network
    Serial.print (F ("Waiting for network ..."));
    if (! modem.waitForNetwork ()) {
      Serial.println ("fail");
      delay (10000);
    Serial.println ("OK");

    // connect to gprs
    Serial.print (F ("Connecting to"));
    Serial.print (apn);
    if (! modem.gprsConnect (apn, user, pass)) {
      Serial.println ("fail");
      delay (10000);
    } else {Serial.println ("OK");}

    // not needed actually
    IPAddress local = modem.localIP ();
    modem.waitResponse ();
    Serial.println (local);

    String chat_id = "XXXX"; / My chat ID
    String text = "test";
    String parses = "";

        Serial.println ("send message1");
        bot.sendMessage (chat_id, text, parses);
void loop () {

When checking the code, I always get the error:
error: #error "Please define GSM modem model"

According to the "TinyGSM -> TinyGsmClient.h" library, this error should only appear if you have not declared a SIM module. I did this at the beginning of the Skatch.
In addition, there is the following message:
Error compiling for the Arduino Uno board.

Can the fault lie in the fact that I am not using a Sim800C as with "Timmae3000" but a Sim800L? I would appreciate help, thank you.

If you have any questions, feel free to ask. I'll do my best to answer them.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...