0

SIM808 Without Serial Monitor
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

SIM808 Without Serial Monitor

by Joe3502 on Mon Jan 14, 2019 5:59 pm

A couple of colleagues and I are working on a project after school for STEM. For our project, when a button is pushed, we would like the FONA 808 board to make a phone call to a preset number that is defined in the code and not in the serial monitor. We would like to design it in a way that it can be portable and only need to change the number when we code it differently. I have seen this done with many other SIM boards and the code is very simple, but my friends and I are limited on what we can do as far as code goes. We can do a lot of things but there are still things that we cannot code yet, like this. We have tried many different things and have researched this extensively. It doesn't look like the SIM808 is used all that often and I have only come across very few projects including this shield. Like I said, when we make a call via the serial monitor, it works perfectly fine, but now we need it to call said number when a button is pressed without having to be connected to the computer and run thought the serial monitor. Thanks in advance!

Joe3502
 
Posts: 19
Joined: Mon Jan 14, 2019 5:45 pm

Re: SIM808 Without Serial Monitor

by adafruit_support_mike on Tue Jan 15, 2019 2:09 am

All you have to do is write the phone number as a string in your code:

Code: Select all | TOGGLE FULL SIZE
    fona.callPhone( "15558675309" );

adafruit_support_mike
 
Posts: 56416
Joined: Thu Feb 11, 2010 2:51 pm

Re: SIM808 Without Serial Monitor

by Joe3502 on Tue Jan 15, 2019 4:29 pm

yes I did that and it said that it "fona" could not be declared in this scope

Joe3502
 
Posts: 19
Joined: Mon Jan 14, 2019 5:45 pm

Re: SIM808 Without Serial Monitor

by Joe3502 on Tue Jan 15, 2019 4:34 pm

adafruit_support_mike wrote: fona.callPhone( "15558675309" );
yes I did that and it said that it "fona" could not be declared in this scope

Joe3502
 
Posts: 19
Joined: Mon Jan 14, 2019 5:45 pm

Re: SIM808 Without Serial Monitor

by adafruit_support_mike on Wed Jan 16, 2019 12:44 am

That means you haven't defined the correct variable.

Post the code you're using between CODE tags and we'll take a look.

adafruit_support_mike
 
Posts: 56416
Joined: Thu Feb 11, 2010 2:51 pm

Re: SIM808 Without Serial Monitor

by Joe3502 on Wed Jan 16, 2019 12:53 pm

Code: Select all | TOGGLE FULL SIZE
             
#include "Adafruit_FONA.h"

#define FONA_RX 2
#define FONA_TX 3
#define FONA_RST 4

Adafruit_FONA fona = Adafruit_FONA(FONA_RST);


// constants won't change:
const int buttonPin = 5;     // the number of the pushbutton pin
const int ledPin =  12;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
 
  pinMode(ledPin, OUTPUT);  // initialize the LED pin as an output:
 
  pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input:
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
    fona.callPhone("5555555555");
  } else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}

Joe3502
 
Posts: 19
Joined: Mon Jan 14, 2019 5:45 pm

Re: SIM808 Without Serial Monitor

by adafruit_support_mike on Thu Jan 17, 2019 1:58 am

That code compiles normally for me. What version of the Arduino IDE are you using?

adafruit_support_mike
 
Posts: 56416
Joined: Thu Feb 11, 2010 2:51 pm

Re: SIM808 Without Serial Monitor

by Joe3502 on Thu Jan 17, 2019 8:07 am

well i got the code to work because i realized that i did not define fona above...so it compiles and when I push the button, the LED lights up but the fona does not call. I have no idea why it wont call. I am using a Fona Sim808 +GPS shield. I have been staying after school for days trying to figure out why it will not call when i push the button. It looks like the code is okay...

Joe3502
 
Posts: 19
Joined: Mon Jan 14, 2019 5:45 pm

Re: SIM808 Without Serial Monitor

by adafruit_support_mike on Fri Jan 18, 2019 3:24 am

Post a photo showing your hardware and connections and we'll take a look. 800x600 images usually work best.

adafruit_support_mike
 
Posts: 56416
Joined: Thu Feb 11, 2010 2:51 pm

Re: SIM808 Without Serial Monitor

by Joe3502 on Fri Jan 18, 2019 8:28 am

that is the best picture that i can do...its inside of our enclosure but there is just an arduino uno underneath of the shield. The antenna is connected properly, the battery is connected properly, the GPS antenna is in, even though we arent using it yet, and we still have access to the USB port and the barrel connector for power to the arduino board. Like I said, the shield works when we use the FONAtest code and do all of the commands though the serial monitor but we have not been able to make a call with it without the FONAtest code. It has to be something with my code, because I have changed nothing with the hardware...
Attachments
IMG_5769.JPG
IMG_5769.JPG (465.78 KiB) Viewed 112 times

Joe3502
 
Posts: 19
Joined: Mon Jan 14, 2019 5:45 pm

Re: SIM808 Without Serial Monitor

by adafruit_support_mike on Sat Jan 19, 2019 2:40 am

The board in the photo doesn't have a SIM card.

You need a SIM card and a valid account for that card to connect to any cellular network.

adafruit_support_mike
 
Posts: 56416
Joined: Thu Feb 11, 2010 2:51 pm

Re: SIM808 Without Serial Monitor

by Joe3502 on Sat Jan 19, 2019 2:46 am

I do sir. I have a Ting sim card. I took that picture of that assembly before i got the sim card. I have already made calls using the FONAtest code that adafruit provided. It is something with my code. My hardware is all fine and my sim card is fine becuase I have already made calls with it. So what do you think is wrong with my code? There are not many other people that I can see that are using this shield and if they are they dont show how they code theirs. We are having a really hard time with this and our deadline is coming up soon.

Joe3502
 
Posts: 19
Joined: Mon Jan 14, 2019 5:45 pm

Re: SIM808 Without Serial Monitor

by adafruit_support_mike on Sat Jan 19, 2019 3:19 am

Looking back at the code above, it doesn't call fona.begin() anywhere.

Take a look at the setup() functions in the example sketches that come with the FONA library. Those show how to set things up.

adafruit_support_mike
 
Posts: 56416
Joined: Thu Feb 11, 2010 2:51 pm

Re: SIM808 Without Serial Monitor

by Joe3502 on Sat Jan 19, 2019 7:05 pm

Thank you very much Mike! I got everything to work. I did not start the 4800 baud serial to the FONA. That was my problem this whole time. I really appreciate your time. I am not in the process of getting it to send a text message to my buddies along with my GPS coordinates.

Joe3502
 
Posts: 19
Joined: Mon Jan 14, 2019 5:45 pm

Re: SIM808 Without Serial Monitor

by adafruit_support_mike on Sun Jan 20, 2019 1:29 am

Glad to hear things are working for you. Happy hacking!

adafruit_support_mike
 
Posts: 56416
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.


cron