Hello Everybody, Rui & Sara!
I have a ESP32 TTGO-T-CALL and I read Yours tutorial regarding this device (SMS sending using DS18B20 with temperature tresholds).
I would like make a car security system, which call me by phone, if the PIR sensor have sign, which make a otside wake up from deep sleep. I wrote the code for that, but unfortunately it is working only with SMS sending.
My code working for SMS sendig and the same code not working for voice calling.
I wrote a simple code for voice calling, which working properly also.
The simple voice calling code, which working properly:
// SIM card PIN (leave empty, if not defined)
const char simPIN[] = “”;
// Your phone number to send SMS: + (plus sign) and country code, for Hungary +36, followed by phone number
String mobile_number = “+3630xxxxxx”;
// Configure TinyGSM library
#define TINY_GSM_MODEM_SIM800 // Modem is SIM800
#define TINY_GSM_RX_BUFFER 1024 // Set RX buffer to 1Kb
#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
// Set serial for debug console (to Serial Monitor, default speed 115200)
#define SerialMon Serial
// Set serial for AT commands (to SIM800 module)
#define SerialAT Serial1
// Define the serial console for debug prints, if needed
//#define DUMP_AT_COMMANDS
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif
#define IP5306_ADDR 0x75
#define IP5306_REG_SYS_CTL0 0x00
void setup() {
// Set console baud rate
SerialMon.begin(115200);
// 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);
delay(3000);
// Restart SIM800 module, it takes quite some time
// To skip it, call init() instead of restart()
SerialMon.println(“Initializing modem…”);
modem.restart();
// use modem.init() if you don’t need the complete restart
// Unlock your SIM card with a PIN if needed
if (strlen(simPIN) && modem.getSimStatus() != 3 ) {
modem.simUnlock(simPIN);
}
}
void loop() {
modem.callNumber(mobile_number);
delay(10000);
}
The deep sleep code, with PIR wake up and SMS sending, which working properly also:
#define BUTTON_PIN_BITMASK 0x200000000 // 2^33 in hex
RTC_DATA_ATTR int bootCount = 0;
const int ledPin = 25; // the number of the LED pin Vigyázni, hogy ne ütközzön a Modem-nél megadott PIN-ekkel!!!!!!!!!!!!!!!!
// SIM card PIN (leave empty, if not defined)
const char simPIN[] = “”;
// Your phone number to send SMS: + (plus sign) and country code, for Hungary +36, followed by phone number
// SMS_TARGET Example for Hungary +36XXXXXXXXX
#define SMS_TARGET “+3630xxxxx”
// Your phone number to send SMS: + (plus sign) and country code, for Hungary +36, followed by phone number
String mobile_number = “+3630xxxxxx”;
// Configure TinyGSM library
#define TINY_GSM_MODEM_SIM800 // Modem is SIM800
#define TINY_GSM_RX_BUFFER 1024 // Set RX buffer to 1Kb
#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
// Set serial for debug console (to Serial Monitor, default speed 115200)
#define SerialMon Serial
// Set serial for AT commands (to SIM800 module)
#define SerialAT Serial1
// Define the serial console for debug prints, if needed
//#define DUMP_AT_COMMANDS
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif
#define IP5306_ADDR 0x75
#define IP5306_REG_SYS_CTL0 0x00
void sendSMS_out(){
// To send an SMS, call modem.sendSMS(SMS_TARGET, smsMessage)
String smsMessage = “Hello from ESP32 deep-sleep!”;
if(modem.sendSMS(SMS_TARGET, smsMessage)){
SerialMon.println(smsMessage);
}
else{
SerialMon.println(“SMS failed to send”);
}
}
/*
Method to print the reason by which ESP32
has been awaken from sleep
*/
void print_wakeup_reason(){
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
switch(wakeup_reason)
{
case ESP_SLEEP_WAKEUP_EXT0 : {
Serial.println(“Wakeup caused by external signal using RTC_IO”);
digitalWrite(ledPin, HIGH);
sendSMS_out();
delay(1000);
digitalWrite(ledPin, LOW);
break;
}
case ESP_SLEEP_WAKEUP_EXT1 : Serial.println(“Wakeup caused by external signal using RTC_CNTL”); break;
case ESP_SLEEP_WAKEUP_TIMER : Serial.println(“Wakeup caused by timer”); break;
case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println(“Wakeup caused by touchpad”); break;
case ESP_SLEEP_WAKEUP_ULP : Serial.println(“Wakeup caused by ULP program”); break;
default : Serial.printf(“Wakeup was not caused by deep sleep: %d\n”,wakeup_reason); break;
}
}
void setup(){
// Set console baud rate
SerialMon.begin(115200);
pinMode(ledPin, OUTPUT);
// 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);
delay(3000);
// Restart SIM800 module, it takes quite some time
// To skip it, call init() instead of restart()
SerialMon.println(“Initializing modem…”);
modem.restart();
// use modem.init() if you don’t need the complete restart
// Unlock your SIM card with a PIN if needed
if (strlen(simPIN) && modem.getSimStatus() != 3 ) {
modem.simUnlock(simPIN);
}
//Increment boot number and print it every reboot
++bootCount;
Serial.println(“Boot number: ” + String(bootCount));
//Print the wakeup reason for ESP32
print_wakeup_reason();
/*
First we configure the wake up source
We set our ESP32 to wake up for an external trigger.
There are two types for ESP32, ext0 and ext1 .
ext0 uses RTC_IO to wakeup thus requires RTC peripherals
to be on while ext1 uses RTC Controller so doesnt need
peripherals to be powered on.
Note that using internal pullups/pulldowns also requires
RTC peripherals to be turned on.
*/
esp_sleep_enable_ext0_wakeup(GPIO_NUM_33,1); //1 = High, 0 = Low
//If you were to use ext1, you would use it like
//esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH);
//Go to sleep now
Serial.println(“Going to sleep now”);
delay(1000);
esp_deep_sleep_start();
Serial.println(“This will never be printed”);
}
void loop(){
//This is not going to be called
}
And last, the similar code for voice calling instead SMS sending, which is not working:
#define BUTTON_PIN_BITMASK 0x200000000 // 2^33 in hex
RTC_DATA_ATTR int bootCount = 0;
const int ledPin = 25; // the number of the LED pin Vigyázni, hogy ne ütközzön a Modem-nél megadottal !!!!!!!!!!!!!!
// SIM card PIN (leave empty, if not defined)
const char simPIN[] = “”;
// Your phone number to send SMS: + (plus sign) and country code, for Hungary +36, followed by phone number
String mobile_number = “+3630xxxxxx”;
// Configure TinyGSM library
#define TINY_GSM_MODEM_SIM800 // Modem is SIM800
#define TINY_GSM_RX_BUFFER 1024 // Set RX buffer to 1Kb
#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
// Set serial for debug console (to Serial Monitor, default speed 115200)
#define SerialMon Serial
// Set serial for AT commands (to SIM800 module)
#define SerialAT Serial1
// Define the serial console for debug prints, if needed
//#define DUMP_AT_COMMANDS
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif
#define IP5306_ADDR 0x75
#define IP5306_REG_SYS_CTL0 0x00
/*
Method to print the reason by which ESP32
has been awaken from sleep
*/
void print_wakeup_reason(){
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
switch(wakeup_reason)
{
case ESP_SLEEP_WAKEUP_EXT0 : {
Serial.println(“Wakeup caused by external signal using RTC_IO”);
digitalWrite(ledPin, HIGH);
modem.callNumber(mobile_number);
delay(1000);
digitalWrite(ledPin, LOW);
break;
}
case ESP_SLEEP_WAKEUP_EXT1 : Serial.println(“Wakeup caused by external signal using RTC_CNTL”); break;
case ESP_SLEEP_WAKEUP_TIMER : Serial.println(“Wakeup caused by timer”); break;
case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println(“Wakeup caused by touchpad”); break;
case ESP_SLEEP_WAKEUP_ULP : Serial.println(“Wakeup caused by ULP program”); break;
default : Serial.printf(“Wakeup was not caused by deep sleep: %d\n”,wakeup_reason); break;
}
}
void setup(){
// Set console baud rate
SerialMon.begin(115200);
// 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);
delay(3000);
// Restart SIM800 module, it takes quite some time
// To skip it, call init() instead of restart()
SerialMon.println(“Initializing modem…”);
modem.restart();
// use modem.init() if you don’t need the complete restart
// Unlock your SIM card with a PIN if needed
if (strlen(simPIN) && modem.getSimStatus() != 3 ) {
modem.simUnlock(simPIN);
}
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
delay(1000); //Take some time to open up the Serial Monitor
//Increment boot number and print it every reboot
++bootCount;
Serial.println(“Boot number: ” + String(bootCount));
//Print the wakeup reason for ESP32
print_wakeup_reason();
/*
First we configure the wake up source
We set our ESP32 to wake up for an external trigger.
There are two types for ESP32, ext0 and ext1 .
ext0 uses RTC_IO to wakeup thus requires RTC peripherals
to be on while ext1 uses RTC Controller so doesnt need
peripherals to be powered on.
Note that using internal pullups/pulldowns also requires
RTC peripherals to be turned on.
*/
esp_sleep_enable_ext0_wakeup(GPIO_NUM_33,1); //1 = High, 0 = Low
//If you were to use ext1, you would use it like
//esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH);
//Go to sleep now
Serial.println(“Going to sleep now”);
delay(1000);
esp_deep_sleep_start();
Serial.println(“This will never be printed”);
}
void loop(){
//This is not going to be called
}
Have You some idea about, which is the reason why is not working?(In the code was given a real mobil number, I reset it only why there is no public for everybody.)
I readed TinyGSM library help and not find the solution for the solving of this problem.
I not find on the internet other solution during a week.
Best Regards:
Balázs Horváth
from Hungary
Hi.
Can you be a little more specific?
When you say that it doesn’t work, what happens?
Does the ESP32 crash? Does it give any error? Any compilation error?
Does it run the part of the code that makes the phone call?
Regards,
Sara
Hi!
I sent 3 code example for You.
I not understand why not working the 3. example. (The first and the second working.)
At the 3. sample the ESP not crashed, and the code was complied also without mistake, no error message received, but I did’nt received the waited reason, i.e. the given phone number not called.
Earlier I received the SMS message and in the short seperate code /not in deep sleep sample/ I received the voice call also by 1st and 2nd code.
The problem is: if I am putting the same code part in deep-sleep sample, the voice calling is not working, but SMS sending working in some deep-sleep sample. I did’nt understand why???
I worked several days on it, according to the TinyGSM library which was modified to TTGO-T-CALL specific pins.
I not understand, how is possible, that the code is working in 1. and 2. sample, and in 3. sample is not working, but it is writen according to same principals?
Thank You for reading,
Best Regards:
Balázs
Hi,
if You send me an e-mail adress I will send the Arduino codes in *.ino formats . It is an easiest way to check it and find the possible mistakes.
Best Regards:
Balázs
Hi again.
I’m not sure if I will be able to debug your code for you.
But, to share your code, you can use a link to pastebin or github.
Were you able to make phone calls with that board? Using a simple sample sketch?
Or the phone calls never worked?
I haven’t experimented phone calls with that board.
Regards,
Sara