Mithun_K_Das
Advanced Member level 3
- Joined
- Apr 24, 2010
- Messages
- 899
- Helped
- 24
- Reputation
- 48
- Reaction score
- 26
- Trophy points
- 1,318
- Location
- Dhaka, Bangladesh, Bangladesh
- Activity points
- 8,254
I've found this problem before, but just did not work with that code. But having the issue again with the same library file.
Adafruit_FONA.h library is pretty popular in Phone, GSM, etc. projects with Arduino. Used in different projects. But one problem is totally uncontrolled.
Once the caller ID detection function is used, the Arduino goes into some kind of uncontrolled loop after a few moments especially if other functions are used with the caller ID detection function.
The function works fine if it is used alone. I mean, no other task needs to do. Please check the video to find the Arduino behavior.
Once the Arduino falls into this situation, No reset works, no loop works. only power restarts bring it back to work.
Why does this happen and how can be solved?
Note that, this is a simple test project.
ino File
Adafruit_FONA.h library is pretty popular in Phone, GSM, etc. projects with Arduino. Used in different projects. But one problem is totally uncontrolled.
Once the caller ID detection function is used, the Arduino goes into some kind of uncontrolled loop after a few moments especially if other functions are used with the caller ID detection function.
The function works fine if it is used alone. I mean, no other task needs to do. Please check the video to find the Arduino behavior.
Once the Arduino falls into this situation, No reset works, no loop works. only power restarts bring it back to work.
Why does this happen and how can be solved?
--- Updated ---
Note that, this is a simple test project.
Code:
#include "Adafruit_FONA.h"
#define FONA_RST 5
#define FONA_RI_INTERRUPT 0
#include <EEPROM.h>
#include <SoftwareSerial.h>
#define FONA_RX 4
#define FONA_TX 3
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);
SoftwareSerial *fonaSerial = &fonaSS;
Adafruit_FONA fona = Adafruit_FONA(FONA_RST);
const int button1 = 12, button2 = 11, swtch = 9;
void setup()
{
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
pinMode(swtch, INPUT_PULLUP);
Serial.begin(115200);
Serial.println(F("Init..."));
fonaSerial->begin(4800);
if (! fona.begin(*fonaSerial))
{
Serial.println(F("GSM NOT FOUND"));
while (1);
}
Serial.println(F("FONA is OK"));
// Enable incoming call notification.
if (fona.callerIdNotification(true, FONA_RI_INTERRUPT))
{
Serial.println(F("C_id n. en"));
EEPROM.write(7,1);
}
}
void loop()
{
char phone[32] = {0};
// Check for an incoming call. Will return true if a call is incoming.
if (fona.incomingCallNumber(phone))
{
Serial.println(F("RING!"));
Serial.print(F("Phone Number: "));
Serial.println(phone);
if (digitalRead(button1) == LOW)
{
for (int k = 0; k < 12; k++)
{
EEPROM.update(101 + k, phone[k + 3]); delay(60);
Serial.print(phone[k + 3]);
}
char phn[12] = {0};
Serial.println(F("Saved Phn number: "));
for (int i = 0; i < 12; i++)
{
phn[i] = EEPROM.read(101 + i);
}
Serial.println(phn);
//reject the call
if (! fona.hangUp()) {
Serial.println(F("Failed"));
} else {
Serial.println(F("OK!"));
}
delay(1000);
String text = "1st number: " + String(phn);
int length_text = text.length() + 1;
char sms_text[length_text];
text.toCharArray(sms_text, length_text);
if (!fona.sendSMS(phn, sms_text))
{
Serial.println(F("Failed"));
} else {
Serial.println(F("Sent!"));
}
EEPROM.update(1,1);
}
if (digitalRead(button2) == LOW)
{
for (int k = 0; k < 12; k++)
{
EEPROM.update(201 + k, phone[k + 3]); delay(60);
Serial.print(phone[k + 3]);
}
char phn[12] = {0};
Serial.println(F("Saved Phn number: "));
for (int i = 0; i < 12; i++)
{
phn[i] = EEPROM.read(201 + i);
}
Serial.println(phn);
//reject the call
if (! fona.hangUp()) {
Serial.println(F("Failed"));
} else {
Serial.println(F("OK!"));
}
delay(1000);
String text = "2nd number: " + String(phn);
int length_text = text.length() + 1;
char sms_text[length_text];
text.toCharArray(sms_text, length_text);
if (!fona.sendSMS(phn, sms_text))
{
Serial.println(F("Failed"));
} else {
Serial.println(F("Sent!"));
}
EEPROM.update(2,1);
}
}//fona end
}
//
--- Updated ---
ino File
Attachments
Last edited: