Advertisement
pleasedontcode

"SIM800L Management" rev_16

Jun 13th, 2024
262
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: "SIM800L Management"
  13.     - Source Code compiled for: ESP32 DevKit V1
  14.     - Source Code created on: 2024-06-13 10:57:23
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* initialize gsm */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23.  
  24. /****** DEFINITION OF LIBRARIES *****/
  25. #include <SoftwareSerial.h> //https://github.com/plerup/espsoftwareserial
  26. #include <Sim800L.h>        //https://github.com/vittorioexp/Sim800L-Arduino-Library-revised
  27.  
  28. /****** FUNCTION PROTOTYPES *****/
  29. void setup(void);
  30. void loop(void);
  31. void updateOutputs(void);
  32.  
  33. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  34. const uint8_t sim_SIM800L_RING_PIN_D16 = 16;
  35.  
  36. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  37. const uint8_t sim_SIM800L_RST_PIN_D14 = 14;
  38. const uint8_t sim_SIM800L_DTR_PIN_D17 = 17;
  39.  
  40. /***** DEFINITION OF Software Serial *****/
  41. const uint8_t sim_SIM800L_Serial_PIN_SERIAL_TX_D4 = 4;
  42. const uint8_t sim_SIM800L_Serial_PIN_SERIAL_RX_D13 = 13;
  43. EspSoftwareSerial::UART sim_SIM800L_Serial;
  44.  
  45. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  46. /***** used to store raw data *****/
  47. bool sim_SIM800L_RST_PIN_D14_rawData = 0;
  48. bool sim_SIM800L_DTR_PIN_D17_rawData = 0;
  49.  
  50. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  51. /***** used to store data after characteristic curve transformation *****/
  52. float sim_SIM800L_RST_PIN_D14_phyData = 0.0;
  53. float sim_SIM800L_DTR_PIN_D17_phyData = 0.0;
  54.  
  55. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  56. Sim800L GSM(sim_SIM800L_Serial_PIN_SERIAL_RX_D13, sim_SIM800L_Serial_PIN_SERIAL_TX_D4, sim_SIM800L_RST_PIN_D14);
  57.  
  58. void setup(void)
  59. {
  60.     // put your setup code here, to run once:
  61.     pinMode(sim_SIM800L_RING_PIN_D16, INPUT_PULLUP);
  62.  
  63.     pinMode(sim_SIM800L_RST_PIN_D14, OUTPUT);
  64.     pinMode(sim_SIM800L_DTR_PIN_D17, OUTPUT);
  65.  
  66.     sim_SIM800L_Serial.begin(9600, SWSERIAL_8N1, sim_SIM800L_Serial_PIN_SERIAL_RX_D13, sim_SIM800L_Serial_PIN_SERIAL_TX_D4, false);
  67.  
  68.     // Initialize GSM module with baud rate 9600
  69.     GSM.begin(9600);
  70.  
  71.     Serial.begin(9600); // Initialize Serial for debugging
  72.  
  73.     // Debugging information
  74.     Serial.println("GET PRODUCT INFO: ");
  75.     Serial.println(GSM.getProductInfo());
  76.  
  77.     Serial.println("GET OPERATORS LIST: ");
  78.     Serial.println(GSM.getOperatorsList());
  79.  
  80.     Serial.println("GET OPERATOR: ");
  81.     Serial.println(GSM.getOperator());
  82. }
  83.  
  84. void loop(void)
  85. {
  86.     // put your main code here, to run repeatedly:
  87.     updateOutputs(); // Refresh output data
  88. }
  89.  
  90. void updateOutputs()
  91. {
  92.     digitalWrite(sim_SIM800L_RST_PIN_D14, sim_SIM800L_RST_PIN_D14_rawData);
  93.     digitalWrite(sim_SIM800L_DTR_PIN_D17, sim_SIM800L_DTR_PIN_D17_rawData);
  94. }
  95.  
  96. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement