Connecting Flora to Fona

Wearable electronics: boards, conductive materials, and projects from Adafruit!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
benhp
 
Posts: 19
Joined: Fri Feb 20, 2015 11:38 am

Re: Connecting Flora to Fona

Post by benhp »

I am now able to get to this menu. Now to test a phone call
Attachments
Screen Shot 2015-02-26 at 12.36.30 PM.png
Screen Shot 2015-02-26 at 12.36.30 PM.png (265.33 KiB) Viewed 362 times

User avatar
benhp
 
Posts: 19
Joined: Fri Feb 20, 2015 11:38 am

Re: Connecting Flora to Fona

Post by benhp »

Success! I have successfully sent a text message with the device. Thank so much for helping me through this.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Connecting Flora to Fona

Post by adafruit_support_rick »

You're welcome!

User avatar
benhp
 
Posts: 19
Joined: Fri Feb 20, 2015 11:38 am

Re: Connecting Flora to Fona

Post by benhp »

Rick I have another question and it regards to the actual code it self. I am only interested in sending a text message, to a preprogrammed number. I am running into problems trying to set up the code to automatically send, so I do not need to be plugged into a computer, to then type the commands into the device. I was wondering if you could help me this one more time

Code: Select all

 case 's': {
      // send an SMS!
      char sendto[21], message[141];
      flushSerial();
      //Serial.print(F("Send to #"));
      sendto = This is where i was placing my phone number;
      Serial.println(sendto);
      Serial.print(F("Type out one-line message (140 char): "));
      readline(message, 140);
      Serial.println(message);
      if (!fona.sendSMS(sendto, message)) {
        Serial.println(F("Failed"));
      } else {
        Serial.println(F("Sent!"));
      }
      
      break;
    }

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Connecting Flora to Fona

Post by adafruit_support_rick »

Code: Select all

      sendto = This is where i was placing my phone number;
You can't do that. Instead, you can put the phone number in an initializer for the array.

Code: Select all

      char sendto[] = "1234567890";
      char message[] = "This is your message"
      flushSerial();
      if (!fona.sendSMS(sendto, message)) {
        Serial.println(F("Failed"));
      } else {
        Serial.println(F("Sent!"));
      }
      
      break;
Better yet, just put the phone number and message into the sendSMS call as a literal string:

Code: Select all

      if (!fona.sendSMS("1234567890", "This is your message")) {
        Serial.println(F("Failed"));
      } else {
        Serial.println(F("Sent!"));
      }
      
      break;

User avatar
benhp
 
Posts: 19
Joined: Fri Feb 20, 2015 11:38 am

Re: Connecting Flora to Fona

Post by benhp »

I am getting hung up on taking the device off the computer. I have a lsm9ds0 9-DOF sensor attached to my flora along with the fona device. I am trying to make the Sensor's accelerometer data once x axis hits -3000 or y axis hits -1800 to send a text message. I get the Fona to initialize but I don't get any data from the sensor.
It wont let me attatch my code because it says I have spam in the code of I M E I but I cant take those out or the code breaks.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Connecting Flora to Fona

Post by adafruit_support_rick »

Put spaces in the I M E I. I'll take the spaces out and try to run it.

User avatar
benhp
 
Posts: 19
Joined: Fri Feb 20, 2015 11:38 am

Re: Connecting Flora to Fona

Post by benhp »

Code: Select all

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_LSM9DS0.h>
#include <Adafruit_Sensor.h>  // not used in this demo but required!
#include "Adafruit_FONA.h"

#define FONA_RX 2
#define FONA_TX 3
#define FONA_RST 6

