Xinyuan-LilyGO / LilyGo-T-Call-SIM800

https://www.aliexpress.com/item/33045221960.html
484 stars 239 forks source link

GPS Connection #44

Closed schmeckm closed 3 years ago

schmeckm commented 4 years ago

Hi All If I want to connect to this Board a GPS Sensor like NEO-8M, what kind of pins shall I use?

Im not sure what I should use Hardware Serial oder Software Serial?

Markus

anthonyvage commented 4 years ago

Connect your GPS Module to Pin 32 and 33 (you can use other pins too). You have to specify these pins when you start serial connection.

HardwareSerial SerialGPS(2); .... SerialGPS.begin(9600, SERIAL_8N1, 32, 33);

slechta commented 4 years ago

Definitely use the hardware UART. It is more reliable as there is UART queue of events and interrupts available out of box.

DroneUniversity commented 4 years ago

Dear All,

I am also having a problem. I have connected a TF Mini Lidar to the default RX and TX pins of the board and I do get silly alphanumeric results on my Serial Monitor.

The problem for me that I am having trouble in understanding is that I already have a "Serial2.begin(115200);" command in void setup, which is used for connecting the dev board to Cayenne dashboard.

How could I setup alternative pins for reception of the Lidar's output and not get confused with the already Serial2.begin(115200) command I have?

Thank you in advance Spyros

UCIS commented 4 years ago

As this board uses the ESP32 chip, which has a GPIO matrix feature, you can use almost any pin (combination) for any peripheral. You can use Serial0, 1 and 2 simultaneously with any of the available GPIO pins using Serial0/1/2.begin(9600, SERIAL_8N1, rx_pin, tx_pin);. Just make sure you do not use an input only pin for TX.

You can even change the pins assigned to Serial0/1/2 later in your application by just calling begin again, and use the same HardwareSerial peripheral to communicate with different external components.

rajeshatuce commented 4 years ago

I am also facing similar problem, I am not getting any output of Neo6m in my serial monitor. Please let me know if any issue with code: // Please select the corresponding model

define SIM800L_IP5306_VERSION_20190610

// Define the serial console for debug prints, if needed

define DUMP_AT_COMMANDS

define TINY_GSM_DEBUG SerialMon

include "utilities.h"

// Set serial for debug console (to the Serial Monitor, default speed 115200)

define SerialMon Serial

// Set serial for AT commands (to the module)

define SerialAT Serial1

// Configure TinyGSM library

define TINY_GSM_MODEM_SIM800 // Modem is SIM800

define TINY_GSM_RX_BUFFER 1024 // Set RX buffer to 1Kb

include

ifdef DUMP_AT_COMMANDS

include

StreamDebugger debugger(SerialAT, SerialMon); TinyGsm modem(debugger);

else

TinyGsm modem(SerialAT);

endif

HardwareSerial SerialGPS(2);

define uS_TO_S_FACTOR 1000000ULL / Conversion factor for micro seconds to seconds /

define TIME_TO_SLEEP 15 / Time ESP32 will go to sleep (in seconds) /

define SERVER_CONNECTION_TIMEOUT 10000

define APN_CONNECTION_TIMEOUT 10000

define HTTP_CONNECTION_TIMEOUT 10000L

// Server details const char server[] = "abc.co.in"; const char resource[] = "/test";

// Your GPRS credentials (leave empty, if missing) const char apn[] = "airtelgprs.com"; // Your APN const char gprsUser[] = ""; // User const char gprsPass[] = ""; // Password const char simPIN[] = ""; // SIM card PIN code, if any

TinyGsmClient client(modem); const int port = 80;

include "FS.h"

include "SD.h"

include

SPIClass SPI1(HSPI);

define MY_CS 33

define MY_SCLK 25

define MY_MISO 27

define MY_MOSI 26

void setupModem() {

ifdef MODEM_RST

// Keep reset high
pinMode(MODEM_RST, OUTPUT);
digitalWrite(MODEM_RST, HIGH);

endif

pinMode(MODEM_PWRKEY, OUTPUT);
pinMode(MODEM_POWER_ON, OUTPUT);

// Turn on the Modem power first
digitalWrite(MODEM_POWER_ON, HIGH);

// Pull down PWRKEY for more than 1 second according to manual requirements
digitalWrite(MODEM_PWRKEY, HIGH);
delay(100);
digitalWrite(MODEM_PWRKEY, LOW);
delay(1000);
digitalWrite(MODEM_PWRKEY, HIGH);

// Initialize the indicator as an output
pinMode(LED_GPIO, OUTPUT);
digitalWrite(LED_GPIO, LED_OFF);

}

