将Arduino主数据保存在数据库中

我想将传感器数据保存在我的数据库中。
因此我想对php文件进行GET请求 在哪里我比较uuid的。 这只是为了看看这个arduino是否已经存在于数据库中。 如果这个Uuid不存在,那么我想要做一个新的条目。 </ p>

有人想法如何实现这一点? </ p>

正如我之前所说,我考虑过对我的网络服务器上的php文件进行获取请求,但这不成功。 因为我没有静态UUID。

因此我需要将其硬编码到我的arduino中,我也不知道该怎么做。 </ p>

PHP文件
Arduino代码 </ p>
</ div>

展开原文

原文

I want to save the sensor data in my database. Therefore I want to do a GET request to a php file where I compare the uuid's. That's just to look if this arduino already exists in the database. If this Uuid does not exist than I want to do a new entry.

Have someone ideas how to realize that?

As I said before, I thought about doing a get request to the php file on my webserver but this wasn't successfull. Beceause I havent a static UUID. Therefore I need to hardcode it into my arduino and I also dont know how to do that.

PHP-File Arduino Code

dongliang1941
dongliang1941 我已经加载了我的php-File和我的Arduino代码。对不起,我知道我的问题有些混乱,但我不知道如何准确地解释我的问题。我试图将Arduino的请求发送到Web服务器。连接已经发生,但我没有收到请求的响应。所以我不知道问题是在请求上还是在php文件上。
大约 4 年之前 回复
dtt3399
dtt3399 这个问题看起来很模糊(但对于downvote并不那么模糊)。您能否提供有关您尝试过的内容和发生的事情的更多信息?你说“这不成功”-究竟发生了什么?
大约 4 年之前 回复

1个回答

cool project. I spot several locations where your issues could be coming from.

In your php code you expect the parameters sensorType, batteryState, onlineState, sending, frequency, sensorDateTimeId and value to be available as get parameters,yet in your arduino code, you're not sending any of those, you're only sending a uuid.

in you php code, you're using variable $uuid, yet you're not populating it anywhere.

you're trying to use mysql_real_escape_string on a array, that will lead to a error. Besides, mysql_real_escape_string is deprecated,and even removed from php in php7. you'd better use other libraries to communicate with mysql. you can for instance have a look at this tutorial: http://codular.com/php-mysqli

If you fix all of those errors, you can try your php code first, before moving on to the arduino code. you should be able to try it by just calling the php page from a browser in this way:

http://yourserver/easy2sense/phpfiles/sensor_connection.php?uuid=12345&sensorType=1&batteryState=2&onlineState=3&sending=4&frequency=5&sensorDateTimeId=6&value=7

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