Go Down

Topic: Arduino Ethernet send to php (Read 1 time) previous topic - next topic

thanasisloi7


I suggest you stop mucking about with string formatting that you evidently don't understand yet, and just type the URL into your sketch:

Code: [Select]
char *pageAdd = "/controlpanel/getalarm.php?alarmstate=0";



Or whatever values you want to use for testing. You can confirm that the path is correct by typing the corresponding URL into the address field of your browser.
Quote
http://4.4.4.4/controlpanel/getalarm.php?alarmstate=0


Does the browser show the response you expected? The Arduino should receive the same response, if the network access is succeeding.



Yes in this way i get the right response....How can i i change 0 with the value?

PeterH


Yes in this way i get the right response....How can i i change 0 with the value?


That's great news. Now we know the only problem is the format of the request string.

Your code to generate it using sprintf was along the right lines. You would need something like this:

Code: [Select]

char pageAdd[64];
int alarmstate=0;
sprintf(pageAdd, "/controlpanel/getalarm.php?alarmstate=%d", alarmstate);


That should produce the same behaviour as before. If it doesn't, print the value of pageAdd before you make the page request, and compare it carefully with the fixed string that you know works correctly.
I only provide help via the forum - please do not contact me for private consultancy.

thanasisloi7

This works correctly but what %d define? I ask because i want to understand how it works so i can send to the web and other values...

SurferTim

Here is a list of things sprintf does and how to use them. The float stuff doesn't work last time I checked.
http://www.cplusplus.com/reference/cstdio/printf/

Go Up