Advertisement
pleasedontcode

**GSM Initialization** rev_01

Jan 25th, 2025
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: **GSM Initialization**
  13.     - Source Code NOT compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2025-01-25 19:44:38
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Get ntc time in three variable */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23. /* START CODE */
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <SoftwareSerial.h> //https://github.com/plerup/espsoftwareserial
  27. #include <Sim800L.h>    //https://github.com/vittorioexp/Sim800L-Arduino-Library-revised
  28.  
  29. /****** FUNCTION PROTOTYPES *****/
  30. void setup(void);
  31. void loop(void);
  32. void getNtcTime(int &day, int &month, int &year, int &hour, int &minute, int &second);
  33.  
  34. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  35. const uint8_t GSM_SIM800L_RING_PIN_RX2      = RX2;
  36.  
  37. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  38. const uint8_t GSM_SIM800L_RST_PIN_D14       = 14;
  39. const uint8_t GSM_SIM800L_DTR_PIN_TX2       = TX2;
  40.  
  41. /***** DEFINITION OF Software Serial *****/
  42. const uint8_t GSM_SIM800L_Serial_PIN_SERIAL_TX_D4       = 4;
  43. const uint8_t GSM_SIM800L_Serial_PIN_SERIAL_RX_D13      = 13;
  44. EspSoftwareSerial::UART GSM_SIM800L_Serial;
  45.  
  46. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  47. /***** used to store raw data *****/
  48. bool    GSM_SIM800L_RST_PIN_D14_rawData     = 0;
  49. bool    GSM_SIM800L_DTR_PIN_TX2_rawData     = 0;
  50.  
  51. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  52. /***** used to store data after characteristic curve transformation *****/
  53. float   GSM_SIM800L_RST_PIN_D14_phyData     = 0.0;
  54. float   GSM_SIM800L_DTR_PIN_TX2_phyData     = 0.0;
  55.  
  56. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  57.  
  58. void setup(void)
  59. {
  60.     // put your setup code here, to run once:
  61.  
  62.     pinMode(GSM_SIM800L_RING_PIN_RX2,   INPUT_PULLUP);
  63.  
  64.     pinMode(GSM_SIM800L_RST_PIN_D14,     OUTPUT);
  65.     pinMode(GSM_SIM800L_DTR_PIN_TX2,     OUTPUT);
  66.  
  67.     GSM_SIM800L_Serial.begin(9600, SWSERIAL_8N1, GSM_SIM800L_Serial_PIN_SERIAL_RX_D13, GSM_SIM800L_Serial_PIN_SERIAL_TX_D4, false);
  68.  
  69. }
  70.  
  71. void loop(void)
  72. {
  73.     // put your main code here, to run repeatedly:
  74.  
  75.     updateOutputs(); // Refresh output data
  76.  
  77.     int day, month, year, hour, minute, second;
  78.     getNtcTime(day, month, year, hour, minute, second);
  79.     // You can now use the NTC time variables (day, month, year, hour, minute, second) as needed
  80. }
  81.  
  82. void updateOutputs()
  83. {
  84.     digitalWrite(GSM_SIM800L_RST_PIN_D14, GSM_SIM800L_RST_PIN_D14_rawData);
  85.     digitalWrite(GSM_SIM800L_DTR_PIN_TX2, GSM_SIM800L_DTR_PIN_TX2_rawData);
  86. }
  87.  
  88. void getNtcTime(int &day, int &month, int &year, int &hour, int &minute, int &second) {
  89.     // Simulate getting NTC time
  90.     // In a real application, you would replace this with actual NTC time retrieval logic
  91.     day = 1;    // Example values
  92.     month = 1;  // Example values
  93.     year = 2023; // Example values
  94.     hour = 12;  // Example values
  95.     minute = 0; // Example values
  96.     second = 0; // Example values
  97. }
  98.  
  99. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement