0

Geofencing with Fona808 - Help!
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Geofencing with Fona808 - Help!

by hobbm013 on Thu Nov 26, 2020 1:22 pm

Hi everyone,

I am trying to follow this project https://learn.adafruit.com/geofencing-w ... dafruit-io

I have assembled the board as shown and uploaded the code without any issues. However when I open the serial monitor which should provide me with GPS data, all I get is this a line of reversed question marks

Double checked everything but can't see anything obviously wrong. Any advice would be appreciated

Matt

hobbm013
 
Posts: 5
Joined: Thu Nov 26, 2020 1:03 pm

Re: Geofencing with Fona808 - Help!

by rskup on Thu Nov 26, 2020 11:48 pm

Sorry if you already looked at this, but does the baud rate on your serial monitor match what is in your code?

I did a quick example with an Adafruit Feather, simply writing the word "Test" to the serial monitor once a second.

In the Feather's code I have: Serial.begin(115200);

Initially, the baud rate on the serial monitor is also 115200, and you see the word "Test" over and over. But when you switch the baud rate to something else, like 57600 as shown, you get goofy characters.

baudrate.jpg
baudrate.jpg (97.95 KiB) Viewed 238 times

rskup
 
Posts: 84
Joined: Sat Aug 01, 2020 9:04 pm

Re: Geofencing with Fona808 - Help!

by hobbm013 on Fri Nov 27, 2020 3:58 pm

Thank you, that has helped the text to be readable.

I now have another issue of the serial monitor reading 'Could Not Find FONA'

Anyone have any other suggestions?

hobbm013
 
Posts: 5
Joined: Thu Nov 26, 2020 1:03 pm

Re: Geofencing with Fona808 - Help!

by rskup on Fri Nov 27, 2020 5:57 pm

You have the 808?, part number 2542?

Can you post the code you uploaded?

rskup
 
Posts: 84
Joined: Sat Aug 01, 2020 9:04 pm

Re: Geofencing with Fona808 - Help!

by rskup on Sat Nov 28, 2020 9:48 am

Also, what is the status of the PWR and NET LEDs on your Fona board when you have everything powered up?

rskup
 
Posts: 84
Joined: Sat Aug 01, 2020 9:04 pm

Re: Geofencing with Fona808 - Help!

by hobbm013 on Sat Nov 28, 2020 7:37 pm

rskup wrote:Also, what is the status of the PWR and NET LEDs on your Fona board when you have everything powered up?


There are no LED’s illuminated

hobbm013
 
Posts: 5
Joined: Thu Nov 26, 2020 1:03 pm

Re: Geofencing with Fona808 - Help!

by rskup on Sat Nov 28, 2020 8:31 pm

Do you have the 808, part number 2542?

Can you post the code you uploaded to it?

rskup
 
Posts: 84
Joined: Sat Aug 01, 2020 9:04 pm

Re: Geofencing with Fona808 - Help!

by hobbm013 on Sun Nov 29, 2020 8:11 am

Code: Select all | TOGGLE FULL SIZE
// Geo Fencing project
// Author: Marco Schwartz
//
// Inspired by the code from Tony DiCola
//
// Released under a MIT license:
// https://opensource.org/licenses/MIT

// Libraries
#include <Adafruit_SleepyDog.h>
#include <SoftwareSerial.h>
#include "Adafruit_FONA.h"

// LED pin
const int ledPin = 6;

// Latitude & longitude for distance measurement
float latitude, longitude, speed_kph, heading, altitude;

// FONA pins configuration
#define FONA_RX              2   // FONA serial RX pin (pin 2 for shield).
#define FONA_TX              3   // FONA serial TX pin (pin 3 for shield).
#define FONA_RST             4   // FONA reset pin (pin 4 for shield)

// FONA instance & configuration
SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);     // FONA software serial connection.
Adafruit_FONA fona = Adafruit_FONA(FONA_RST);                 // FONA library connection.

void setup() {

  // Initialize serial output.
  Serial.begin(115200);
  Serial.println(F("Geofencing with Adafruit IO & FONA808"));

  // Initialize the FONA module
  Serial.println(F("Initializing FONA....(may take 10 seconds)"));
  fonaSS.begin(4800);

  if (!fona.begin(fonaSS)) {
    halt(F("Couldn't find FONA"));
  }

  fonaSS.println("AT+CMEE=2");
  Serial.println(F("FONA is OK"));

  // Use the watchdog to simplify retry logic and make things more robust.
  // Enable this after FONA is intialized because FONA init takes about 8-9 seconds.
  Watchdog.enable(8000);
  Watchdog.reset();

  // Enable GPS.
  fona.enableGPS(true);

}

