Сначала попробуйте этот , чтобы запрограммировать микросхему SAM для создания интерфейса между модемом и консольным ПК (я обнаружил, что в MC20_Arduino_Interface.h есть хорошие готовые функции, которые вы можете настроитьмодем.)
Простая программа выглядит следующим образом:
#include "MC20_Arduino_Interface.h"
// set serial port that connects to MC20
//#define serialMC20 Serial1
void setup()
{
//Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
SerialUSB.begin(115200);
while (!Serial);
//Being serial communication witj Arduino and MC20
serialMC20.begin(115200);
delay(1000);
SerialUSB.println("Setup Complete!");
}
void loop()
{
//Read MC20 output (if available) and print it in Arduino IDE Serial Monitor
if (serialMC20.available())
{
SerialUSB.write(serialMC20.read());
}
//Read Arduino IDE Serial Monitor inputs (if available) and send them to MC20
if (SerialUSB.available())
{
serialMC20.write(SerialUSB.read());
}
}
Кроме того, я предлагаю вам использовать последовательный монитор Arduino для связи.
Если модем успешно запускается, выувидит SMS Ready
и Call Ready
в последовательном мониторе.Согласно документам Quectel HTTP для запроса POST:
3.2.Отправьте POST-запрос на HTTP-сервер
AT+QIFGCNT=0
OK
AT+QICSGP=1,"CMNET" //Set APN
OK
AT+QIREGAPP //Optional
OK
AT+QIACT //Optional
OK
AT+QHTTPURL=58,30 //Set URL
CONNECT
<Input data>
//For example, input 58 bytes:
http://api.efxnow.com/DEMOWebServices2.8/Service.asmx/Echo
OK
//POST the data whose size is 18 bytes and the maximum latency time for inputting is 50s.
//It is recommended to set the latency time as long as enough to download all the data in the latency time.
AT+QHTTPPOST=18,50,10
CONNECT
//This means module enters into data mode and is ready to receive data from UART.
//For example, input 18 bytes: Message=helloworld.
OK
//This means all data has been received, and DCD is set to high.
AT+QHTTPREAD=30 //Read the response of HTTP server.
CONNECT
<Output data> //Output the response data of HTTP server to UART.
//For example, UART outputs:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="https://api.efxnow.com/webservices2.3">Message='helloworld' ASCII:104 101 108 108
111 119 111 114 108 100 </string>
OK
AT+QIDEACT //Deactivate PDP context.
DEACT OK
Например, для httpbin.org/post
это будет выглядеть примерно так:
16:45:56.416 -> AT+QIFGCNT=0
16:45:56.416 -> OK
16:46:02.918 -> AT+QICSGP=1,"mtnirancell"
16:46:02.918 -> OK
16:46:07.850 -> AT+QIREGAPP
16:46:07.850 -> OK
16:46:12.275 -> AT+QIACT
16:46:12.275 -> OK
16:46:27.467 -> AT+QHTTPURL=23,60
16:46:27.467 -> CONNECT
16:46:27.467 -> <http://httpbin.org/post>
16:46:36.965 -> OK
16:46:36.965 ->
16:46:48.786 -> AT+QHTTPPOST=18,50,10
16:46:48.786 -> CONNECT
16:46:48.786 -> <message=helloworld>
16:47:02.094 -> OK
16:47:02.094 ->
16:47:06.569 -> AT+QHTTPREAD=30
16:47:06.569 -> CONNECT
16:47:06.569 -> {
16:47:06.569 -> "args": {},
16:47:06.569 -> "data": "",
16:47:06.569 -> "files": {},
16:47:06.569 -> "form": {
16:47:06.569 -> "message": "helloworld"
16:47:06.569 -> },
16:47:06.569 -> "headers": {
16:47:06.569 -> "Accept": "*/*",
16:47:06.569 -> "Content-Length": "18",
16:47:06.569 -> "Content-Type": "application/x-www-form-urlencoded",
16:47:06.602 -> "Host": "httpbin.org",
16:47:06.602 -> "User-Agent": "QUECTEL_MODULE"
16:47:06.602 -> },
16:47:06.602 -> "json": null,
16:47:06.602 -> "origin": "*******, ********",
16:47:06.602 -> "url": "https://httpbin.org/post"
16:47:06.602 -> }
16:47:06.602 -> OK