diff --git a/智能节水花盆.sln b/智能节水花盆.sln new file mode 100644 index 0000000..3403ea6 --- /dev/null +++ b/智能节水花盆.sln @@ -0,0 +1,51 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33403.182 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "智能节水花盆", "智能节水花盆\智能节水花盆.vcxproj", "{9C776B16-FBEB-40D4-A346-114384E760E3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9C776B16-FBEB-40D4-A346-114384E760E3}.Debug|ARM.ActiveCfg = Debug|ARM + {9C776B16-FBEB-40D4-A346-114384E760E3}.Debug|ARM.Build.0 = Debug|ARM + {9C776B16-FBEB-40D4-A346-114384E760E3}.Debug|ARM.Deploy.0 = Debug|ARM + {9C776B16-FBEB-40D4-A346-114384E760E3}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Debug|ARM64.Build.0 = Debug|ARM64 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Debug|x64.ActiveCfg = Debug|x64 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Debug|x64.Build.0 = Debug|x64 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Debug|x64.Deploy.0 = Debug|x64 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Debug|x86.ActiveCfg = Debug|x86 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Debug|x86.Build.0 = Debug|x86 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Debug|x86.Deploy.0 = Debug|x86 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Release|ARM.ActiveCfg = Release|ARM + {9C776B16-FBEB-40D4-A346-114384E760E3}.Release|ARM.Build.0 = Release|ARM + {9C776B16-FBEB-40D4-A346-114384E760E3}.Release|ARM.Deploy.0 = Release|ARM + {9C776B16-FBEB-40D4-A346-114384E760E3}.Release|ARM64.ActiveCfg = Release|ARM64 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Release|ARM64.Build.0 = Release|ARM64 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Release|ARM64.Deploy.0 = Release|ARM64 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Release|x64.ActiveCfg = Release|x64 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Release|x64.Build.0 = Release|x64 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Release|x64.Deploy.0 = Release|x64 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Release|x86.ActiveCfg = Release|x86 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Release|x86.Build.0 = Release|x86 + {9C776B16-FBEB-40D4-A346-114384E760E3}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B13AE56C-A90A-44BB-ACE8-3D913CC2041E} + EndGlobalSection +EndGlobal diff --git a/智能节水花盆/__vm/.智能节水花盆.vsarduino.h b/智能节水花盆/__vm/.智能节水花盆.vsarduino.h new file mode 100644 index 0000000..7322563 --- /dev/null +++ b/智能节水花盆/__vm/.智能节水花盆.vsarduino.h @@ -0,0 +1,20 @@ +/* + Editor: https://www.visualmicro.com/ + This file is for intellisense purpose only. + Visual micro (and the arduino ide) ignore this code during compilation. This code is automatically maintained by visualmicro, manual changes to this file will be overwritten + The contents of the _vm sub folder can be deleted prior to publishing a project + All non-arduino files created by visual micro and all visual studio project or solution files can be freely deleted and are not required to compile a sketch (do not delete your own code!). + Note: debugger breakpoints are stored in '.sln' or '.asln' files, knowledge of last uploaded breakpoints is stored in the upload.vmps.xml file. Both files are required to continue a previous debug session without needing to compile and upload again + + Hardware: Arduino Uno WiFi (unowifi), Platform=avr, Package=arduino +*/ + +#if defined(_VMICRO_INTELLISENSE) + +#ifndef _VSARDUINO_H_ +#define _VSARDUINO_H_ +#include +#include +#include "..\智能节水花盆.ino" +#endif +#endif diff --git a/智能节水花盆/__vm/Compile.vmps.xml b/智能节水花盆/__vm/Compile.vmps.xml new file mode 100644 index 0000000..249a636 --- /dev/null +++ b/智能节水花盆/__vm/Compile.vmps.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + 104 +105 display.println(" Wellcome To\n YANG\nIntelligent Flowerpot"); +106 display.display(); +107 delay(8000); +108 // display.begin(SSD1306_SWITCHCAPVCC, 0x3c); //初始化OLED并设置其IIC地址为 0x3C +109 } +110 +-->111 void loop() { +112 // delay(2000); +113 +114 buttonState = digitalRead(buttonPin); +115 +116 Serial.println(analogRead(14));//湿度传感器接ESP32上的GPIO号 +117 delay(100); +118 if (buttonState == LOW) { // 判断是否按下开关 +119 display.clearDisplay(); //清屏 +120 delay(200); + + + + + + + + \ No newline at end of file diff --git a/智能节水花盆/__vm/Configuration.Debug.vmps.xml b/智能节水花盆/__vm/Configuration.Debug.vmps.xml new file mode 100644 index 0000000..3ccf3f3 --- /dev/null +++ b/智能节水花盆/__vm/Configuration.Debug.vmps.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/智能节水花盆/src/arduino folders read me.txt b/智能节水花盆/src/arduino folders read me.txt new file mode 100644 index 0000000..71714e3 --- /dev/null +++ b/智能节水花盆/src/arduino folders read me.txt @@ -0,0 +1,14 @@ +##################################################### + Arduino How To: Use sub folders for source code + http://www.visualmicro.com/ +##################################################### + +* .INO code can exist in the project folder and '\src' folder. +* .Cpp/.c/.S/.h etc. can exist in the project folder, the '\src' folder and in any folder(s) below the '\src' folder. +* .Cpp/.c/.S/.h sources in shared code projects should follow the same folder rules (because they are merged with the project sources into a temporary build folder prior to compile). + +* Use the 'Show All Files' icon above the 'Solution Explorer' to switch between 'included project files' and 'physical files/folders'. +* Source code in the project folder will always be compiled regardless of inclusion in the project. This functionality can be disabled in Global Options. + + + diff --git a/智能节水花盆/智能节水花盆.ino b/智能节水花盆/智能节水花盆.ino new file mode 100644 index 0000000..95be764 --- /dev/null +++ b/智能节水花盆/智能节水花盆.ino @@ -0,0 +1,202 @@ +/* + Name: 智能节水花盆.ino + Created: 2023/3/15 0:22:26 + Author: qw200 +*/ + +#include +#include +#include //驱动128x64 and 128x32 的屏幕显示的库 +#include //Arduino的图形库 +#include +#include + +#define SCREEN_WIDTH 128 // OLED display width, in pixels +#define SCREEN_HEIGHT 64 // OLED display height, in pixels +// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) + +#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) +Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); +// Example testing sketch for various DHT humidity/temperature sensors +// Written by ladyada, public domain + +int M0 = 1024; //在空气中AO读取的值最大为1024,代表干燥时的读数 +int M1 = 0; //浸泡在水里的最小值 464(最小值会改变),代表100%湿度 +int PIN_AO = 14; //与wifi不冲突的pin +int in1 = 0; +int in2 = 2; +int LED = 15; +#include +#define DHTPIN 13//刚才插得2号引脚 +#define DHTTYPE DHT11//定义类型 +DHT dht(DHTPIN, DHTTYPE);//进行初始化设置 + +int buttonPin = 12; // 将开关连接到 +int buttonState = 0; +void setup() { + Serial.begin(9600); + dht.begin();//DHT开始工作 + pinMode(PIN_AO, INPUT); + pinMode(in1, OUTPUT); + pinMode(in2, OUTPUT); + pinMode(LED, OUTPUT); + digitalWrite(in1, LOW); + digitalWrite(in2, LOW); + digitalWrite(LED, LOW); + pinMode(buttonPin, INPUT_PULLUP); // 设 + //Serial.println("OLED FeatherWing test"); //串口输出信息 + + display.begin(SSD1306_SWITCHCAPVCC, 0x3c); //初始化OLED并设置其IIC地址为 0x3C + display.clearDisplay(); //清屏 + delay(200); + + display.setTextSize(1.3); + display.setTextColor(SSD1306_WHITE); + display.setCursor(0, 0); //设置光标的位置 + + //绘制像素点 + // display.drawPixel(64, 32, WHITE);//(x坐标,y坐标,颜色) + + //绘制水平线 + // display.drawFastHLine(64,32,64,SSD1306_WHITE);//(x起点,y起点,长度,颜色) + //绘制竖直线 + // display.drawFastVLine(64,10,50,SSD1306_WHITE); + + //绘制线 + // display.drawLine(0,0,128,64,SSD1306_WHITE);//(x起,y起,x终,y终) + + //绘制空心矩形 + // display.drawRect(0,0,128,64,SSD1306_WHITE);//(左上角x坐标,左上角y坐标,矩形长,矩形宽) + + //绘制实心矩形 + //display.fillRect(20,10,88,44,SSD1306_WHITE);//同上 + + //点亮全屏 + // display.fillScreen(SSD1306_WHITE); + + //绘制空心圆 + //display.drawCircle(64,32,32,SSD1306_WHITE);//(圆心x坐标,圆心y坐标,半径) + + //绘制实心圆 + //display.fillCircle(64,32,31,SSD1306_WHITE); + + //绘制空心三角形 + //display.drawTriangle(63,0, 0,63, 127,63, SSD1306_WHITE);//(第一顶点坐标[x,y],第二,第三) + + //绘制实心三角形 + // display.fillTriangle(63,0, 0,63, 127,63, SSD1306_WHITE); + + //绘制空心圆角矩形 + //display.drawRoundRect(10,5,107, 43,8, SSD1306_WHITE);//(左上角x,左上角y,矩形长,矩形宽,矩形圆角半径) + + //实心圆角 + //display.fillRoundRect(10,5,107,53,3, SSD1306_WHITE); + + //绘制Bitmap图像 + //Bimap图像数据 + + + + + display.display(); + display.println(""); + display.println(""); + + display.println(" Wellcome To\n YANG\nIntelligent Flowerpot"); + display.display(); + delay(8000); + // display.begin(SSD1306_SWITCHCAPVCC, 0x3c); //初始化OLED并设置其IIC地址为 0x3C +} + +void loop() { + // delay(2000); + + buttonState = digitalRead(buttonPin); + + Serial.println(analogRead(14));//湿度传感器接ESP32上的GPIO号 + delay(100); + if (buttonState == LOW) { // 判断是否按下开关 + display.clearDisplay(); //清屏 + delay(200); + + + display.setTextSize(1.3); + display.setTextColor(SSD1306_WHITE); + display.setCursor(0, 0); //设置光标的位置 + + // display.clearDisplay(); + //delay(8000); + + digitalWrite(in2, LOW); + digitalWrite(in1, LOW); + digitalWrite(LED, LOW); + + display.println("Hello, user!"); + display.println(""); + display.println("Enter Emergency\nBraking"); + display.println(""); + display.println("All programs have\nbeen closed for you"); + display.display(); + + // actually display all of the above + + delay(2000); + } + else { + + float h = dht.readHumidity();//读湿度 + float t = dht.readTemperature();//读湿度 + Serial.print("Humidity:");//湿度 + Serial.print(h); + Serial.println("%"); + Serial.print("Temperatrue:");//温度 + Serial.print(t); + Serial.println("C"); + display.clearDisplay(); + delay(200); + display.setTextSize(1.3); + display.setTextColor(SSD1306_WHITE); + display.setCursor(0, 0); //设置光标的位置 + float HUMI = ((M0 - analogRead(PIN_AO)) / ((M0 - M1) / 100)); //将湿度模拟量转换成数字量 + if (HUMI > 100.00) { + HUMI = 100; + } + if (HUMI > 80) { + digitalWrite(in2, LOW); + digitalWrite(in1, LOW); + digitalWrite(LED, LOW); + } + else { + digitalWrite(in2, LOW); + digitalWrite(in1, HIGH); + digitalWrite(LED, HIGH); + } + Serial.print("HUMI= "); + Serial.print(HUMI); + Serial.println("% "); + display.println("---------YANG--------"); + display.println(""); + display.print("Temperature: "); + display.print(t); + display.println("C"); + display.print("Humidity: ");//湿度 + display.print(h); + display.println("%"); + display.print("Soil Moisture: "); + display.println(HUMI); + if (HUMI > 80) { + display.println("Watter: OFF"); + display.println("Photosynthesis: OFF"); + } + else { + display.println("Watter: ON"); + display.println("Photosynthesis: ON"); + } + + display.println("---Have a nice DAY!--"); + //delay(1000); + display.display(); + + + } +} diff --git a/智能节水花盆/智能节水花盆.vcxproj b/智能节水花盆/智能节水花盆.vcxproj new file mode 100644 index 0000000..278db26 --- /dev/null +++ b/智能节水花盆/智能节水花盆.vcxproj @@ -0,0 +1,128 @@ + + + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + Debug + x86 + + + Release + x86 + + + Debug + x64 + + + Release + x64 + + + + {9c776b16-fbeb-40d4-a346-114384e760e3} + Linux + 智能节水花盆 + 智能节水花盆 + 15.0 + Linux + 1.0 + Generic + {D51BCBC9-82E9-4017-911E-C93873C4EA2B} + + + + + true + + + false + + + true + + + false + + + true + + + false + + + false + + + true + + + + + + c:\visualmicro\ignore + c:\visualmicro\pi-ignore + Arduino + + + + CppCode + true + + + + + + + + + + + + + + VisualMicroDebugger + + + $(ProjectDir)..\..\..\Arduino\libraries\GFX4d\src;$(ProjectDir)..\..\..\..\AppData\Local\arduino15\libraries\SD\src;$(ProjectDir)..\..\..\Arduino\libraries\Arduino_Uno_WiFi_Dev_Ed_Library\src;$(ProjectDir)..\..\..\Arduino\libraries\Adafruit_SSD1306;$(ProjectDir)..\..\..\Arduino\libraries\Adafruit_GFX_Library;$(ProjectDir)..\..\..\Arduino\libraries\Adafruit_BusIO;$(ProjectDir)..\..\..\..\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src;$(ProjectDir)..\..\..\..\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src;$(ProjectDir)..\..\..\Arduino\libraries\DHT_sensor_library;$(ProjectDir)..\..\..\..\..\..\\Users\\qw200\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino;$(ProjectDir)..\..\..\..\..\..\\Users\\qw200\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard;$(ProjectDir)..\..\..\..\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\lib\gcc\avr\7.3.0\include;$(ProjectDir)..\..\..\..\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\lib\gcc\avr\7.3.0\include-fixed;$(ProjectDir)..\..\..\..\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include;$(ProjectDir)..\..\..\Arduino\libraries\GFX4d\src;$(ProjectDir)..\..\..\Arduino\libraries\Adafruit_SSD1306;$(ProjectDir)..\..\..\Arduino\libraries\Adafruit_GFX_Library;$(ProjectDir)..\..\..\..\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src;$(ProjectDir)..\..\..\..\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src\utility;$(ProjectDir)..\..\..\..\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src;$(ProjectDir)..\..\..\Arduino\libraries\DHT_sensor_library;$(ProjectDir)..\..\..\Arduino\libraries\Arduino_Uno_WiFi_Dev_Ed_Library\src + $(ProjectDir)..\..\..\..\..\..\\Users\\qw200\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7\bin\avr-g++ + $(ProjectDir)..\..\..\..\..\..\\Users\\qw200\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7\bin\avr-g++ + false + + + + $(ProjectDir)..\..\..\Arduino\libraries\GFX4d\src;$(ProjectDir)..\..\..\..\AppData\Local\arduino15\libraries\SD\src;$(ProjectDir)..\..\..\Arduino\libraries\Arduino_Uno_WiFi_Dev_Ed_Library\src;$(ProjectDir)..\..\..\Arduino\libraries\Adafruit_SSD1306;$(ProjectDir)..\..\..\Arduino\libraries\Adafruit_GFX_Library;$(ProjectDir)..\..\..\Arduino\libraries\Adafruit_BusIO;$(ProjectDir)..\..\..\..\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src;$(ProjectDir)..\..\..\..\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src;$(ProjectDir)..\..\..\Arduino\libraries\DHT_sensor_library;$(ProjectDir)..\..\..\..\..\..\\Users\\qw200\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino;$(ProjectDir)..\..\..\..\..\..\\Users\\qw200\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard;$(ProjectDir)..\..\..\..\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\lib\gcc\avr\7.3.0\include;$(ProjectDir)..\..\..\..\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\lib\gcc\avr\7.3.0\include-fixed;$(ProjectDir)..\..\..\..\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include;$(ProjectDir)..\..\..\Arduino\libraries\GFX4d\src;$(ProjectDir)..\..\..\Arduino\libraries\Adafruit_SSD1306;$(ProjectDir)..\..\..\Arduino\libraries\Adafruit_GFX_Library;$(ProjectDir)..\..\..\..\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src;$(ProjectDir)..\..\..\..\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src\utility;$(ProjectDir)..\..\..\..\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src;$(ProjectDir)..\..\..\Arduino\libraries\DHT_sensor_library;$(ProjectDir)..\..\..\Arduino\libraries\Arduino_Uno_WiFi_Dev_Ed_Library\src;%(AdditionalIncludeDirectories) + $(ProjectDir)..\..\..\..\..\..\\Users\\qw200\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7\bin\avr-g++ + gnu++11 + gnu11 + + + $(ProjectDir)..\..\..\..\..\..\program files\microsoft visual studio\2022\community\common7\ide\extensions\0axxbbxm.vxj\Micro Platforms\default\vm-intelli-pre.h;$(ProjectDir)..\..\..\..\AppData\Local\Temp\VMBuilds\智能节水花盆\unowifi\Debug\.vmintelli\aaf59a5be9d08a6e007ec97fcb20ad5a\vm-intelli-gcc-defines.h;$(ProjectDir)..\..\..\..\..\..\program files\microsoft visual studio\2022\community\common7\ide\extensions\0axxbbxm.vxj\Micro Platforms\default\vm-intelli-post.h;$(ProjectDir)__vm\.智能节水花盆.vsarduino.h;%(ForcedIncludeFiles) + true + true + _VMICRO_INTELLISENSE;__AVR_atmega328p__;__AVR_ATmega328P__;__AVR_ATmega328p__;_VMDEBUG=1;F_CPU=16000000L;ARDUINO=108010;ARDUINO_AVR_UNO_WIFI_DEV_ED;ARDUINO_ARCH_AVR;ESP_CH_UART;ESP_CH_UART_BR=19200;%(PreprocessorDefinitions) + + + + + + + + + + \ No newline at end of file diff --git a/智能节水花盆/智能节水花盆.vcxproj.filters b/智能节水花盆/智能节水花盆.vcxproj.filters new file mode 100644 index 0000000..eb6d625 --- /dev/null +++ b/智能节水花盆/智能节水花盆.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + xml;json;txt;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Misc Files + + + + + + + + Header Files + + + \ No newline at end of file