基于行空板K10的植物生长监视仪
在21世纪的农业领域,科技的进步正以前所未有的速度改变着传统农耕方式。智能农业作为现代农业的重要组成部分,通过引入物联网(IoT)、大数据、人工智能(AI)等先进技术,正在逐步实现农业生产的精细化和智能化管理。基于行空板K10的植物生长监视仪监测植物生长环境的温度、光照和土壤湿度,并通过互联网传输至云端,方便随时随地查看植物生长环境状态。
使用的材料:
行空板K10、土壤湿度传感器。
实现的模块化代码如下:
C源码如下:
/*!
* MindPlus
* esp32s3bit
*
*/
#include <DFRobot_Iot.h>
#include "unihiker_k10.h"
// 静态常量
const String topics = {"temperature","light","humidity","",""};
// 创建对象
UNIHIKER_K10 k10;
uint8_t screen_dir=2;
DFRobot_IotmyIot;
AHT20 aht20;
// 主程序开始
void setup() {
k10.begin();
k10.initScreen(screen_dir);
k10.creatCanvas();
k10.setScreenBackground(0xFFCC99);
myIot.wifiConnect(" ", " ");
while (!myIot.wifiStatus()) {}
k10.canvas->canvasText(myIot.getWiFiSoftIP(), 1, 0x0000FF);
k10.rgb->write(1, 0xFFFF00);
myIot.init("192.168.99.143","siot","36148494345778936","dfrobot", topics, 1883);
myIot.connect();
while (!myIot.connected()) {}
k10.rgb->write(2, 0x0000FF);
delay(1000);
}
void loop() {
k10.canvas->canvasText("植物生长监视仪", 0, 10, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
k10.canvas->canvasText(aht20.getData(AHT20::eAHT20TempC), 0, 60, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
k10.canvas->canvasText((analogRead(P0)), 0, 120, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
k10.canvas->canvasText(k10.readALS(), 0, 180, 0x0000FF, k10.canvas->eCNAndENFont24, 50, true);
k10.rgb->write(0, 0x00FF00);
k10.canvas->updateCanvas();
myIot.publish("siot/temperature", aht20.getData(AHT20::eAHT20TempC), 1);
myIot.publish("siot/light", k10.readALS(), 1);
myIot.publish("siot/humidity", (analogRead(P0)), 1);
delay(5000);
k10.rgb->write(0, 0x000000);
}
SIOT服务端数据
页:
[1]