How to read data from ThingSpeak and control led using sim800L?

조회 수: 47 (최근 30일)
Su Kyi
Su Kyi 2020년 12월 15일
댓글: Anzaku Engla 2023년 4월 27일
I'm working on SIM800L with arduino and try to read data from ThingSpeak. I can read my channel field last value (1 or 0) using AT+HTTPREAD command. But the content get from sim800L.read() is -1 not one or zero. I want to read 1 or 0 and then turn on/off LED. How to get the data of field from the response of AT+HTTPREAD? Please find the code as follows:
{.....
SIM800L.println("AT+HTTPPARA=\"URL\",\"http://api.thingspeak.com/channels/xxxxxxx/fields/3/last?api_key=xxxxxxxxxxxxxx\"");
delay(1000);
ShowSerialData();
SIM800L.println("AT+HTTPACTION=0");
delay(10000);
ShowSerialData();
SIM800L.println("AT+HTTPREAD");
delay(300);
ShowSerialData();
changeled();
ShowSerialData();
SIM800L.println("");
delay(100);
}
void changeled()
{
String content = "";
Serial.println(SIM800L.read());
content = content + String(SIM800L.read());
Serial.print("Content:");
Serial.println(content);
}
  댓글 수: 3
Christopher Stapels
Christopher Stapels 2022년 10월 14일
-1 is for unauthorized. Perhaps it is a private channel you are trying to read?
Anzaku Engla
Anzaku Engla 2023년 4월 27일
First of all you have to be sure you can read AT command reply from the SIM800 first. If you can do this your solution is close

댓글을 달려면 로그인하십시오.

답변 (1개)

Vinod
Vinod 2021년 9월 21일
편집: Vinod 2021년 9월 21일
Is the SIM card activated? Have you confirmed that you can connect to the internet with the SIM800L module and your SIM card? Does your GSM provider support the use of their SIM card in the SIM800L module? See this video.

커뮤니티

더 많은 답변 보기:  ThingSpeak 커뮤니티

카테고리

Help CenterFile Exchange에서 REST API에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by