anyone know how to fix it ?
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 6); // configure software serial port
int REDLed= 2;
int GREENLed= 3;
int BLUELed= 4;
void setup() {
pinMode(REDLed, OUTPUT);
pinMode(GREENLed, OUTPUT);
pinMode(GREENLed, OUTPUT);
SIM900.begin(9600);
Serial.begin(9600);
Serial.print("power up" );
delay(30000);
}
void loop()
{
Serial.println("SubmitHttpRequest - started" );
SubmitHttpRequest();
Serial.println("SubmitHttpRequest - finished" );
delay(10000);
}
void SubmitHttpRequest()
{
SIM900.println("AT+CSQ"); // Signal quality check
delay(100);
ShowSerialData();// this code is to show the data from gprs shield, in order to easily see the process of how the gprs shield submit a http request, and the following is for this purpose too.
SIM900.println("AT+CGATT?"); //Attach or Detach from GPRS Support
delay(100);
ShowSerialData();
SIM900.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");//setting the SAPBR, the connection type is using gprs
delay(1000);
ShowSerialData();
SIM900.println("AT+SAPBR=3,1,\"APN\",\"CMNET\"");//setting the APN, Access point name string
delay(4000);
ShowSerialData();
SIM900.println("AT+SAPBR=1,1");//setting the SAPBR
delay(2000);
ShowSerialData();
SIM900.println("AT+HTTPINIT"); //init the HTTP request
delay(2000);
ShowSerialData();
SIM900.println("AT+HTTPPARA=\"URL\",\"https://gps.zidan.smkmhd2pku.sch.id/getstate.php?color=All\"");// setting the httppara, the second parameter is the website you want to access
delay(1000);
ShowSerialData();
SIM900.println("AT+HTTPACTION=0");//submit the request
delay(10000);//the delay is very important, the delay time is base on the return from the website, if the return datas are very large, the time required longer.
//while(!SIM900.available());
ShowSerialData();
SIM900.println("AT+HTTPREAD");// read the data from the website you access
delay(300);
changeLed();
ShowSerialData();
SIM900.println("");
delay(100);
}
void changeLed()
{
String content = "";
// String RedState = content.substring();
while(SIM900.available()!=0)
{
//Serial.write(SIM900.read());
content = content + String(char (SIM900.read()));
}
Serial.println(content);
if(content.substring(30,31)== "1")
{
digitalWrite(REDLed, HIGH);
}
else if (content.substring(30,31)== "0")
{
digitalWrite(REDLed, LOW);
}
if(content.substring(31,32)== "1")
{
digitalWrite(GREENLed, HIGH);
}
else if (content.substring(31,32)== "0")
{
digitalWrite(GREENLed, LOW);
}
if(content.substring(32,33)== "1")
{
digitalWrite(BLUELed, HIGH);
}
else if (content.substring(32,33)== "0")
{
digitalWrite(BLUELed, LOW);
}
content = "";
}
void ShowSerialData()
{
while(SIM900.available()!=0)
Serial.write(char (SIM900.read()));
}
What is it that needs fixing ?
Please do not post pictures of Serial monitor output
Select the text using the mouse, then use Ctrl + C to copy the selected text and post it here in code tags
i
that the code why i need to fix it because the link is not fully completed and the arduino doesn't get information from the web that show just null but that must show 111 or 110 or 100 or 000
or maybe you have idea to make not get limited like that
i need that because i need function like get data from a web and extract the data to control relay that why i say 111 or 110 or 100 or 000
i will explain it again when the code running and open the link the arduino not fully open the link and that cause information in the link cannot readable
did you know how to fix it or what kind of code to make it read all of the link
What do you see if you print what you are sending to SIM900 ?
The name of the SoftwareSerial port does not really matter but are you using a SIM800, as in the topic title, or a SIM900 as in the code ?
@UKHeliBob
ouh yes i not change it but still work because i see that just for name
to clarify it , i use sim 800L
what i see is the link is not fully printed and there is no respone or no result and that must be have result
https://gpstestering.000webhostapp.com/getstate.php?color=All
you can see result when you open it just few number
In the code that you posted you are not printing what you send to the SIM800, you are printing what you get back from the SIM800
Try this
void setup()
{
Serial.begin(115200);
Serial.println("AT+HTTPPARA=\"URL\",\"https://gps.zidan.smkmhd2pku.sch.id/getstate.php?color=All\"");// setting the httppara, the second parameter is the website you want to access
}
void loop()
{
}
Does it print what you want and expect
#include <SoftwareSerial.h>
SoftwareSerial sim800(7, 6); // configure software serial port
int REDLed= 2;
int GREENLed= 3;
int BLUELed= 4;
void setup() {
pinMode(REDLed, OUTPUT);
pinMode(GREENLed, OUTPUT);
pinMode(GREENLed, OUTPUT);
sim800.begin(115200);
Serial.begin(115200);
Serial.print("power up" );
delay(30000);
Serial.begin(115200);
Serial.println("AT+HTTPPARA=\"URL\",\"https://gps.zidan.smkmhd2pku.sch.id/getstate.php?color=All\"");// setting the httppara, the second parameter is the website you want to access
}
void loop()
{
Serial.println("SubmitHttpRequest - started" );
SubmitHttpRequest();
Serial.println("SubmitHttpRequest - finished" );
delay(10000);
}
void SubmitHttpRequest()
{
sim800.println("AT+CSQ"); // Signal quality check
delay(100);
ShowSerialData();// this code is to show the data from gprs shield, in order to easily see the process of how the gprs shield submit a http request, and the following is for this purpose too.
sim800.println("AT+CGATT?"); //Attach or Detach from GPRS Support
delay(100);
ShowSerialData();
sim800.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");//setting the SAPBR, the connection type is using gprs
delay(1000);
ShowSerialData();
sim800.println("AT+SAPBR=3,1,\"APN\",\"CMNET\"");//setting the APN, Access point name string
delay(4000);
ShowSerialData();
sim800.println("AT+SAPBR=1,1");//setting the SAPBR
delay(2000);
ShowSerialData();
sim800.println("AT+HTTPINIT"); //init the HTTP request
delay(2000);
ShowSerialData();
sim800.println("AT+HTTPPARA=\"URL\",\"https://gpstestering.000webhostapp.com/getstate.php?color=All");// setting the httppara, the second parameter is the website you want to access
delay(1000);
ShowSerialData();
sim800.println("AT+HTTPACTION=0");//submit the request
delay(10000);//the delay is very important, the delay time is base on the return from the website, if the return datas are very large, the time required longer.
//while(!sim800.available());
ShowSerialData();
sim800.println("AT+HTTPREAD");// read the data from the website you access
delay(300);
changeLed();
ShowSerialData();
sim800.println("");
delay(100);
}
void changeLed()
{
String content = "";
// String RedState = content.substring();
while(sim800.available()!=0)
{
//Serial.write(sim800.read());
content = content + String(char (sim800.read()));
}
Serial.println(content);
if(content.substring(30,31)== "1")
{
digitalWrite(REDLed, HIGH);
}
else if (content.substring(30,31)== "0")
{
digitalWrite(REDLed, LOW);
}
if(content.substring(31,32)== "1")
{
digitalWrite(GREENLed, HIGH);
}
else if (content.substring(31,32)== "0")
{
digitalWrite(GREENLed, LOW);
}
if(content.substring(32,33)== "1")
{
digitalWrite(BLUELed, HIGH);
}
else if (content.substring(32,33)== "0")
{
digitalWrite(BLUELed, LOW);
}
content = "";
}
void ShowSerialData()
{
while(sim800.available()!=0)
Serial.write(char (sim800.read()));
}
you mean like this?
@UKHeliBob
oke the result is fully printed but in my case i need it to work for get data from the link to turn off or on led because the link little bit too long that doesn't print it as well and the sim work as same the link printed
There may be a limit to the length of message that the SIM800 can send. Can you spit the message into 2 sections and send one after another ?
@UKHeliBob
i was think like but i don't know how to do that
acctually i made a gps tracker for my school project and extra feature is use a relay to cut the engine when stolen
#include <Http.h>
#include <TinyGPS++.h>
#define RST_PIN 5
#define RX_PIN 6
#define TX_PIN 7
TinyGPSPlus GPS;
double lat;
double lng;
int indikatorGPS = 2;
int indikatorData = 3;
const char BEARER[] PROGMEM = "telkomsel"; //APN Provider
int id = 1;
void setup() {
pinMode(indikatorData, OUTPUT);
pinMode(indikatorGPS, OUTPUT);
Serial.begin(9600);
while (!Serial);
Serial.println("Starting!");
}
void loop() {
while (Serial.available()) {
GPS.encode(Serial.read());
}
if (GPS.location.isUpdated()) {
digitalWrite(indikatorData, LOW);
digitalWrite(indikatorGPS, HIGH);
lat = GPS.location.lat();
lng = GPS.location.lng();
sendData();
digitalWrite(indikatorGPS, LOW);
delay(3000); //delay 10 detik
}else{
digitalWrite(indikatorData, HIGH);
}
}
void sendData(){
char response[32];
char body[90];
HTTP http(9600, RX_PIN, TX_PIN, RST_PIN);
http.connect(BEARER);
String request = "{\"id\":" + String(id) + ",\"lat\":" + String(lat, 6) + ",\"lng\":" + String(lng, 6) + "}";
request.toCharArray(body, 90);
delay(1000);
Result result = http.post("https://gpstestering.000webhostapp.com/gps/sync.php", body, response);
Serial.println(response);
Serial.print(http.disconnect());
}
void getdata(){
}
here the code that has been work for send coordinate to database
and i need to adapt it for
getdata
and get result of 101 number and turn off or turn on the relay
Something like this, but I don't know what the SIM800 will make of it
void setup()
{
Serial.begin(115200);
Serial.println("AT+HTTPPARA=\"URL\",\"https://gps.zidan.smkmhd2pku.sch.id/getstate.php?color=All\"");// setting the httppara, the second parameter is the website you want to access
Serial.print("AT+HTTPPARA=\"URL\","); //\"https://gps.zidan.smkmhd2pku.sch.id/getstate.php?color=All\"");// setting the httppara, the second parameter is the website you want to access
Serial.println("\"https://gps.zidan.smkmhd2pku.sch.id/getstate.php?color=All\"");// setting the httppara, the second parameter is the website you want to access
}
void loop()
{
}
wait why you made it in void setup ? that will not work to get the data and turn on and off the led
My code was an example to show you the principle and compare the outputs from the 2 methods to ensure that the output was the same.
It is up to you to apply it to your project
okey the print is work but the case still not solved
I have no idea what you are showing me. Did you just print the URL or send it to the SIM800 ?
Please post your revised code and Serial monitor output both in code tags.
No pictures
sorry i forgot about it
#include <SoftwareSerial.h>
SoftwareSerial sim800(7, 6); // configure software serial port
int REDLed= 11;
int GREENLed= 3;
int BLUELed= 4;
void setup() {
pinMode(REDLed, OUTPUT);
pinMode(GREENLed, OUTPUT);
pinMode(GREENLed, OUTPUT);
sim800.begin(9600);
Serial.begin(9600);
Serial.print("power up" );
delay(30000);
}
void loop()
{
Serial.println("SubmitHttpRequest - started" );
SubmitHttpRequest();
Serial.println("SubmitHttpRequest - finished" );
delay(10000);
}
void SubmitHttpRequest()
{
sim800.println("AT+CSQ"); // Signal quality check
delay(100);
ShowSerialData();// this code is to show the data from gprs shield, in order to easily see the process of how the gprs shield submit a http request, and the following is for this purpose too.
sim800.println("AT+CGATT?"); //Attach or Detach from GPRS Support
delay(100);
ShowSerialData();
sim800.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");//setting the SAPBR, the connection type is using gprs
delay(1000);
ShowSerialData();
sim800.println("AT+SAPBR=3,1,\"APN\",\"CMNET\"");//setting the APN, Access point name string
delay(4000);
ShowSerialData();
sim800.println("AT+SAPBR=1,1");//setting the SAPBR
delay(2000);
ShowSerialData();
sim800.println("AT+HTTPINIT"); //init the HTTP request
delay(2000);
ShowSerialData();
sim800.println("AT+HTTPPARA=\"URL\",\"https://gpstestering.000webhostapp.com/getstate.php?color=All");// setting the httppara, the second parameter is the website you want to access
Serial.println("AT+HTTPPARA=\"URL\",\"https://gps.zidan.smkmhd2pku.sch.id/getstate.php?color=All\"");// setting the httppara, the second parameter is the website you want to access
Serial.print("AT+HTTPPARA=\"URL\","); //\"https://gps.zidan.smkmhd2pku.sch.id/getstate.php?color=All\"");// setting the httppara, the second parameter is the website you want to access
Serial.println("\"https://gps.zidan.smkmhd2pku.sch.id/getstate.php?color=All\"");// setting the httppara, the second parameter is the website you want to access
delay(1000);
ShowSerialData();
sim800.println("AT+HTTPACTION=0");//submit the request
delay(10000);//the delay is very important, the delay time is base on the return from the website, if the return datas are very large, the time required longer.
//while(!sim800.available());
ShowSerialData();
sim800.println("AT+HTTPREAD");// read the data from the website you access
delay(300);
changeLed();
ShowSerialData();
sim800.println("");
delay(100);
}
void changeLed()
{
String content = "";
// String RedState = content.substring();
while(sim800.available()!=0)
{
//Serial.write(sim800.read());
content = content + String(char (sim800.read()));
}
Serial.println(content);
if(content.substring(30,31)== "1")
{
digitalWrite(REDLed, HIGH);
}
else if (content.substring(30,31)== "0")
{
digitalWrite(REDLed, LOW);
}
if(content.substring(31,32)== "1")
{
digitalWrite(GREENLed, HIGH);
}
else if (content.substring(31,32)== "0")
{
digitalWrite(GREENLed, LOW);
}
if(content.substring(32,33)== "1")
{
digitalWrite(BLUELed, HIGH);
}
else if (content.substring(32,33)== "0")
{
digitalWrite(BLUELed, LOW);
}
content = "";
}
void ShowSerialData()
{
while(sim800.available()!=0)
Serial.write(char (sim800.read()));
}
Hi
I tested your code , after replacing HTTPS with HTTP and I got the response