├── Third Party Notices.txt ├── PlantSensor ├── Assets │ ├── StoreLogo.png │ ├── LockScreenLogo.scale-200.png │ ├── SplashScreen.scale-200.png │ ├── Square44x44Logo.scale-200.png │ ├── Wide310x150Logo.scale-200.png │ ├── Square150x150Logo.scale-200.png │ └── Square44x44Logo.targetsize-24_altform-unplated.png ├── App.xaml ├── project.json ├── Utility │ └── FileNames.cs ├── PlantSensor.nuget.targets ├── Properties │ ├── AssemblyInfo.cs │ └── Default.rd.xml ├── Package.appxmanifest ├── Sensors │ ├── MCP3008.cs │ └── BMP280.cs ├── View │ ├── SettingsPage.xaml │ ├── SettingsPage.xaml.cs │ ├── TwitterPage.xaml.cs │ ├── TwitterPage.xaml │ ├── MainPage.xaml.cs │ ├── MainPage.xaml │ ├── HistoryPage.xaml │ └── HistoryPage.xaml.cs ├── SensorDataProvider.cs ├── PlantSensor.csproj └── App.xaml.cs ├── README.md ├── LICENSE.txt ├── PlantSensor.sln └── .gitignore /Third Party Notices.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ms-iot/PlantSensor/HEAD/Third Party Notices.txt -------------------------------------------------------------------------------- /PlantSensor/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ms-iot/PlantSensor/HEAD/PlantSensor/Assets/StoreLogo.png -------------------------------------------------------------------------------- /PlantSensor/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ms-iot/PlantSensor/HEAD/PlantSensor/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /PlantSensor/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ms-iot/PlantSensor/HEAD/PlantSensor/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /PlantSensor/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ms-iot/PlantSensor/HEAD/PlantSensor/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /PlantSensor/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ms-iot/PlantSensor/HEAD/PlantSensor/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /PlantSensor/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ms-iot/PlantSensor/HEAD/PlantSensor/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /PlantSensor/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ms-iot/PlantSensor/HEAD/PlantSensor/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /PlantSensor/App.xaml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /PlantSensor/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0", 4 | "TweetinviAPI": "1.0.0", 5 | "WinRTXamlToolkit.Controls.DataVisualization": "2.0.0" 6 | }, 7 | "frameworks": { 8 | "uap10.0": {} 9 | }, 10 | "runtimes": { 11 | "win10-arm": {}, 12 | "win10-arm-aot": {}, 13 | "win10-x86": {}, 14 | "win10-x86-aot": {}, 15 | "win10-x64": {}, 16 | "win10-x64-aot": {} 17 | } 18 | } -------------------------------------------------------------------------------- /PlantSensor/Utility/FileNames.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | namespace PlantSensor 3 | { 4 | class FileNames 5 | { 6 | public const string BrightnessfileName = "BrightnessHistoryTextFile.txt"; 7 | public const string TemperaturefileName = "TemperatureHistoryTextFile.txt"; 8 | public const string SoilMoisturefileName = "SoilMoistureHistoryTextFile.txt"; 9 | public const string SettingsfileName = "settings.txt"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /PlantSensor/PlantSensor.nuget.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(UserProfile)\.nuget\packages\ 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Windows IoT Plant Sensor 2 | digiPlant is a Universal Windows Platform app that helps users monitor their plant. The app collects and displays tempoerature, brightness, and soil moisture data from various sensors. It runs on a Raspberry Pi and Windows 10 IoT Core. The Twitter page is currently a work in progress. 3 | 4 | ## Cloning the project 5 | 6 | - Use Command Prompt to navigate to the folder where you want the project: 7 | ```cd ``` 8 | - Run the git clone command: 9 | ```git clone https://github.com/ms-iot/PlantSensor.git``` 10 | 11 | The step-by-step instruction for building this project can be found on https://www.hackster.io/MasayukiN/plant-app-v-1-0-1167ed?ref=user&ref_id=100482&offset=0 12 | 13 | 14 | === 15 | 16 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. -------------------------------------------------------------------------------- /PlantSensor/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PlantSensor")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("PlantSensor")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. 2 | 3 | The MIT License (MIT) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /PlantSensor/Properties/Default.rd.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /PlantSensor/Package.appxmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | PlantSensor 7 | t-managa 8 | Assets\StoreLogo.png 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /PlantSensor.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlantSensor", "PlantSensor\PlantSensor.csproj", "{75E178AC-7A35-48A1-B019-8404A10D4D19}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|ARM = Debug|ARM 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | Release|ARM = Release|ARM 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Debug|ARM.ActiveCfg = Debug|ARM 19 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Debug|ARM.Build.0 = Debug|ARM 20 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Debug|ARM.Deploy.0 = Debug|ARM 21 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Debug|x64.ActiveCfg = Debug|x64 22 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Debug|x64.Build.0 = Debug|x64 23 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Debug|x64.Deploy.0 = Debug|x64 24 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Debug|x86.ActiveCfg = Debug|x86 25 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Debug|x86.Build.0 = Debug|x86 26 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Debug|x86.Deploy.0 = Debug|x86 27 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Release|ARM.ActiveCfg = Release|ARM 28 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Release|ARM.Build.0 = Release|ARM 29 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Release|ARM.Deploy.0 = Release|ARM 30 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Release|x64.ActiveCfg = Release|x64 31 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Release|x64.Build.0 = Release|x64 32 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Release|x64.Deploy.0 = Release|x64 33 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Release|x86.ActiveCfg = Release|x86 34 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Release|x86.Build.0 = Release|x86 35 | {75E178AC-7A35-48A1-B019-8404A10D4D19}.Release|x86.Deploy.0 = Release|x86 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | EndGlobal 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Gg]enerated Files/ 19 | x64/ 20 | x86/ 21 | build/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | 26 | # Visual Studo 2015 cache/options directory 27 | .vs/ 28 | 29 | # MSTest test Results 30 | [Tt]est[Rr]esult*/ 31 | [Bb]uild[Ll]og.* 32 | 33 | # NUNIT 34 | *.VisualState.xml 35 | TestResult.xml 36 | 37 | # Build Results of an ATL Project 38 | [Dd]ebugPS/ 39 | [Rr]eleasePS/ 40 | dlldata.c 41 | 42 | *_i.c 43 | *_p.c 44 | *_i.h 45 | *.ilk 46 | *.meta 47 | *.obj 48 | *.pch 49 | *.pdb 50 | *.pgc 51 | *.pgd 52 | *.rsp 53 | *.sbr 54 | *.tlb 55 | *.tli 56 | *.tlh 57 | *.tmp 58 | *.tmp_proj 59 | *.log 60 | *.vspscc 61 | *.vssscc 62 | .builds 63 | *.pidb 64 | *.svclog 65 | *.scc 66 | 67 | # Chutzpah Test files 68 | _Chutzpah* 69 | 70 | # Visual C++ cache files 71 | ipch/ 72 | *.aps 73 | *.ncb 74 | *.opensdf 75 | *.sdf 76 | *.cachefile 77 | *.VC.db 78 | *.VC.VC.opendb 79 | 80 | # Visual Studio profiler 81 | *.psess 82 | *.vsp 83 | *.vspx 84 | 85 | # TFS 2012 Local Workspace 86 | $tf/ 87 | 88 | # Guidance Automation Toolkit 89 | *.gpState 90 | 91 | # ReSharper is a .NET coding add-in 92 | _ReSharper*/ 93 | *.[Rr]e[Ss]harper 94 | *.DotSettings.user 95 | 96 | # JustCode is a .NET coding addin-in 97 | .JustCode 98 | 99 | # TeamCity is a build add-in 100 | _TeamCity* 101 | 102 | # DotCover is a Code Coverage Tool 103 | *.dotCover 104 | 105 | # NCrunch 106 | _NCrunch_* 107 | .*crunch*.local.xml 108 | 109 | # MightyMoose 110 | *.mm.* 111 | AutoTest.Net/ 112 | 113 | # Web workbench (sass) 114 | .sass-cache/ 115 | 116 | # Installshield output folder 117 | [Ee]xpress/ 118 | 119 | # DocProject is a documentation generator add-in 120 | DocProject/buildhelp/ 121 | DocProject/Help/*.HxT 122 | DocProject/Help/*.HxC 123 | DocProject/Help/*.hhc 124 | DocProject/Help/*.hhk 125 | DocProject/Help/*.hhp 126 | DocProject/Help/Html2 127 | DocProject/Help/html 128 | 129 | # Click-Once directory 130 | publish/ 131 | 132 | # Publish Web Output 133 | *.[Pp]ublish.xml 134 | *.azurePubxml 135 | # TODO: Comment the next line if you want to checkin your web deploy settings 136 | # but database connection strings (with potential passwords) will be unencrypted 137 | *.pubxml 138 | *.publishproj 139 | 140 | # NuGet Packages 141 | *.nupkg 142 | # The packages folder can be ignored because of Package Restore 143 | **/packages/* 144 | # except build/, which is used as an MSBuild target. 145 | !**/packages/build/ 146 | # Uncomment if necessary however generally it will be regenerated when needed 147 | #!**/packages/repositories.config 148 | 149 | # Windows Azure Build Output 150 | csx/ 151 | *.build.csdef 152 | 153 | # Windows Store app package directory 154 | AppPackages/ 155 | 156 | # Others 157 | *.[Cc]ache 158 | ClientBin/ 159 | [Ss]tyle[Cc]op.* 160 | ~$* 161 | *~ 162 | *.dbmdl 163 | *.dbproj.schemaview 164 | *.pfx 165 | *.publishsettings 166 | node_modules/ 167 | bower_components/ 168 | 169 | # RIA/Silverlight projects 170 | Generated_Code/ 171 | 172 | # Backup & report files from converting an old project file 173 | # to a newer Visual Studio version. Backup files are not needed, 174 | # because we have git ;-) 175 | _UpgradeReport_Files/ 176 | Backup*/ 177 | UpgradeLog*.XML 178 | UpgradeLog*.htm 179 | 180 | # SQL Server files 181 | *.mdf 182 | *.ldf 183 | 184 | # Business Intelligence projects 185 | *.rdl.data 186 | *.bim.layout 187 | *.bim_*.settings 188 | 189 | # Microsoft Fakes 190 | FakesAssemblies/ 191 | 192 | # Node.js Tools for Visual Studio 193 | .ntvs_analysis.dat 194 | 195 | # Visual Studio 6 build log 196 | *.plg 197 | 198 | # Visual Studio 6 workspace options file 199 | *.opt 200 | 201 | # Custom ignores 202 | gallery.xml 203 | project.lock.json 204 | -------------------------------------------------------------------------------- /PlantSensor/Sensors/MCP3008.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | using Windows.Devices.Enumeration; 3 | using Windows.Devices.Spi; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Diagnostics; 10 | 11 | namespace PlantSensor 12 | { 13 | public class MCP3008 14 | { 15 | // Constants for the SPI controller chip interface 16 | public SpiDevice mcp3008; 17 | const int SPI_CHIP_SELECT_LINE = 0; // SPI0 CS0 pin 24 18 | 19 | // ADC chip operation constants 20 | const byte MCP3008_SingleEnded = 0x08; 21 | const byte MCP3008_Differential = 0x00; 22 | 23 | // These are used when we calculate the voltage from the ADC units 24 | float ReferenceVoltage; 25 | public const uint Min = 0; 26 | public const uint Max = 1023; 27 | 28 | 29 | public MCP3008(float referenceVolgate) 30 | { 31 | Debug.WriteLine("MCP3008::New MCP3008"); 32 | 33 | // Store the reference voltage value for later use in the voltage calculation. 34 | ReferenceVoltage = referenceVolgate; 35 | } 36 | 37 | /// 38 | /// This method is used to configure the Pi2 to communicate over the SPI bus to the MCP3008 ADC chip. 39 | /// 40 | public async Task Initialize() 41 | { 42 | Debug.WriteLine("MCP3008::Initialize"); 43 | try 44 | { 45 | // Setup the SPI bus configuration 46 | var settings = new SpiConnectionSettings(SPI_CHIP_SELECT_LINE); 47 | // 3.6MHz is the rated speed of the MCP3008 at 5v 48 | settings.ClockFrequency = 3600000; 49 | settings.Mode = SpiMode.Mode0; 50 | 51 | // Ask Windows for the list of SpiDevices 52 | 53 | // Get a selector string that will return all SPI controllers on the system 54 | string aqs = SpiDevice.GetDeviceSelector(); 55 | 56 | // Find the SPI bus controller devices with our selector string 57 | var dis = await DeviceInformation.FindAllAsync(aqs); 58 | 59 | // Create an SpiDevice with our bus controller and SPI settings 60 | mcp3008 = await SpiDevice.FromIdAsync(dis[0].Id, settings); 61 | 62 | if (mcp3008 == null) 63 | { 64 | Debug.WriteLine( 65 | "SPI Controller {0} is currently in use by another application. Please ensure that no other applications are using SPI.", 66 | dis[0].Id); 67 | return; 68 | } 69 | 70 | } 71 | catch (Exception e) 72 | { 73 | Debug.WriteLine("Exception: " + e.Message + "\n" + e.StackTrace); 74 | throw; 75 | } 76 | } 77 | 78 | /// 79 | /// This method does the actual work of communicating over the SPI bus with the chip. 80 | /// To line everything up for ease of reading back (on byte boundary) we 81 | /// will pad the command start bit with 7 leading "0" bits 82 | /// 83 | /// Write 0000 000S GDDD xxxx xxxx xxxx 84 | /// Read ???? ???? ???? ?N98 7654 3210 85 | /// S = start bit 86 | /// G = Single / Differential 87 | /// D = Chanel data 88 | /// ? = undefined, ignore 89 | /// N = 0 "Null bit" 90 | /// 9-0 = 10 data bits 91 | /// 92 | public int ReadADC(byte whichChannel) 93 | { 94 | byte command = whichChannel; 95 | command |= MCP3008_SingleEnded; 96 | command <<= 4; 97 | 98 | byte[] commandBuf = new byte[] { 0x01, command, 0x00 }; 99 | 100 | byte[] readBuf = new byte[] { 0x00, 0x00, 0x00 }; 101 | 102 | mcp3008.TransferFullDuplex(commandBuf, readBuf); 103 | 104 | int sample = readBuf[2] + ((readBuf[1] & 0x03) << 8); 105 | int s2 = sample & 0x3FF; 106 | Debug.Assert(sample == s2); 107 | 108 | return sample; 109 | } 110 | 111 | /// 112 | /// Returns the ADC value (uint) as a float voltage based on the configured reference voltage 113 | /// 114 | /// the ADC value to convert 115 | /// The computed voltage based on the reference voltage 116 | public float ADCToVoltage(int adc) 117 | { 118 | return (float)adc * ReferenceVoltage / (float)Max; 119 | } 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /PlantSensor/View/SettingsPage.xaml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 |