Przeszukaj forum
Pokazywanie wyników dla tagów 'SIM800C'.
Znaleziono 1 wynik
-
Witam, Od 1,5 miesiąca uczę się programować Arduino Uno rev3 korzystając z zakupionego zestawu Forbot Arduino na Botlandzie. Przerobiłem tutoriale oraz spędziłem sporo godzin tworząc przykładowe projekty, jednakże nie potrafię ogarnąć jednej kwestii związanej z GSM AT Commands. Aktualnie staram się stworzyć urządzenie sprawdzające zasięg GSM i wysłać tę informację na ThinkSpeak (albo inny serwis/php/excel sheets itp). Wysyłanie danych do ThinkSpeak, MySql, Google Sheets etc udało mi się osiągnąć, jednakże mam problem z wysłaniem mojej zmiennej, czyli zasięgu (który wywołuję komendą AT+CSQ i otrzymuję wartość w postaci +CSQ:18,99 , z której tylko cyfra 18 mnie interesuje). Kod programu przesyłam poniżej. Arduino Uno rev 3 wyposazyłem w DFRobot Shield GPRS SIM800C Aktualnie arduino wysyła z "ręki" wpisaną stałą wartość 18, jednakże tutaj chciałbym aby pobierał dane z +CSQ i otrzymaną wartość dodał w wysyłany link. z góry dziękuję za pomoc! //testing GSM signal strenght and sending it to ThingSpeak #include <SoftwareSerial.h> // I am using DFRobot Shield GPRS SIM800C therefore need to redirect RX and TX #define SIM_800_RX 2 #define SIM_800_TX 3 SoftwareSerial MySerial(SIM_800_RX, SIM_800_TX); int delayShort=1000; //time delays = 1 second int delayMedium=3000; //time delays = 3 seconds int delayLong=60000; //time delays = 60 seconds void setup() { Serial.begin(9600); // Open serial communications and wait for port to open: while (!Serial); MySerial.begin(9600); // set the data rate for the SoftwareSerial port delay(delayShort); MySerial.println("AT"); // checking communication with GSM printGSMreply(); //expecting answer is OK delay(delayMedium); MySerial.println("at+csq"); delay(delayShort); printGSMreply(); //expecting answer is +CSQ:18,99 MySerial.println("at+cipshut"); //Close the GPRS PDP context - if deleted I am getting error message delay(delayShort); printGSMreply(); //expecting answer is OK } void loop() { sendToGsm(); //Start the GSM-Modul and start the transmisson delay(delayMedium); //Wait one minute } void sendToGsm() { MySerial.println("at+csq"); printGSMreply(); //expecting answer is arround +CSQ:18,99 and would like to send number 18 to ThingSpeak delay(delayShort); MySerial.println("at+cstt=\"internet\",\"\",\"\""); printGSMreply(); MySerial.println("at+ciicr"); //brings up the GPRS connection printGSMreply(); MySerial.println("at+cifsr");//enquire my IP address allocated printGSMreply(); MySerial.println("at+cipstart=\"TCP\",\"184.106.153.149\",\"80\"");//connect to the ThingSpeak IP address which will be translated as update URL (https://api.thingspeak.com) printGSMreply(); MySerial.println("at+cipsend=72");//declare the number of characters I want to send to ThinkSpeak plus +3 => in my case 69+3=72 printGSMreply(); MySerial.print("GET /update?");//this is a constant beginning for the GET command and is as provided by ThingSpeak printGSMreply(); MySerial.print("api_key=ABCDEFGHIJKLMNOP");//the channel API key provided by ThingSpeak printGSMreply(); MySerial.print("&field1="); printGSMreply(); MySerial.println("18");//!!HERE I WOULD LIKE TO GET MY AT+CSQ VALUE!! printGSMreply(); MySerial.println("at+cipack");//ask for acknowledge details printGSMreply(); MySerial.println("at+CIPCLOSE");//close the IP connection (mozna uzyc CIPSHUT printGSMreply(); } void printGSMreply() //Print GSM Status { while (MySerial.available()) { Serial.write(MySerial.read()); } }