void turnOffNetlight() { SerialMon.println("Turning off SIM800 Red LED..."); modem.sendAT("+CNETLIGHT=0"); }

void turnOnNetlight() { SerialMon.println("Turning on SIM800 Red LED..."); modem.sendAT("+CNETLIGHT=1"); }

void initiateGPRSSubmitHTTPRequest(){ // Restart takes quite some time // To skip it, call init() instead of restart() SerialMon.println("Initializing modem..."); //modem.restart(); modem.init();

// Turn off network status lights to reduce current consumption
turnOffNetlight();

// Or, use modem.init() if you don't need the complete restart
String modemInfo = modem.getModemInfo();
SerialMon.print("Modem: ");
SerialMon.println(modemInfo);

// Unlock your SIM card with a PIN if needed
if (strlen(simPIN) && modem.getSimStatus() != 3 ) {
    modem.simUnlock(simPIN);
}

SerialMon.print("Waiting for network...");
if (!modem.waitForNetwork(240000L)) {
    SerialMon.println(" fail");
    delay(10000);
    return;
}
SerialMon.println(" OK");

// When the network connection is successful, turn on the indicator
digitalWrite(LED_GPIO, LED_ON);

if (modem.isNetworkConnected()) {
    SerialMon.println("Network connected");
}

SerialMon.print(F("Connecting to APN: "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
    SerialMon.println(" fail");
    delay(APN_CONNECTION_TIMEOUT);
    return;
}
SerialMon.println(" OK");

SerialMon.print("Connecting to ");
SerialMon.print(server);
if (!client.connect(server, port)) {
    SerialMon.println(" fail");
    delay(SERVER_CONNECTION_TIMEOUT);
    return;
}
SerialMon.println(" OK");

// Make a HTTP GET request:
SerialMon.println("Performing HTTP GET request...");
client.print(String("GET ") + resource + " HTTP/1.1\r\n");
client.print(String("Host: ") + server + "\r\n");
client.print("Connection: close\r\n\r\n");
client.println();

unsigned long timeout = millis();
while (client.connected() && millis() - timeout < HTTP_CONNECTION_TIMEOUT) {
    // Print available data
    while (client.available()) {
        char c = client.read();
        SerialMon.print(c);
        timeout = millis();
    }
}
SerialMon.println();

// Shutdown
client.stop();
SerialMon.println(F("Server disconnected"));

modem.gprsDisconnect();
SerialMon.println(F("GPRS disconnected"));

}

void initiateDeepSleep(){ // DTR is used to wake up the sleeping Modem // DTR is used to wake up the sleeping Modem // DTR is used to wake up the sleeping Modem

ifdef MODEM_DTR

bool res;

modem.sleepEnable();

delay(100);

// test modem response , res == 0 , modem is sleep
res = modem.testAT();
Serial.print("SIM800 Test AT result -> ");
Serial.println(res);

delay(1000);

Serial.println("Use DTR Pin Wakeup");
pinMode(MODEM_DTR, OUTPUT);
//Set DTR Pin low , wakeup modem .
digitalWrite(MODEM_DTR, LOW);

// test modem response , res == 1 , modem is wakeup
res = modem.testAT();
Serial.print("SIM800 Test AT result -> ");
Serial.println(res);

endif

// Make the LED blink three times before going to sleep
int i = 3;
while (i--) {
    digitalWrite(LED_GPIO, LED_ON);
    modem.sendAT("+SPWM=0,1000,80");
    delay(100);
    digitalWrite(LED_GPIO, LED_OFF);
    modem.sendAT("+SPWM=0,1000,0");
    delay(100);
}

//After all off
modem.poweroff();

SerialMon.println(F("Poweroff"));

esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);

esp_deep_sleep_start();

/*
The sleep current using AXP192 power management is about 500uA,
and the IP5306 consumes about 1mA
*/

} void setup() { // Set console baud rate SerialMon.begin(115200);

delay(10);

// Start power management
if (setupPMU() == false) {
    Serial.println("Setting power error");
}

// Some start operations
setupModem();

// Set GSM module baud rate and UART pins
SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
SerialGPS.begin(9600, SERIAL_8N1, 32, 33);//Neo6m Rx goes to pin 32 and Tx goes to Pin 33. Tried reversing but no luck

}

void loop() { if (SerialGPS.available()) { SerialMon.print(char(SerialGPS.read())); // read from gps, write to serial debug port } else{ SerialMon.println("Not available"); } //initiateGPRSSubmitHTTPRequest(); //initiateDeepSleep(); }

lewisxhe commented 3 years ago

Issues have not been active for a long time and will be closed. If there is a problem, please reopen it.