1

I'm looking for a way to get lots of sensory data from my Arduino Micro to a PHP script. My current attempt is using the following AT-commands:

Sent: [AT+HTTPPARA=URL,www.example.com/newData.php?data=t0_20.75,l_0.00,m_584,h_42,td_22,d_21x44x54]
Res: [AT+HTTPPARA=URL,www.example.com/newData.php?data=t0_20.75,l_]

As you can see I send a long GET-parameter to my server with shortened parameter Names like t0 for temperature sensor number zero, l for light and so on.

In the response from my SIM800l I get back a string with exactly 63 characters, so I assume there's some lenght limitation there on the SIM-module.

After that command when it tries to finish the HTTP request I get a lot of errors as AT-command responses and no GET data arrives on my script.


I check wheter or not data has arrived with the following function on my server:

ob_start();
echo "Var_dump of GET\n";
var_dump($_GET);

echo "Var_dump of POST\n";
var_dump($_POST);
$vd_res = ob_get_clean();

file_put_contents('postdump.log', $vd_res."\n",FILE_APPEND);

When typing some data directly into the browser it saves my sent data in postdump.log so I'm pretty sure the SIM-module can't handle the given amount of data.

Do you have any idea how I can send bigger amounts of data all at once? For energy saving purposes I would prefer if it would be possible in only a single request.

1
  • I get back a string with exactly 63 characters, - I guess you're using SoftwareSerial, and using the silly delay(1000) way of waiting for a response that I see all over the place...?
    – Majenko
    Apr 14, 2019 at 20:13

1 Answer 1

2

Do you have any idea how I can send bigger amounts of data all at once? For energy saving purposes I would prefer if it would be possible in only a single request.

Do a POST request. You can send huge amounts of data in the body.

In the response from my SIM800l I get back a string with exactly 63 characters, so I assume there's some lenght limitation there on the SIM-module.

Nope.

I guess you're doing something like:

sendCommand("AT+HTTPPARA=URL,www.example.com/newData.php?data=t0_20.75,l_0.00,m_584,h_42,td_22,d_21x44x54");
delay(1000);
printResponse();

The problem there is that you're relying on the internal buffer of SoftwareSerial (or HardwareSerial if you use a real serial port). You wait for a predefined time for characters to arrive, and then after that time print them out. The serial code has a 64 byte buffer.

I see that kind of code all over the place, and it's the worst possible way of reading serial. Whoever posted the first instance of such code and started this chain of evil should be taken outside and shot.

Instead you must read the serial properly. Being lazy like that doesn't work.

Read this blog post to learn more about reading serial data properly.

3
  • Thank you very much. My problem was in fact the buffer limit. I made a workaround where I would add every GET paramater seperatly in a function and only at the end I made a commit by writing \r\n so it gets interpreted as one big command. Apr 15, 2019 at 7:31
  • @The_javascript_King, the answer was not about TX buffer
    – Juraj
    Apr 15, 2019 at 9:48
  • With "buffer limit" I meant the limit given by SoftwareSerial Apr 15, 2019 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.