// i2c
Adafruit_LSM9DS0 lsm = Adafruit_LSM9DS0();
char replybuffer[255];
Adafruit_FONA fona = Adafruit_FONA(FONA_RST);
uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0);
void setupSensor()
{
  // 1.) Set the accelerometer range
  lsm.setupAccel(lsm.LSM9DS0_ACCELRANGE_2G);
  // 2.) Set the magnetometer sensitivity
  // 3.) Setup the gyroscope
  lsm.setupGyro(lsm.LSM9DS0_GYROSCALE_245DPS);
  //lsm.setupGyro(lsm.LSM9DS0_GYROSCALE_500DPS);
  //lsm.setupGyro(lsm.LSM9DS0_GYROSCALE_2000DPS);
}
void setup() 
{
  while (!Serial); // flora & leonardo
  // Try to initialise and warn if we couldn't detect the chip
  
  Serial.begin(115200);
  Serial.println(F("FONA basic test"));
  Serial.println(F("Initializing....(May take 3 seconds)"));

// make it slow so its easy to read!
//  fonaSS.begin(4800); // if you're using software serial
  Serial1.begin(4800); // if you're using hardware serial

  // See if the FONA is responding
  if (! fona.begin(Serial1)) {           // can also try fona.begin(Serial1) 
    //Serial.println(F("Couldn't find FONA"));
    while (1);
  }
  Serial.println(F("FONA is OK"));
  // Print SIM card i m e i number.
  char i m e i[15] = {0}; // MUST use a 16 character buffer for i m e i!
  uint8_t i m e iLen = fona.geti m e i(i m e i);
  if (i m e iLen > 0) {
    //Serial.print("SIM card I M E I: "); Serial.println(I M E I);
  }
!lsm.begin();
 
}

void loop() 
{
  lsm.read();
  Serial.print("Accel X: "); Serial.print((int)lsm.accelData.x); Serial.print(" ");
  Serial.print("Accel Y: "); Serial.print((int)lsm.accelData.y); Serial.print(" ");
  Serial.print("Z: "); Serial.println((int)lsm.accelData.z);     Serial.print(" ");
  
  Serial.print("Gyro X: "); Serial.print((int)lsm.gyroData.x);   Serial.print(" ");
  Serial.print("Gyro Y: "); Serial.print((int)lsm.gyroData.y);   Serial.print(" ");
  Serial.print("Z: "); Serial.println((int)lsm.gyroData.z);      Serial.println(" ");
  //Serial.print("Temp: "); Serial.print((int)lsm.temperature);    Serial.println(" ");
  delay(1400);
   if( (int)lsm.accelData.x > -3000 ||  (int)lsm.accelData.y > -1800 ){
    Serial.print("We are standing");
  }
  else {
     Serial.print("We are falling");
//      if (!fona.sendSMS("1234567890", "This is TEST")) {
//        Serial.println(F("Failed"));
//      } else {
//        Serial.println(F("Sent!"));
//      }
  
  }
}

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Connecting Flora to Fona

Post by adafruit_support_rick »

I'm getting sensor data here. You must have your LSM9DS0 hooked up wrong.

User avatar
benhp
 
Posts: 19
Joined: Fri Feb 20, 2015 11:38 am

Re: Connecting Flora to Fona

Post by benhp »

I get the sensor data when I run the Library example code. it should send the text message when that sensor reads anything less than -3000 but I do not get a message.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Connecting Flora to Fona

Post by adafruit_support_rick »

Mine isn't passing the test to do that. It keeps printing out "We are standing"

User avatar
benhp
 
Posts: 19
Joined: Fri Feb 20, 2015 11:38 am

Re: Connecting Flora to Fona

Post by benhp »

I get the same message now. It looks like it still needs to go through the serial monitor for the Fona to initialize. Is that true?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Connecting Flora to Fona

Post by adafruit_support_rick »

I don't think so. I added this to your code, but I did nothing else:

Code: Select all

  /* Initialise the sensor */
  if(!lsm.begin())
  {
    /* There was a problem detecting the LSM9DS0 ... check your connections */
    Serial.print(F("Ooops, no LSM9DS0 detected ... Check your wiring or I2C ADDR!"));
    while(1);
  }
  Serial.println(F("Found LSM9DS0 9DOF"));
    
  /* Setup the sensor gain and integration time */
  setupSensor();

User avatar
benhp
 
Posts: 19
Joined: Fri Feb 20, 2015 11:38 am

Re: Connecting Flora to Fona

Post by benhp »

Awesome I got it to work! I successfully was able to get the text message. I have one last question, and that is How do I get the flora to initialize the Fona? So that I don't have to go to the Serial.Monitor and initializing it that way.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Connecting Flora to Fona

Post by adafruit_support_rick »

Not sure what initialization you're referring to? Once you call fona.begin, it's ready to go.

Locked
Please be positive and constructive with your questions and comments.

Return to “Wearables”