TTGO T-call Serial

Julianni
Posts: 1
Joined: Mon Jul 27, 2020 3:51 pm

TTGO T-call Serial

Postby Julianni » Mon Jul 27, 2020 3:58 pm

Hi,

I'm trying to connect Raspberry Pi to ttgo t-call card with serial pin.
I expected get Raspberry pi messages on pin 34 (Serial 2)
But the Serial seems always buzy.

Code: Select all

 
 // SIM card PIN (leave empty, if not defined)
const char simPIN[]   = "0000";

// Your phone number to send SMS: + (plus sign) and country code, for Portugal +351, followed by phone number
// SMS_TARGET Example for Portugal +351XXXXXXXXX
#define SMS_TARGET  "**********"

// Configure TinyGSM library
#define TINY_GSM_MODEM_SIM800      // Modem is SIM800
#define TINY_GSM_RX_BUFFER   1024  // Set RX buffer to 1Kb

#include <Wire.h>
#include <TinyGsmClient.h>

// TTGO T-Call pins
#define MODEM_RST            5
#define MODEM_PWKEY          4
#define MODEM_POWER_ON       23
#define MODEM_TX             27
#define MODEM_RX             26
#define I2C_SDA              21
#define I2C_SCL              22

// Connexion raspebby
#define RXD2 34
#define TXD2 33

// Set serial for AT commands (to SIM800 module)
#define SerialAT  Serial2  
TinyGsm modem(SerialAT);

/*ESP 32 */
const int PushButton = 35;
void setup() {
  // Button
  pinMode(PushButton, INPUT);
  digitalWrite(PushButton, HIGH);
  Serial.begin(115200);
  Serial.println("Serial ok");
  //Module GSM Set modem reset, enable, power pins
  pinMode(MODEM_PWKEY, OUTPUT);
  pinMode(MODEM_RST, OUTPUT);
  pinMode(MODEM_POWER_ON, OUTPUT);
  digitalWrite(MODEM_PWKEY, LOW);
  digitalWrite(MODEM_RST, HIGH);
  digitalWrite(MODEM_POWER_ON, HIGH);

  // Set GSM module baud rate and UART pins
  SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
  Serial.println("Initializing Serial2...");
  Serial2.begin(115200, SERIAL_8N1, RXD2, TXD2);
  Serial.println("Initializing ok");
  delay(3000);

  Serial.println("Initializing modem...");
  modem.restart();

  // Unlock your SIM card with a PIN if needed
  if (strlen(simPIN) && modem.getSimStatus() != 3 ) {
    modem.simUnlock(simPIN);
  }

  Serial.println("Ready!");
}

void loop() {
  // put your main code here, to run repeatedly:
  int Push_button_state = LOW;
  Push_button_state = digitalRead(PushButton);
  
  /*if ( Push_button_state == HIGH )
  { 
       Serial.println("Bouton on");
       String smsMessage = "Hello from ESP32!";
       
       if(modem.sendSMS(SMS_TARGET, smsMessage)){
        Serial.println(smsMessage);
       }
       else{
        Serial.println("SMS failed to send");
       }
       delay(500);
  }*/
   if ( Push_button_state == HIGH )
   {
    String s = "test";
    Serial.println(s);
    if(Serial2.available()) {
       Serial.println("free");
      Serial.println(Serial2.readString());
    }
    else{
      Serial.println("buzy");
    }
   }
} 
Where/ what is the problem?

Thanks advance for your help

Who is online

Users browsing this forum: Bing [Bot] and 13 guests