AT.ino 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. Description: SIM800L serial transparent transmission debugging program
  3. */
  4. #include <M5Stack.h>
  5. #define RX_PIN 16
  6. #define TX_PIN 17
  7. #define RESET_PIN 5
  8. void header(const char *string, uint16_t color){
  9. M5.Lcd.fillScreen(color);
  10. M5.Lcd.setTextSize(1);
  11. M5.Lcd.setTextColor(TFT_MAGENTA, TFT_BLUE);
  12. M5.Lcd.fillRect(0, 0, 320, 30, TFT_BLUE);
  13. M5.Lcd.setTextDatum(TC_DATUM);
  14. M5.Lcd.drawString(string, 160, 3, 4);
  15. }
  16. void setup() {
  17. M5.begin();
  18. M5.Power.begin();
  19. header("SIM800L AT command", TFT_BLACK);
  20. M5.Lcd.setTextFont(2);
  21. M5.Lcd.setTextColor(TFT_WHITE, TFT_BLACK);
  22. M5.Lcd.drawString("Please use serial port to Test AT command.",0, 35, 2);
  23. // Host serial communication
  24. Serial.begin(115200);
  25. // SIM800L serial communication
  26. Serial2.begin(115200, SERIAL_8N1, RX_PIN, TX_PIN);
  27. pinMode(RESET_PIN, OUTPUT);
  28. }
  29. void loop() {
  30. //AT instruction write
  31. if(Serial.available()){
  32. Serial2.write(Serial.read());
  33. }
  34. //AT instruction result
  35. if(Serial2.available()){
  36. Serial.write(Serial2.read());
  37. }
  38. delay(10);
  39. }