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: "SIM800L Control"
- - Source Code NOT compiled for: Arduino Nano ESP32
- - Source Code created on: 2024-06-13 11:19:54
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* initialize gsm */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** 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 updateOutputs(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t gsm_SIM800L_RING_PIN_D3 = 3;
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t gsm_SIM800L_RST_PIN_D2 = 2;
- const uint8_t gsm_SIM800L_DTR_PIN_D4 = 4;
- /***** DEFINITION OF Software Serial *****/
- const uint8_t gsm_SIM800L_Serial_PIN_SERIAL_TX_A0 = A0;
- const uint8_t gsm_SIM800L_Serial_PIN_SERIAL_RX_A1 = A1;
- SoftwareSerial gsm_SIM800L_Serial(gsm_SIM800L_Serial_PIN_SERIAL_RX_A1, gsm_SIM800L_Serial_PIN_SERIAL_TX_A0);
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool gsm_SIM800L_RST_PIN_D2_rawData = 0;
- bool gsm_SIM800L_DTR_PIN_D4_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float gsm_SIM800L_RST_PIN_D2_phyData = 0.0;
- float gsm_SIM800L_DTR_PIN_D4_phyData = 0.0;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- Sim800L GSM(&gsm_SIM800L_Serial, gsm_SIM800L_RST_PIN_D2, gsm_SIM800L_RING_PIN_D3, gsm_SIM800L_DTR_PIN_D4);
- void setup(void)
- {
- // put your setup code here, to run once:
- pinMode(gsm_SIM800L_RING_PIN_D3, INPUT_PULLUP);
- pinMode(gsm_SIM800L_RST_PIN_D2, OUTPUT);
- pinMode(gsm_SIM800L_DTR_PIN_D4, OUTPUT);
- gsm_SIM800L_Serial.begin(9600);
- // Initialize GSM module
- GSM.begin(4800);
- // Minimum functionality
- if (!GSM.setFunctionalityMode(0)) Serial.println("ERROR");
- else Serial.println("Minimum functionality");
- Serial.print("Functionality mode: ");
- Serial.println(GSM.getFunctionalityMode());
- delay(5000);
- // Full functionality
- if (!GSM.setFunctionalityMode(1)) Serial.println("ERROR");
- else Serial.println("Full functionality");
- Serial.print("Functionality mode: ");
- Serial.println(GSM.getFunctionalityMode());
- delay(5000);
- // Flight mode (disable RF function)
- if (!GSM.setFunctionalityMode(4)) Serial.println("ERROR");
- else Serial.println("Flight mode (disable RF function)");
- Serial.print("Functionality mode: ");
- Serial.println(GSM.getFunctionalityMode());
- delay(5000);
- }
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- updateOutputs(); // Refresh output data
- }
- void updateOutputs()
- {
- digitalWrite(gsm_SIM800L_RST_PIN_D2, gsm_SIM800L_RST_PIN_D2_rawData);
- digitalWrite(gsm_SIM800L_DTR_PIN_D4, gsm_SIM800L_DTR_PIN_D4_rawData);
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement