这次作品用了mind+1.80最新版本,和SIOT V2物联网搭建平台。mind+1.80增加了可视化操作平台使作品展示更加丰富。
下面介绍一下我本次作品所使用器材。
硬件材料:
1、掌控板。
2、温湿度传感器。
3、MQ9气体监测传感器。
4、杜邦线若干。
电路连接如下图所示。

步骤1 连接好电路后开始搭建开发环境。
首先打开物联网搭建平台,打开SIOT V2.

步骤2 连接wifi 和MQTT参数配置。

步骤3 读取数据和发送数据

步骤4 搭建好SIOT平台

步骤5 搭建好可视化数据面板

步骤6 编写完整的程序

步骤7 最后看一下最终效果。
附件
代码
 /*!
 * MindPlus
 * mpython
 *
 */
#include <MPython.h>
#include <DFRobot_DHT.h>
#include <DFRobot_Iot.h>
// 动态变量
String         mind_s_HuanJingGuangXianZhi, mind_s_ShengYinZhi;
volatile float mind_n_XuanZhuanBianMaQiShuZhi, mind_n_ShiDuZhi, mind_n_WenDuZhi;
// 静态常量
const String topics[5] = {"siot/掌控板","","","",""};
// 创建对象
DFRobot_Iot myIot;
DFRobot_DHT dht11_P8;
// 主程序开始
void setup() {
	mPython.begin();
	dht11_P8.begin(P8, DHT11);
	mind_n_XuanZhuanBianMaQiShuZhi = 0;
	myIot.wifiConnect("dfsgdfg", "234534545454");
	while (!myIot.wifiStatus()) {yield();}
	display.setCursorLine(2);
	display.printLine("wifi OK");
	myIot.init("192.168.0.110","siot","9105777759729661","dfrobot", topics, 1883);
	myIot.connect();
	while (!myIot.connected()) {yield();}
	display.setCursorLine(3);
	display.printLine("MQTTOK");
	myIot.subscribeTopic("siot/温度传感器");
	myIot.subscribeTopic("siot/湿度传感器");
	myIot.subscribeTopic("siot/环境光线值");
	myIot.subscribeTopic("siot/气体监测");
	display.fillScreen(0);
}
void loop() {
	mind_n_XuanZhuanBianMaQiShuZhi = (analogRead(P0));
	Serial.begin(9600);
	display.setCursorLine(1);
	display.printLine("创客工作室环境监测");
	myIot.publish("siot/温度传感器", dht11_P8.getTemperature(), 1);
	myIot.publish("siot/湿度传感器", dht11_P8.getHumidity(), 1);
	mind_n_ShiDuZhi = dht11_P8.getTemperature();
	mind_n_WenDuZhi = dht11_P8.getHumidity();
	display.setCursorLine(2);
	display.printLine((String("温度:") + String(mind_n_ShiDuZhi)));
	display.setCursorLine(3);
	display.printLine((String("湿度:") + String(mind_n_WenDuZhi)));
	myIot.publish("siot/旋转编码器", (map((analogRead(P2)), 0, 1023, 0, 255)), 1);
	myIot.publish("siot/气体监测", (analogRead(P0)), 1);
	mind_s_HuanJingGuangXianZhi = (light.read());
	mind_s_ShengYinZhi = (sound.read());
	delay(1000);
	myIot.publish("siot/环境光线值", (String((String(mind_s_ShengYinZhi) + String(","))) + String(mind_s_HuanJingGuangXianZhi)), 1);
}

 返回首页
    返回首页
   回到顶部
    回到顶部
   
 
 
  
  他的勋章
    他的勋章
  

花生编程2023.08.03
赞赞赞
花生编程2023.08.03
厉害厉害
三春牛-创客2023.07.31
66666
三春牛-创客2023.07.31
厉害厉害