Hallo wieder und schönen Abend,
zu meiner Frage diesmal:
Ich will meinen ESP32 D1 Mini Board mit einem SIM800L Modul verbinden.
Da ich aus dem Internet gesehen habe, dass das ESP32 d1 mini auch auf Pin 17&16 UART hat, habe ich dort meine SIM800L angeschlossen.
Ich weis auch das SIM800L Modul stabile Spannung benötig, hab aber jetzt nichts da somit habe ich es auf den 3,3V Pin vom ESP32 angeschlosse.
Es Blinkt mal im Sekundentakt, was laut internet bedeutet, das es Power hat aber keine Verbindung vorhanden ist.
Ich bekomme immer den Error:
#error "Please define GSM modem model"
.
.
.
Fehler beim Kompilieren für das Board NodeMCU-32S.
Jedoch habe ich meiner meinung nach mit
#define TINY_GSM_MODEM_SIM800 // SIM800 declared as a module
das Modem Modell definiert
Hier noch mein derzeitiger testcode:
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include "RTClib.h"
#include <Wire.h>
#include <TinyGsmClient.h>
/*
#define I2C_Freq 100000
#define SDA_0 21
#define SCL_0 22
#define SDA_1 17
#define SCL_1 16
TwoWire I2C_0 = TwoWire(0);
TwoWire I2C_1 = TwoWire(1);
*/
#define TINY_GSM_MODEM_SIM800 // SIM800 declared as a module
// Your GPRS credentials (leave empty, if not needed)
const char apn[] = "internet.t-mobile.at"; // APN (example: internet.vodafone.pt) use https://wiki.apnchanger.org
const char gprsUser[] = "t-mobile"; // GPRS User
const char gprsPass[] = "tm"; // GPRS Password
// SIM card PIN (leave empty, if not defined)
const char simPIN[] = "1079";
/*
// TTGO T-Call pins
#define MODEM_RST 5
#define MODEM_PWKEY 4
#define MODEM_POWER_ON 23
*/
#define MODEM_TX 17
#define MODEM_RX 16
#define SERIAL_8N1 115200
// Set serial for debug console (to Serial Monitor, default speed 115200)
#define SerialMon Serial
// Set serial for AT commands (to SIM800 module)
#define SerialAT Serial1
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif
RTC_DS1307 rtc;
TinyGsmClient client(modem);
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
void setup () {
Serial.begin(115200);
SerialMon.begin(115200);
//I2C_0.begin(SDA_0 , SCL_0 , I2C_Freq );
//I2C_1.begin(SDA_1 , SCL_1 , I2C_Freq );
/*
// Set modem reset, enable, power pins
pinMode(MODEM_PWKEY, OUTPUT);
pinMode(MODEM_RST, OUTPUT);
pinMode(MODEM_POWER_ON, OUTPUT);
digitalWrite(MODEM_PWKEY, LOW);
digitalWrite(MODEM_RST, HIGH);
digitalWrite(MODEM_POWER_ON, HIGH);
*/
// Set GSM module baud rate and UART pins
SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
delay(3000);
// Restart SIM800 module, it takes quite some time
// To skip it, call init() instead of restart()
SerialMon.println("Initializing modem...");
modem.restart();
// use modem.init() if you don't need the complete restart
// Unlock your SIM card with a PIN if needed
if (strlen(simPIN) && modem.getSimStatus() != 3 ) {
modem.simUnlock(simPIN);
}
//#ifndef ESP8266
//while (!Serial); // wait for serial port to connect. Needed for native USB
//#endif
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
abort();
}
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running, let's set the time!");
// When time needs to be set on a new device, or after a power loss, the
// following line sets the RTC to the date & time this sketch was compiled
//rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
rtc.adjust(DateTime(2022, 07, 31, 21, 11, 0));
}
// When time needs to be re-set on a previously configured device, the
// following line sets the RTC to the date & time this sketch was compiled
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
rtc.adjust(DateTime(2022, 07, 31, 21, 15, 0));
}
void loop () {
SerialMon.print("Connecting to APN: ");
SerialMon.print(apn);
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
SerialMon.println(" fail");
}
else {
SerialMon.println(" OK");
modem.gprsDisconnect();
SerialMon.println(F("GPRS disconnected"));
}
DateTime now = rtc.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
}
Wie gesagt Pining:
SIM800L -> ESP32 d1 mini
Vcc _> 3,3V
GND -> GND
RXD -> GPIO17
TXD -> GPIO16
Hier der Link zum Pinout vom ESP32 d1 mini:
https://sthack.eu/wiki/wemos-mini-d1-esp32/
Hier das Datenblatt zum SIM800L:
SIM800L DE.pdf (3,5 MB)
Hab auch über die Lib GSMSim.h mit diesem Code versucht:
/*
* GSMSim Example
*
* GSMSim_Module_Info.ino
*
* By Erdem ARSLAN
* Version: v.2.0.1
*
* The MIT License (MIT)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <GSMSim.h>
// You can use any Serial interface. I recommended HardwareSerial. Please use the library with highiest baudrate.
// In examples, i used HardwareSerial. You can change it anymore.
#define RESET_PIN 34 // you can use any pin.
GSMSim gsm(Serial1, RESET_PIN);
void setup() {
Serial1.begin(115200); // If you dont change module baudrate, it comes with auto baudrate.
while(!Serial1) {
; // wait for module for connect.
}
Serial.begin(115200); // Serial for debug...
// Init module...
gsm.init(); // use for reseting module. Use it if you dont have any valid reason.
// Module Manifacturer
Serial.print("Module Manifacturer... ");
Serial.println(gsm.moduleManufacturer());
delay(1000);
// Module Manifacturer
Serial.print("Module Model... ");
Serial.println(gsm.moduleModel());
delay(1000);
// Module Manifacturer
Serial.print("Module Revision... ");
Serial.println(gsm.moduleRevision());
delay(1000);
// Module Manifacturer
Serial.print("Module IMEI... ");
Serial.println(gsm.moduleIMEI());
delay(1000);
// For other methods please look at readme.txt file.
}
void loop() {
// Use your Serial interface...
if(Serial1.available()) {
Serial.println(Serial1.readString());
}
// put your main code here, to run repeatedly:
}
Module Manifacturer...
Module Model...
Module Revision...
Module IMEI...
Leider auch keinen erfolgt.
Vlt hat ja von euch Profis schon jemand damit Erfahrung und kennt die Probleme und wäre so nett sich die Zeit zu nehmen und mir zu helfen das mal zum laufen zu bringen.
Das versenden der daten danach, muss ich mir erst ansehen, aber wäre schon mal froh wenn es soweit funktioniert.
Danke
Lg