Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: **GSM Initialization**
- - Source Code NOT compiled for: ESP32 DevKit V1
- - Source Code created on: 2025-01-25 19:44:38
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Get ntc time in three variable */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <SoftwareSerial.h> //https://github.com/plerup/espsoftwareserial
- #include <Sim800L.h> //https://github.com/vittorioexp/Sim800L-Arduino-Library-revised
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void getNtcTime(int &day, int &month, int &year, int &hour, int &minute, int &second);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t GSM_SIM800L_RING_PIN_RX2 = RX2;
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t GSM_SIM800L_RST_PIN_D14 = 14;
- const uint8_t GSM_SIM800L_DTR_PIN_TX2 = TX2;
- /***** DEFINITION OF Software Serial *****/
- const uint8_t GSM_SIM800L_Serial_PIN_SERIAL_TX_D4 = 4;
- const uint8_t GSM_SIM800L_Serial_PIN_SERIAL_RX_D13 = 13;
- EspSoftwareSerial::UART GSM_SIM800L_Serial;
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool GSM_SIM800L_RST_PIN_D14_rawData = 0;
- bool GSM_SIM800L_DTR_PIN_TX2_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float GSM_SIM800L_RST_PIN_D14_phyData = 0.0;
- float GSM_SIM800L_DTR_PIN_TX2_phyData = 0.0;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(GSM_SIM800L_RING_PIN_RX2, INPUT_PULLUP);
- pinMode(GSM_SIM800L_RST_PIN_D14, OUTPUT);
- pinMode(GSM_SIM800L_DTR_PIN_TX2, OUTPUT);
- GSM_SIM800L_Serial.begin(9600, SWSERIAL_8N1, GSM_SIM800L_Serial_PIN_SERIAL_RX_D13, GSM_SIM800L_Serial_PIN_SERIAL_TX_D4, false);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- updateOutputs(); // Refresh output data
- int day, month, year, hour, minute, second;
- getNtcTime(day, month, year, hour, minute, second);
- // You can now use the NTC time variables (day, month, year, hour, minute, second) as needed
- }
- void updateOutputs()
- {
- digitalWrite(GSM_SIM800L_RST_PIN_D14, GSM_SIM800L_RST_PIN_D14_rawData);
- digitalWrite(GSM_SIM800L_DTR_PIN_TX2, GSM_SIM800L_DTR_PIN_TX2_rawData);
- }
- void getNtcTime(int &day, int &month, int &year, int &hour, int &minute, int &second) {
- // Simulate getting NTC time
- // In a real application, you would replace this with actual NTC time retrieval logic
- day = 1; // Example values
- month = 1; // Example values
- year = 2023; // Example values
- hour = 12; // Example values
- minute = 0; // Example values
- second = 0; // Example values
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement