亿迅智能制造网
工业4.0先进制造技术信息网站!
首页 | 制造技术 | 制造设备 | 工业物联网 | 工业材料 | 设备保养维修 | 工业编程 |
home  MfgRobots >> 亿迅智能制造网 >  >> Manufacturing Technology >> 制造工艺

DasFilisera 温室

组件和用品

DHT22 温度传感器
× 1
DS18B20
× 1
土壤温湿度传感器FS200-SHT25
× 1
4 通道中继模块
× 1
2通道中继模块
× 1
超声波传感器 - HC-SR04(通用)
× 1
Arduino MKR1000
× 1

应用和在线服务

DasData
Microsoft Visual Studio 2015

关于这个项目

种植植物和蔬菜时要更加了解它们的环境条件。只需使用 MKR1000

植物生长的要求

植物生长取决于几个理想的环境条件,例如温度、湿度、光线和其他矿物营养物或氧气。

为植物提供足量的水或保持温室中的正常温度可能是一个棘手的过程,但如果您能更轻松地做到这一点,则并非如此。

硬件概览

温度/湿度

TH1 - 外部温度值将由防水 DS18B20 传感器提供 - D1 引脚连接

TH2 - 内部温度/ 哼。可以从 DHT22 - pin D0 中找到

TH3 - FS200/SHT25 - 将在土壤条件下引入。 SCL 和 SDA 引脚 12/11 的连接

水杆

W1 - 为了获得水位,将使用超声波传感器,如 HC - A0 处的 SR04 连接 - 回声和 A1 处的触发器。基于此值,您可以使用 R1 - 4 通道继电器控制阀门。

气温/氧气

A1 - 根据温度/湿度值,您可以使用 R2 继电器命令何时打开窗户。根据气候,您应该根据需要对其进行调整。

继电器 R1 / R2

要设置一些命令,例如打开 Windows 或启动任何泵,您可以向继电器发送命令...... R1 连接到数字引脚 7,8,9,10 和 R2 5,6

MKR1000 - 休息

现在我们将所有东西连接在一起,是时候获取一些数据并使用 aRest 库进行感知,这将为 MKR1000 设备提供一个带有 json 格式字符串的 Web 界面。使用下面提供的库、.ino 文件并相应地更改您的 Wifi 路由器连接。

数据和接口

只要我们的设备有一个接口,我们就可以使用这些数据并在本地网络上查看它。

我们一直在使用 Visual Studio 2015 和 .net 来构建一个 Windows 应用程序,该应用程序将帮助您可视化温室生活条件以及您想要集成的一些日常历史或各种日志。

为了存储在云中,我们简单地使用了 DasData 温室配置,或者您可以创建自己的数据通道。

下一步将是修改应用程序文件夹中 Settings.txt 中提供的 DsKey 和 AKey。如果一切正常,您应该已经可以在网上看到一些数据了。

关注 DasData 的黑客频道以获取更多未来更新

温室自动化

您应该根据您的温室配置和尺寸来决定哪些阀门或电机会产生更多动作。所有这些都可以通过继电器进行控制。

代码

  • Filisera_Arduino
  • libraries.zip
  • Filisera - vb.zip
  • Filisera - VS
Filisera_Arduino C/C++
DASFilisera 使用 Arduino/Genuino MKR1000 板的 aREST 库。
/* DASFilisera 使用 Arduino/Genuino MKR1000 板的 aREST 库。 aREST - 由 Marco Schwartz 在 2016 年根据 GPL 许可编写。*/// 导入所需的库#include #include #include #include "DHT.h"#include #include #include #include // ********************** ***// ** 温度传感器 **// *************************#define DHTPIN 0 // 内部湿度/温度/热量index#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321#define ONE_WIRE_BUS 1OneWire oneWire(ONE_WIRE_BUS);DallasTemperature sensor(&oneWire);float umidSol =0; // 土壤湿度浮动 umidAer =0; // 空气湿度浮动 tempIn =0; // 温度浮动 tempOut =0; // 温度超出 tempSol =0; // 容器volumefloat umidexIn =0; // 感觉像 temp//VOLUM #define echoPin A0 // Echo pin A0#define trigPin A1 // 触发 pin A1long duration; // 计算距离的持续时间int HR_dist =0; // 计算的 distanceint minimumRange=5; //Min Sonar rangeint maximumRange=200; //最大声纳范围unsigned long pulseduration=0;int nivelCm, nivelRamasCm;int nivelProc, nivelVol;int empty =100;int full =100;int sqrLevel, sqrInvertLevel; // Statusint status =WL_IDLE_STATUS;// 创建一个REST实例aREST rest =aREST();// WiFi参数char ssid[] ="WIFI_AP";char password[] ="WIFI_PASSW";//监听传入TCP连接的端口# define LISTEN_PORT 80// 创建一个服务器实例WiFiServer server(LISTEN_PORT);//INITIALIZARE SENZORI DHT dht(DHTPIN, DHTTYPE);// RELEE RELEEEint aVentil, aLateral;int inReleu1Ventil =6;int inReleu2Ventil =7;;int inReleu4Ventil =9;int inReleu1Lateral =10;int inReleu2Lateral =11;// 声明函数暴露给APIint ledControl(String command);void setup(void){ // 开始Serial Serial.begin(115200); // 初始化变量并将它们暴露给 REST API // rest.variable("温度",&温度);// rest.variable("湿度",&湿度); // 要暴露的函数 rest.function("led",ledControl); // 为设备提供名称和 ID rest.set_id("1"); rest.set_name("mkr1000"); // 连接到 WiFi while (status !=WL_CONNECTED) { Serial.print("Attempting to connect to SSID:"); Serial.println(ssid); status =WiFi.begin(ssid, password); // 等待 10 秒连接:delay(10000); Serial.println("WiFi 已连接"); // 启动服务器 server.begin(); Serial.println("服务器启动"); // 打印 IP 地址 IPAddress ip =WiFi.localIP(); Serial.print("IP 地址:"); Serial.println(ip); // 设置 DHT - 内部 DHT dht(DHTPIN, DHTTYPE);//sensors.begin(); // 色情传感器外部温度 DS-16B20 pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); // 初始化变量并将它们暴露给 REST API rest.variable("Vol_container",&sqrLevel ); rest.variable("Umiditate_sol",&umidSol); rest.variable("Umiditate_aer",&umidAer); rest.variable("Temp_in",&tempIn ); rest.variable("Temp_out",&tempOut ); rest.variable("Temp_sol",&tempSol); // rest.variable("Umidex_in",&umidexIn ); //sensors.requestTemperatures(); // 温度输出 }void loop() { getmyDistance(); // getSoilVals(); getInsideVals();// getOutSideVals(); // 处理 REST 调用 WiFiClient client =server.available();如果(!客户端){ 返回; } while(!client.available()){ 延迟(1); } rest.handle(client);}void getmyDistance() { digitalWrite(trigPin,LOW);延迟微秒(2);数字写入(触发引脚,高);延迟微秒(10);数字写入(trigPin,低);持续时间 =pulseIn(echoPin,HIGH); //计算距离 HR_dist =duration/58.2;// sqrLevel =empty - HR_dist; if (HR_dist>=maximumRange || HR_dist <=minimumRange) { sqrLevel =0; } else { sqrLevel =empty - HR_dist; Serial.println(HR_dist); } 延迟(100); }void getDistance() {digitalWrite(trigPin, LOW);delayMicroseconds(10);// 现在发送 10uS 脉冲以激活 Ping digitalWrite(trigPin, HIGH);延迟微秒(10); digitalWrite(trigPin, LOW);// 最后,测量传入脉冲的长度 pulseduration =pulseIn(echoPin, HIGH);// 脉冲长度除以 halfpulseduration =pulseduration/2;// 转换为厘米.nivelRamasCm =int( pulseduration/29);nivelCm =empty - nivelRamasCm;nivelVol =map(nivelRamasCm, full, empty, 100, 0);// 以厘米为单位的 Tipareste nivelul if (nivelCm>=-5 &&nivelCm <=135) { double a =nivelCm / 100 * nivelVol; int sqrLevel =240 - nivelCm; int sqrInvertLevel =120 + nivelRamasCm; if (nivelCm>65 &&nivelCm <=85){ } if (nivelCm>85 &&nivelCm <=100){ } } }long microsecondsToCentimeters(长微秒){ // 声速为 340 m/s 或 29 microseconds per厘米 // ping 来回移动,因此,距离是移动距离的一半 return microseconds / 29 / 2;}void getInsideVals() { float h =dht.readHumidity(); // 读取摄氏温度(默认) float t =dht.readTemperature(); // 读取温度为华氏度 (isFahrenheit =true)// float f =dht.readTemperature(true); umidAer =h;温度 =t; // 检查是否有任何读取失败并提前退出(重试)。 if (isnan(h) || isnan(t)) { Serial.println("从 DHT 传感器读取失败!");返回; } // 以华氏度计算热量指数(默认) //float hif =dht.computeHeatIndex(f, h); // 计算摄氏温度指数 (isFahreheit =false) // float hic =dht.computeHeatIndex(t, h, false); // umidexIn =hic; }void getOutSideVals() { tempOut =sensor.getTempCByIndex(0); Serial.println("温度输出:"); Serial.print(tempOut); } void getSoilVals() { umidSol =SHT2x.GetHumidity(); tempSol =SHT2x.GetTemperature(); Serial.println("土壤湿度(%RH):"); Serial.print(umidSol); Serial.print("温度土壤(C):"); Serial.print(tempSol); } //sensors.requestTemperatures(); // 温度输出 // APIint ledControl(String command) 可访问的自定义函数 { // 从命令中获取状态 int state =command.toInt();数字写入(6,状态);返回 1;} 
libraries.zipC/C++
Filisera 中使用的库
无预览(仅限下载)。
Filisera - vb.zipVBScript
.net Visual Studio 项目
无预览(仅限下载)。
Filisera - VS VBScript
.net 文件,将从 arduino 读取数据并显示接口设备 IP 私有 intVolumContainer、intUmidSol、intUmidSera、intTempAfara、intTempSera、intTempSol、intUmidex As String 'VARIABILES Private strR1, strR2 As String 'RELAYS Public Count As CountDown 'COUNTDOWN TICK Private _dasResult As String ' VARIABILES String ="" 'USER KEY DASDATA Private _DSKey As String ="" 'DATASET KEY DASDATA Private _myDas As New dasData.das Private Sub Form1_Load(sender As Object, e As EventArgs) 处理MyBase.Load Count =New CountDown(50, 0) ) '5 秒更新 AddHandler Count.Tick, AddressOf Count_Tick AddHandler Count.TimesOut, AddressOf Times_up 尝试 'READ SETTINGS FROM .txt FILE Dim path As String =Directory.GetCurrentDirectory( ) Dim FILE_NAME As String =path &"\Settings.txt" Dim myText As String ="" ' If System.IO.File.Exists(FILE_NAME) =True Then Dim objReader As New System.IO.StreamReader(FILE_NAME, System. Text.Encoding.Default) Do While objReader.Peek() <> -1 myText &=objReader.ReadLine() Loop Dim _settingItems() As String =myText.Split(" ") _deviceIP =_settingItems(0) 'IP-ul DEVICE _AKey =_settingItems(1).Replace("akey:", "") _DSKey =_settingItems(2).Replace("dskey:", "") cbxEnabled.Text ="Device:" &_deviceIP txtInfo.Text =" IP设备:" &_deviceIP &vbNewLine &"AKey:" &_AKey &vbNewLine &"DSKey:" &_DSKey &vbNewLine strR1 =_settingItems(3).Replace("relay1:", "") txtInfo.Text +="Relay1 :" &strR1 &vbNewLine strR2 =_settingItems(4).Replace("relay2:", "") txtInfo.Text +="Relay2:" &strR2 &vbNewLine ' txtInfo.Text ="设置:" &myText objReader.Dispose () objReader.Close() End If Catch ex As Exception lblDevice.Text =ex.Message.ToString End Try cmdCheckDevice() 'LOCAL SETTINGS Thread.CurrentThread.CurrentCulture =New CultureInfo("en-US") 'Thread.CurrentThread.CurrentUICulture =New CultureInfo("ro-RO") cmdStartFilisera() End Sub Private Sub Count_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) cmdGetSensorValues() cmdTriggers() If CDate(dtFrom.Text).ToString("dd.MM.yyyy") =Date.Now().ToString("dd.MM.yyyy") 然后 cmdStartFilisera() End If End Sub Private Sub Times_up(ByVal sender As System.Object, ByVal e As System.EventArgs) ' Count.Reset() 'Count.Pause() End Sub Private Sub cmdStartFilisera() Try dtFrom.MaxDate =DateTime.Now _dasResult =_myDas.getDas(_DSKey, "json", 0, 100) cmdFillData() Catch ex As Exception lblDevice.Text +=ex.Message.ToString End Try End Sub Private Sub cbxEnabled_CheckedChanged(sender As Object, e As EventArgs) 处理 cbxEnabled。 CheckedChanged cmdCheckDevice() End Sub Private Sub cmdCheckDevice() Try If cbxDemo.Checked =False Then lblDevice.Text =("Enable device!") lblEvenimente.Text =Date.Now.ToString("dd.MM .yyyy HH:mm:ss") 如果 cbxEnabled.Checked =True 那么将 pingsender 调暗为新 Net.NetworkInformation.Ping 如果不是 pingsender.Send(_deviceIP).Status =Net.NetworkInformation.IPStatus.Success 那么 lblDevice.Text =("本地网络上的设备不可用!”)cbxEnabled.Checked =False btnTemperatura.Enabled =False btnVolumContainer.Enabled =False Count.Reset() Count.Pause() MessageBox.Show(“未找到设备在“&_deviceIP&”! ") Else lblDevice.Text =("设备已连接!") btnTemperatura.Enabled =True btnVolumContainer.Enabled =True cmdGetSensorValues() Timer1.Enabled =True cmdAddData() Count.Start() End If Else End If Else btnTemperatura.Enabled =True btnVolumContainer.Enabled =True cmdGetSensorValues() Timer1.Enabled =True cmdAddData() Count.Start() End If Catch ex As Exception End Try End Sub Private Sub btnVolumContainer_Click(sender As Object, e As EventArgs) 处理 btnVolumContainer.Click ' http ://192.168.0.102/digital/7/1 '关闭水按钮 Dim _ItemsR1() As String =s trR1.Split(",") 如果 btnVolumContainer.Text.Contains("Open") 然后 cmdRelay(_ItemsR1(0), 1) cmdRelay(_ItemsR1(1), 1) cmdRelay(_ItemsR1(2), 0) cmdRelay(_ItemsR1) (3), 0) btnVolumContainer.Text ="关水" Else cmdRelay(_ItemsR1(0), 0) cmdRelay(_ItemsR1(1), 0) cmdRelay(_ItemsR1(2), 1) cmdRelay(_ItemsR1(3), 1 ) btnVolumContainer.Text ="Open water" End If ' Dim _url As String =_deviceIP &"digital/7/1" End Sub Private Sub btnTemperatura_Click(sender As Object, e As EventArgs) 处理 btnTemperatura.Click 'CLOSE WINDOW FROM BUTTON Dim _ItemsR2() As String =strR2.Split(",") If btnTemperatura.Text.Contains("Open") Then cmdRelay(_ItemsR2(0), 1) cmdRelay(_ItemsR2(1), 1) btnTemperatura.Text ="Close window" Else cmdRelay(_ItemsR2(0), 0) cmdRelay(_ItemsR2(1), 0) btnTemperatura.Text ="Open window" End If End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) 处理 Timer1.Tick cmdAddData () End Sub Private Sub btnTestCloud_Click(sender As Object, e As EventArgs) 处理 btnTestCloud。单击 Try cmdStartFilisera() Catch ex As Exception MessageBox.Show("Lost connection with DasData!") End Try End Sub Private Function cmdRelay(ByVal _DPin As String, ByVal _cmd As Int16) Try Dim _urlCommand As String =_deviceIP &"/digital /" &_DPin &"/" &_cmd Dim client As New WebClient() client.Headers.Add("user-agent", "Arduino/4.0 (compatible; MSIE 6.0;视窗 NT 5.2; .NET CLR 1.0.3705;)") Dim data As Stream =client.OpenRead(_urlCommand) Dim reader As New StreamReader(data) Dim s As String =reader.ReadToEnd() ' txtInfo.Text +=(s) data。 Close() reader.Close() Catch ex As Exception End Try End Function Private Sub dtFrom_ValueChanged(sender As Object, e As EventArgs) 处理 dtFrom.ValueChanged Try 'GET VALUES BASED ON DATE SELECTION _dasResult =_myDas.getDas(_DSKey, "jsond ", CDate(dtFrom.Text).ToString("dd.MM.yyyy"), CDate(dtFrom.Text).ToString("dd.MM.yyyy")) cmdFillData() Catch ex As Exception MessageBox.Show(ex .Message.ToString) End Try End Sub Private Sub cmdGetSensorValues() Try ''GET SENSOR VALUES FROM DEVICE If cbxDemo.Checked =False Then Dim client As New WebClient() client.Headers.Add("user-agent", "Arduino /4.0 (兼容; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)") Dim data As Stream =client.OpenRead("http://" &_deviceIP &"/index.html") Dim reader As New StreamReader(data) Dim s As String =reader.ReadToEnd() s =s.Replace("""", "").Replace("}", "").Replace("{", "").Replace(" ", "").Replace("variables:", "") Dim sItems() As String =s.Split(",") intVolumContainer =cmdGetVal(sItems(0)) intUmidSol =cmdGetVal(sItems(1)) intUmidSera =cmdGetVal(sItems(2)) intTempSera =cmdGetVal(sItems(3)) intTempAfara =cmdGetVal(sItems) 4)) intTempSol =cmdGetVal(sItems(5)) data.Close() reader.Close() Else intVolumContainer =_rnd(60) intUmidSol =_rnd(80) intUmidSera =_rnd(20) intTempSera =_rnd(45) intTemprndara =(57) intTempSol =_rnd(66) End If ggVolum.Value =intVolumContainer rgVolum.Value =intVolumContainer ggUmidSol.Value =intUmidSol ggUmidSera.Value =intUmidSera ggTempSera.Value =intTempSera ggTempOut.Value =intTempAfara =intTempAfara =intTempAfara =intTempAfara ggS '{“变量”{“Volum_container”:0,“Umiditate_sol”:0.00,“Umiditate_aer”:36.60,“Temp_in”:26.50,“Temp_out”:0.00,“Temp_sol”:0.00,“Umiditate_aer”:36.60,“Temp_sol”:0.00,“Umiditate_aer”:36.60 id":"1", "name":"FiliSera", "hardware":"arduino", "connected":true} End Try E nd Sub Private Function cmdGetVal(ByVal _sItem As String) Try 'SPLIT STRING AND GET VALUES BACK Dim _s() As String =_sItem.Split(":") Return _s(1) Catch ex As Exception End Try End Function Private Sub cmdAddData () 尝试将数据发送到 DASDATA 云存储 Dim _strFiliseraDataSend As String =intVolumContainer &"|" &intUmidSol &"|" &intUmidSera &"|" &intTempAfara &"|" &intTempSera &"|" &intTempSol '&"| "&intUmidex &"|"&Dim _dasResult As String =_myDas.sendDas(_strFiliseraDataSend, _DSKey, _AKey) Catch ex As Exception cmdLogMe("ERROR..." &ex.Message.ToString(), "error") End Try End Sub Private Sub cmdFillData() Try 'FILL INTERFACE WILL ALL SORT OF DATA Dim dataSet As DataSet =JsonConvert.DeserializeObject(Of DataSet)(_dasResult) Dim dataTable As DataTable =dataSet.Tables(0) 'GRIDVIEW DataGridView1.DataSource =dataSet. Tables(0) DataGridView1.AutoGenerateColumns =True 'CHARTS ChartTemp.DataSource =dataTable ChartTemp.Series.Clear() chartUmid.DataSource =dataTable ch artUmid.Series.Clear() chartVolum.DataSource =dataTable chartVolum.Series.Clear() Dim i As Integer =0 Dim j As Integer =0 Dim k As Integer =0 For Each table In dataSet.Tables For Each row In table. table.Columns 中的每个 col 行 Dim colName As String =col.ColumnName.ToString If colName <> "id" And colName <> "AIDate" Then Try Dim serieName As String =RTrim(colName) 'VOLUME If colName.Contains( "Nivel") 然后 chartVolum.Series.Add(serieName) chartVolum.Series(serieName).LabelFormat ="N1" chartVolum.Series(i).ChartType =SeriesChartType.Line chartVolum.Series(i).BorderWidth =2 chartVolum.Series (i).Color =Color.Aqua chartVolum.Series(i).BorderDashStyle =ChartDashStyle.Solid chartVolum.Series(serieName).YValueMembers =RTrim(colName) chartVolum.Series(serieName).XValueMember ="AIDate" i +=1 End If 'HUMIDITY If colName.Contains("Umid") Then chartUmid.Series.Add(serieName) chartUmid.Series(serieName).LabelFormat ="N1" chartUmid.Series(j).ChartType =SeriesChartType.Line chartU mid.Series(j).BorderWidth =2 chartUmid.Series(j).BorderDashStyle =ChartDashStyle.Solid chartUmid.Series(serieName).YValueMembers =RTrim(colName) chartUmid.Series(serieName).XValueMember ="AIDate" j +=1 End If 'TEMP If colName.Contains("Temp") Then ChartTemp.Series.Add(serieName) ChartTemp.Series(serieName).LabelFormat ="N1" ChartTemp.Series(k).ChartType =SeriesChartType.Line ChartTemp.Series (k).BorderWidth =2 ChartTemp.Series(k).BorderDashStyle =ChartDashStyle.Solid ChartTemp.Series(serieName).YValueMembers =RTrim(colName) ChartTemp.Series(serieName).XValueMember ="AIDate" k +=1 End If Catch ex As Exception End Try End If Next Exit For Next Next '填充图表 ChartTemp.DataBind() ChartTemp.Visible =True chartUmid.DataBind() chartUmid.Visible =True chartVolum.DataBind() chartVolum.Visible =True Catch ex As异常 cmdLogMe("ERROR..." &ex.Message.ToString(), "error") End Try End Sub Private Sub cmdTriggers() 'SET TRIGGERS AND STORE THE LOG Select Case intVolumContain er Case> 80 cmdLogMe("HIGH HIGH - Container volume - stop water", "0") Case> 70 ' cmdLogMe("HIGH - Container volume - water will start", "1") Case <20 ' cmdLogMe("LOW - 容器容积低 - 水将停止", "1") Case <10 cmdLogMe("LOW LOW - 容器容积高高高 - 开始水", "0") End Select Select Case intTempSera Case> 38 cmdLogMe("HIGH HIGH HIGH HIGH - 温室温度 - 打开窗户", "0") Case> 30 ' cmdLogMe("HIGH - 温室温度 - 准备窗户", "1") Case <10' cmdLogMe("LOW - 温室温度 - prepare windows", "1") Case <10 cmdLogMe("LOW LOW - Container volume high high high high-start water", "0") End Select End Sub Public Function _rnd(ByVal n As Integer) As Integer '初始化随机数生成器 Dim r As New Random(System.DateTime.Now.Millisecond) Return r.Next(1, n) End Function Private Sub cmdLogMe(message As String, _type As String) Try Dim _strLog As String ="adeewdf4-4aa34-14ass24 -8436-aea1" 'LOG DASDATA DS KEY lstEv enimente.Items.Add((System.DateTime.Now &" " &message) + Constants.vbNewLine) 'STORE LOGS TO DASDATA _myDas.sendDas(message &"|" &_type, _strLog, _AKey) Catch ex As Exception cmdLogMe( "ERROR..." &ex.Message.ToString(), "error") End Try End SubEnd Class
源文件 - Filisera
https://github.com/dasdata/DasFilisera

示意图

带连接的 PDF 文件 - 传感器和继电器

制造工艺

  1. 温度计
  2. Raspberry Pi 温度记录器
  3. 使用 1 线 DS18B20 传感器和 Raspberry Pi 测量温度
  4. TMP006 温度传感器 Python 库,使用 Raspberry pi,
  5. Python 和 Raspberry Pi 温度传感器
  6. Raspberry Pi 上的 1 线温度传感器 DS1820(直接 GPIO)
  7. Raspberry Pi 1-Wire 数字温度计传感器 (DS18B20)
  8. Raspberry Pi 温度和光传感器
  9. Raspberry Pi 温度传感器
  10. 轴承温度传感器 |探测器
  11. 片上实验室流量和温度传感器
  12. 红外传感器温度测量