Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] String + int code doesn't work

Status
Not open for further replies.

andihong

Member level 1
Joined
May 13, 2015
Messages
33
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
216
i have a code for arduino that need a string with variable to redirect the value to mysql


here the example of code.

int input = sht1x.readTemperatureC();

i want to get the variable inside the string on HttpPost.

here the code
httpPOST("http:xxx.com", 80, "/tes.php", "(i want to get it inside here)", msg, 50);
Code:
httpPOST("http:xxx.com", 80, "/tes.php", "input="+input+"", msg, 50);

the code doesn't work, is there any way to convert it ?
 
Last edited by a moderator:

Try converting input to string and pass the string to httpPOST() like this.

Code:
httpPOST("http:xxx.com", 80, "/tes.php", str, msg, 50);

str is the string which holds the int value converted to string.

For better help, zip and post the Arduino sketch and necessary Arduino libraries.

- - - Updated - - -

Try this

Code:
int input = sht1x.readTemperatureC();
String myStr = String(input);
httpPOST("http:xxx.com", 80, "/tes.php", myStr, msg, 50);
 

Try converting input to string and pass the string to httpPOST() like this.

Code:
httpPOST("http:xxx.com", 80, "/tes.php", str, msg, 50);

str is the string which holds the int value converted to string.

For better help, zip and post the Arduino sketch and necessary Arduino libraries.

- - - Updated - - -

Try this

Code:
int input = sht1x.readTemperatureC();
String myStr = String(input);
httpPOST("http:xxx.com", 80, "/tes.php", myStr, msg, 50);

it doesn't work.

i want to post the parameter to send it through php file.

httpPOST("http:xxx.com", 80, "/tes.php", "", msg, 50);


if i am give the value, its work,
example : httpPOST("http:xxx.com", 80, "/tes.php", "humidity=70&value=60", msg, 50);

but if i want to change the value 70 and 60 to a variable that i get from the sht11, it doesn't work..

please help.
 

I asked you to Zip and post the Arduino sketch and necessary libraries.

https://www.instructables.com/id/PART-1-Send-Arduino-data-to-the-Web-PHP-MySQL-D3js/?ALLSTEPS

oh ya sorry i forgot to upload the libraries and arduino sketch,

Attached below are the libraries.

and the arduino sketch

Code:
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "inetGSM.h"
#include <SHT1x.h>

#define dataPin 10
#define clockPin 11

SHT1x sht1x(dataPin, clockPin);

InetGSM inet;
int k = 0;
int j = 0;
char msg[150];
boolean found = false;
char data;
int numdata;
char inSerial[50];
int i = 0;
boolean started = false;

void setup()

{

  Serial.begin(9600);
  Serial.println("Arduino Started");
  /*
  if (gsm.begin(2400)) {
    Serial.println("\nstatus=READY");
    started = true;
  }
  else Serial.println("\nstatus=IDLE");
  if (started) {
    if (inet.attachGPRS("internet", "wap", "wap123"))
      Serial.println("status=ATTACHED");
    else Serial.println("status=ERROR");
    delay(1000);
   
  }
  */
  
};

void loop()
{
  int suhu;
  int temp_c;
  int temp_f;
  int humidity;

  temp_c = sht1x.readTemperatureC();
  temp_f = sht1x.readTemperatureF();
  humidity = sht1x.readHumidity();


 inet.httpPOST("andi.pcr.ac.id", 80, "/tessuhu.php", "cahaya=[COLOR="#FF0000"]1000[/COLOR]&kelembaban=[COLOR="#FF0000"]70[/COLOR]&suhu=[COLOR="#FF0000"]30[/COLOR]", msg, 50);
 serialswread();
  delay(3600000);
};

void serialswread() {
  gsm.SimpleRead();
}

here i want to change the colored red text with the variable temp_c, suhu , and humidity that values from sensor.
 

Attachments

  • GSM-GPRS-GPS-Shield-GSMSHIELDv1.zip
    58.5 KB · Views: 117
Last edited by a moderator:

Attached Project File below:
 

Attachments

  • GSM-GPRS-GPS-Shield-GSMSHIELD.zip
    58.5 KB · Views: 101

The values being passed to httpPOST() is wrong.

Code:
httpPOST(const char* server, int port, const char* path, const char* parameters, char* result, int resultlength)

See example project and pass arguments according to the function.
 

The values being passed to httpPOST() is wrong.

Code:
httpPOST(const char* server, int port, const char* path, const char* parameters, char* result, int resultlength)

See example project and pass arguments according to the function.



how to make an arguments with String and then convert to char*?
 

You are passing sting to const char* parameters

You have to see GPRS example sketch and find out what parameters have to be sent. There are const strings.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top