Closed schmeckm closed 3 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);
Definitely use the hardware UART. It is more reliable as there is UART queue of events and interrupts available out of box.
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
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.
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 the serial console for debug prints, if needed
// Set serial for debug console (to the Serial Monitor, default speed 115200)
// Set serial for AT commands (to the module)
// Configure TinyGSM library
StreamDebugger debugger(SerialAT, SerialMon); TinyGsm modem(debugger);
TinyGsm modem(SerialAT);
HardwareSerial SerialGPS(2);
// 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;
SPIClass SPI1(HSPI);
void setupModem() {
// Keep reset high
pinMode(MODEM_RST, OUTPUT);
digitalWrite(MODEM_RST, HIGH);
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
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);
// 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(); }
Issues have not been active for a long time and will be closed. If there is a problem, please reopen it.
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