void loop() {

  // Watchdog reset at start of loop--make sure everything below takes less than 8 seconds in normal operation!
  Watchdog.reset();

  // Grab a GPS reading.
  float latitude, longitude, speed_kph, heading, altitude;
  bool gpsFix = fona.getGPS(&latitude, &longitude, &speed_kph, &heading, &altitude);

  Serial.print("Latitude: ");
  printFloat(latitude, 5);
  Serial.println("");

  Serial.print("Longitude: ");
  printFloat(longitude, 5);
  Serial.println("");

  // Wait 5 secs
  delay(5000);

}

// Halt function called when an error occurs.  Will print an error and stop execution while
// doing a fast blink of the LED.  If the watchdog is enabled it will reset after 8 seconds.
void halt(const __FlashStringHelper *error) {
  Serial.println(error);
  while (1) {
    digitalWrite(ledPin, LOW);
    delay(100);
    digitalWrite(ledPin, HIGH);
    delay(100);
  }
}

void printFloat(float value, int places) {
  // this is used to cast digits
  int digit;
  float tens = 0.1;
  int tenscount = 0;
  int i;
  float tempfloat = value;

  // make sure we round properly. this could use pow from <math.h>, but doesn't seem worth the import
  // if this rounding step isn't here, the value  54.321 prints as 54.3209

  // calculate rounding term d:   0.5/pow(10,places)
  float d = 0.5;
  if (value < 0)
    d *= -1.0;
  // divide by ten for each decimal place
  for (i = 0; i < places; i++)
    d /= 10.0;
  // this small addition, combined with truncation will round our values properly
  tempfloat +=  d;

  // first get value tens to be the large power of ten less than value
  // tenscount isn't necessary but it would be useful if you wanted to know after this how many chars the number will take

  if (value < 0)
    tempfloat *= -1.0;
  while ((tens * 10.0) <= tempfloat) {
    tens *= 10.0;
    tenscount += 1;
  }


  // write out the negative if needed
  if (value < 0)
    Serial.print('-');

  if (tenscount == 0)
    Serial.print(0, DEC);

  for (i = 0; i < tenscount; i++) {
    digit = (int) (tempfloat / tens);
    Serial.print(digit, DEC);
    tempfloat = tempfloat - ((float)digit * tens);
    tens /= 10.0;
  }

  // if no places after decimal, stop now and return
  if (places <= 0)
    return;

  // otherwise, write the point and continue on
  Serial.print('.');

  // now write out each decimal place by shifting digits one by one into the ones place and writing the truncated value
  for (i = 0; i < places; i++) {
    tempfloat *= 10.0;
    digit = (int) tempfloat;
    Serial.print(digit, DEC);
    // once written, subtract off that digit
    tempfloat = tempfloat - (float) digit;
  }
}

hobbm013
 
Posts: 5
Joined: Thu Nov 26, 2020 1:03 pm

Re: Geofencing with Fona808 - Help!

by hobbm013 on Sun Nov 29, 2020 8:16 am

rskup wrote:Do you have the 808, part number 2542?

Can you post the code you uploaded to it?


This is the one - https://thepihut.com/products/adafruit- ... 7739996049

I believe it is Part Number 2542

hobbm013
 
Posts: 5
Joined: Thu Nov 26, 2020 1:03 pm

Re: Geofencing with Fona808 - Help!

by rskup on Sun Nov 29, 2020 3:56 pm

Ok, several questions, sorry in advance if they seem basic, my Fona 3G board and your 808 board are surprisingly similar, so some of what I'm asking is what I've learned getting my Fona 3G up and running.

Did you charge up the LiPo until the green light came on? The reason I ask that is because on my Fona 3G it will start behaving oddly and then shutdown when the LiPo is around 3.3 volts, so, first just making sure that your LiPo is charged up.

Can you upload a picture of your project so that the wiring is visible? The reason I'm asking that is because it turns out my Fona 3G has almost the same pinouts at the edge of the board as your 808. I use to run my Fona 3G off an Uno, so, thought I'd compare the wiring.

Last question, do you have a voltmeter in order to check some voltages on the Fona pins?

rskup
 
Posts: 84
Joined: Sat Aug 01, 2020 9:04 pm

Please be positive and constructive with your questions and comments.