GithubHelp home page GithubHelp logo

Comments (7)

blemasle avatar blemasle commented on August 29, 2024

Hi,

You've declared your simSerial as a HardwareSerial* (a pointer). If you look closely at the example code, I'm not. Hence the error you're facing. The library is taking a reference, so just feed it the simSerial variable (not the pointer) and it'll work nicely :)

from arduino-sim808.

mircoh avatar mircoh commented on August 29, 2024

Mm, first thanks to your answer! :)

Here is the code now, that starts printing: "N: Powering on SIM808..." but then it stops:

/**
 * Acquire a GPS position and display it on Serial
 */

#include <SIM808.h>
#include <ArduinoLog.h>

#include <HardwareSerial.h>

#define SIM_RST		5	///< SIM808 RESET
#define SIM_RX		6	///< SIM808 RXD
#define SIM_TX		7	///< SIM808 TXD
#define SIM_PWR		25	///< SIM808 PWRKEY
#define SIM_STATUS	8	///< SIM808 STATUS

#define SIM808_BAUDRATE 9600    ///< Control the baudrate use to communicate with the SIM808 module
#define SERIAL_BAUDRATE 9600   ///< Controls the serial baudrate between the arduino and the computer
#define NO_FIX_GPS_DELAY 3000   ///< Delay between each GPS read when no fix is acquired
#define FIX_GPS_DELAY  10000    ///< Delay between each GPS read when a fix is acquired

#define POSITION_SIZE   128     ///< Size of the position buffer
#define NL  "\n"

#if defined(__AVR__)
    typedef __FlashStringHelper* __StrPtr;
#else
    typedef const char* __StrPtr;
#endif

SIM808 sim808 = SIM808(SIM_RST, SIM_PWR, SIM_STATUS);
char position[POSITION_SIZE];

void setup() {
    Serial.begin(SERIAL_BAUDRATE);
    Log.begin(LOG_LEVEL_NOTICE, &Serial);

    Serial1.begin(SIM808_BAUDRATE);
    sim808.begin(Serial1);

    Log.notice(S_F("Powering on SIM808..." NL));
    sim808.powerOnOff(true);
    sim808.init();

    Log.notice(S_F("Powering on SIM808's GPS..." NL));
	sim808.powerOnOffGps(true);
}

void loop() {
    SIM808GpsStatus status = sim808.getGpsStatus(position, POSITION_SIZE);
    
    if(status < SIM808GpsStatus::Fix) {
        Log.notice(S_F("No fix yet..." NL));
        delay(NO_FIX_GPS_DELAY);
        return;
    }

    uint16_t sattelites;
    float lat, lon;
    __StrPtr state;

    if(status == SIM808GpsStatus::Fix) state = S_F("Normal");
    else state = S_F("Accurate");

    sim808.getGpsField(position, SIM808GpsField::GnssUsed, &sattelites);
    sim808.getGpsField(position, SIM808GpsField::Latitude, &lat);
    sim808.getGpsField(position, SIM808GpsField::Longitude, &lon);

    Log.notice(S_F("%s" NL), position);
    Log.notice(S_F("Fix type: %S" NL), state);
    Log.notice(S_F("Sattelites used : %d" NL), sattelites);
    Log.notice(S_F("Latitude : %F" NL), lat);
    Log.notice(S_F("Longitude : %F" NL), lon);
    
    delay(FIX_GPS_DELAY);
}

from arduino-sim808.

blemasle avatar blemasle commented on August 29, 2024

You're welcome. Could you please enable debugging output and paste the output logs ? It should help diagnose where the problem lies.

from arduino-sim808.

mircoh avatar mircoh commented on August 29, 2024

Ok, I have added this: #define _DEBUG 1

Where can I see the logs now? :) I am on Mac, in Serial Monitor there is nothing else to see.

from arduino-sim808.

blemasle avatar blemasle commented on August 29, 2024

It should be printed on your serial monitor. There is absolutely nothing in there ?
Also, you must define _DEBUG before including SIM808.h. If it still doesn't work (can't see why but hey), you can also directly turn _SIM808_DEBUG to 1.

from arduino-sim808.

mircoh avatar mircoh commented on August 29, 2024

Mmm, strange!
There is really nothing more, see here: Screenshot 2020-01-16 23 47 28

from arduino-sim808.

blemasle avatar blemasle commented on August 29, 2024

That doesn't feell right... Have you tried to add some Serial.print here and there to find where the code stops ? I cannot figure out how could you not reach that line.

from arduino-sim808.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.