A9G模块的使用说明
详见该博客:a9gdfgdfhguyiuh-CSDN博客
接线
ESP32 DEVKIT_C | A9G |
GND | GND |
D23 | RX |
A9G开发板用板载MiniUSB(安卓口)供电
代码
from machine import UART # 导入串口模块
# import time'''UART0 UART1 UART2
TX 1 10 17
RX 3 9 16UART0已被上位机占用
UART1的默认引脚用于外接flash'''uart = UART(1, baudrate=115200, tx=23,) # 初始化串口1,波特率115200,tx=23,不使用rx'''
AT_instruction = "AT\r\n" # 查询是否与模块建立联系
uart.write(AT_instruction)
time.sleep_ms(100)AT_instruction = "AT+CSQ\r\n" # 查询信号强度 第一个参数为信号强度值
uart.write(AT_instruction)
time.sleep_ms(100)AT_instruction = "AT+CCID\r\n" # 获取SIM卡的序列号,用来检测是否有SIM卡
uart.write(AT_instruction)
time.sleep_ms(100)
'''AT_instruction = "AT+CMGF=1\r\n" # 文本方式发送短信
uart.write(AT_instruction)AT_instruction = "AT+CMGS=\"18601652379\"\r\n" # 向指定号码发送短信
uart.write(AT_instruction)AT_instruction = "The smoke concentration in the laboratory is high, please deal with it as soon as possible.\r\n" # 短信的内容
uart.write(AT_instruction)AT_instruction = [0x1a] # 结束符
uart.write(bytes(AT_instruction))AT_instruction = "ATD18601652379\r\n" # 向指定号码打电话
uart.write(AT_instruction)