Search code examples
arduinogprs

Variable inside AT+UHTTPC command


I'm trying to figure out how to include a variable that I grab from a sensor inside an AT+UHTTPC command to post the values inside a DB.

I tried using the HTTPPAR command but it seems the GPRS I have doesn't recognize it ( I have a SARA G350 GPRS shield )

Here's the code I'm using right now which cannot contain a variable :

 mySerial.println("AT+UHTTPC=2,5,\"/add.php\",\"post.ffs\",\"vite=10\",0"); updateSerial(); 
delay(1000);

Solution

  • You just need to read your sensor value and create a new string based on that then pass it to your serial output.

    void send_value()
    {
        String command = "AT+UHTTPC=2,5,\"/add.php\",\"post.ffs\",\"vite=";
        float Windspeed = analogRead(A0);
        // convert value to String
        command += String(Windspeed);
        // or convert with precision
        // command += String(Windspeed, 2);
        command += "\",0";
        mySerial.println(command);
        updateSerial();
        delay(1000);
    }