本帖最后由 weijinhe 于 2014-10-15 12:49 编辑
智慧农业是农业生产的高级阶段,依托部署在农业生产现场的各种传感节点(环境温湿度、土壤水分、二氧化碳、光照及RFID标签等)和无线通信网络实现农业生产环境的智能感知、智能预警及智能决策等,为农业生产提供精准化种植、可视化管理、智能化决策。 一、智慧农业解决方案包括: 1、Machtalk物联网平台云服务,实时监控植物生长状态。machtalk.net 2、数据采集系统:土壤湿度、光照、温度传感器等。 3、控制通讯系统:arduino、wifi模块、zigbee模
[mw_shl_code=cpp,true]void setup() {
Serial.begin(115200);
pinMode(13,OUTPUT);
}
int time=0;
void loop() {
time=time+1;
if(time>5000)
{
time=0;
}
if (time%3==1)
{
int valt, sensort;
sensort=analogRead(A0);
valt=map(sensort, 0, 1023, 0, 100);
Serial.println("POST /v1.0/device/b7eee47edda741e5b2c8856b70850327/1/1/datapoints/add HTTP/1.1"); //设备ID用自己的替换 土壤湿度
Serial.println("Host: api.machtalk.net");
Serial.println("APIKey:7a19bd7874a541a6b4c50a831ea0b3b2"); //自己的替代
Serial.print("Accept: *");
Serial.print("/");
Serial.println("*");
Serial.print("Content-Length: ");
int thislength=17+getLength(valt);
Serial.println(thislength);
Serial.println("Content-Type: application/x-www-form-urlencoded");
Serial.println("Connection: close");
Serial.println();
Serial.print("params={\"value\":");
Serial.print(valt);
Serial.println("}");
delay(5000);
}
if (time%3==2)
{
int valg, sensorg;
sensorg=analogRead(A1);//光照
valg=map(sensorg, 0, 1023, 0, 100);
Serial.println("POST /v1.0/device/d4f5ca259a67420488a62e037cc25625/1/1/datapoints/add HTTP/1.1"); //设备ID用自己的替换 光照
Serial.println("Host: api.machtalk.net");
Serial.println("APIKey:7a19bd7874a541a6b4c50a831ea0b3b2"); //自己的替代
Serial.print("Accept: *");
Serial.print("/");
Serial.println("*");
Serial.print("Content-Length: ");
int thislength=17+getLength(valg);
Serial.println(thislength);
Serial.println("Content-Type: application/x-www-form-urlencoded");
Serial.println("Connection: close");
Serial.println();
Serial.print("params={\"value\":");
Serial.print(valg);
Serial.println("}");
delay(5000);
}
if (time%3==0)
{
int sensorValue;
int dat = analogRead(A2);
sensorValue=(125*dat)>>8;
Serial.println("POST /v1.0/device/f2d621e1f2c647098cf315589e832e51/1/1/datapoints/add HTTP/1.1"); //设备ID用自己的替换 温度传感器
Serial.println("Host: api.machtalk.net");
Serial.println("APIKey:7a19bd7874a541a6b4c50a831ea0b3b2"); //自己的替代
Serial.print("Accept: *");
Serial.print("/");
Serial.println("*");
Serial.print("Content-Length: ");
int thislength=17+getLength(sensorValue);
Serial.println(thislength);
Serial.println("Content-Type: application/x-www-form-urlencoded");
Serial.println("Connection: close");
Serial.println();
Serial.print("params={\"value\":");
Serial.print(sensorValue);
Serial.println("}");
delay(5000);
}
}
int getLength(int someValue) {
int digits = 1;
int dividend = someValue /10;
while (dividend > 0) {
dividend = dividend /10;
digits++;
}
return digits;
}
[/mw_shl_code]
|