-
Notifications
You must be signed in to change notification settings - Fork 0
Add Ds1820b20 sensor #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/nf-telemetry-clients/Peripherals/Ds18b20.Sensor/Ds18b20.Sensor.nfproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <PropertyGroup Label="Globals"> | ||
| <NanoFrameworkProjectSystemPath>$(MSBuildExtensionsPath)\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath> | ||
| </PropertyGroup> | ||
| <Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" /> | ||
| <PropertyGroup> | ||
| <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
| <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
| <ProjectTypeGuids>{11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
| <ProjectGuid>de298f11-0961-430e-8fa5-0f2bd5f4997d</ProjectGuid> | ||
| <OutputType>Library</OutputType> | ||
| <AppDesignerFolder>Properties</AppDesignerFolder> | ||
| <FileAlignment>512</FileAlignment> | ||
| <RootNamespace>TelemetryStash.Ds18b20Sensor</RootNamespace> | ||
| <AssemblyName>Ts.Ds18b20.Sensor</AssemblyName> | ||
| <TargetFrameworkVersion>v1.0</TargetFrameworkVersion> | ||
| <AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects> | ||
| <NuGetAudit>true</NuGetAudit> | ||
| <NuGetAuditMode>direct</NuGetAuditMode> | ||
| <NuGetAuditLevel>low</NuGetAuditLevel> | ||
| </PropertyGroup> | ||
| <Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" /> | ||
| <ItemGroup> | ||
| <Compile Include="Ds18b20Sensor.cs" /> | ||
| <Compile Include="Properties\AssemblyInfo.cs" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <Reference Include="Iot.Device.Ds18b20"> | ||
| <HintPath>..\..\packages\nanoFramework.Iot.Device.Ds18b20.1.0.726\lib\Iot.Device.Ds18b20.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="mscorlib"> | ||
| <HintPath>..\..\packages\nanoFramework.CoreLibrary.1.16.11\lib\mscorlib.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="nanoFramework.Device.OneWire"> | ||
| <HintPath>..\..\packages\nanoFramework.Device.OneWire.1.4.32\lib\nanoFramework.Device.OneWire.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="nanoFramework.Hardware.Esp32"> | ||
| <HintPath>..\..\packages\nanoFramework.Hardware.Esp32.1.6.29\lib\nanoFramework.Hardware.Esp32.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="nanoFramework.Runtime.Events"> | ||
| <HintPath>..\..\packages\nanoFramework.Runtime.Events.1.11.29\lib\nanoFramework.Runtime.Events.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="System.Device.Model"> | ||
| <HintPath>..\..\packages\nanoFramework.System.Device.Model.1.2.771\lib\System.Device.Model.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="UnitsNet.Temperature"> | ||
| <HintPath>..\..\packages\UnitsNet.nanoFramework.Temperature.5.69.0\lib\UnitsNet.Temperature.dll</HintPath> | ||
| </Reference> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <None Include="packages.config" /> | ||
| </ItemGroup> | ||
| <Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" /> | ||
| <ProjectExtensions> | ||
| <ProjectCapabilities> | ||
| <ProjectConfigurationsDeclaredAsItems /> | ||
| </ProjectCapabilities> | ||
| </ProjectExtensions> | ||
| </Project> |
55 changes: 55 additions & 0 deletions
55
src/nf-telemetry-clients/Peripherals/Ds18b20.Sensor/Ds18b20Sensor.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| using Iot.Device.Ds18b20; | ||
| using nanoFramework.Device.OneWire; | ||
| using nanoFramework.Hardware.Esp32; | ||
| using System; | ||
| using System.Threading; | ||
|
|
||
| namespace TelemetryStash.Ds18b20Sensor | ||
| { | ||
| public class Ds18b20Sensor | ||
| { | ||
| public Ds18b20Sensor() | ||
| { | ||
| Configuration.SetPinFunction(18, DeviceFunction.COM2_RX); | ||
| Configuration.SetPinFunction(17, DeviceFunction.COM2_TX); | ||
| } | ||
mikmog marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public void RunDemo() | ||
| { | ||
| var oneWire = new OneWireHost(); | ||
|
|
||
| var ds18b20 = new Ds18b20(oneWire, null, false, TemperatureResolution.VeryHigh) | ||
| { | ||
| IsAlarmSearchCommandEnabled = false | ||
| }; | ||
|
|
||
| if (ds18b20.Initialize()) | ||
| { | ||
| Console.WriteLine($"Is sensor parasite powered?:{ds18b20.IsParasitePowered}"); | ||
| string devAddrStr = ""; | ||
| foreach (var addrByte in ds18b20.Address) | ||
| { | ||
| devAddrStr += addrByte.ToString("X2"); | ||
| } | ||
|
|
||
| Console.WriteLine($"Sensor address:{devAddrStr}"); | ||
|
|
||
| while (true) | ||
| { | ||
| if (!ds18b20.TryReadTemperature(out var currentTemperature)) | ||
| { | ||
| Console.WriteLine("Can't read!"); | ||
| } | ||
| else | ||
| { | ||
| Console.WriteLine($"Temperature: {currentTemperature.DegreesCelsius.ToString("F")}\u00B0C"); | ||
| } | ||
|
|
||
| Thread.Sleep(5000); | ||
| } | ||
| } | ||
|
|
||
| oneWire.Dispose(); | ||
| } | ||
mikmog marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
39 changes: 39 additions & 0 deletions
39
src/nf-telemetry-clients/Peripherals/Ds18b20.Sensor/Properties/AssemblyInfo.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| using System.Reflection; | ||
| using System.Runtime.CompilerServices; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| // General Information about an assembly is controlled through the following | ||
| // set of attributes. Change these attribute values to modify the information | ||
| // associated with an assembly. | ||
| [assembly: AssemblyTitle("CSharp.TestApplication")] | ||
| [assembly: AssemblyDescription("")] | ||
| [assembly: AssemblyConfiguration("")] | ||
| [assembly: AssemblyCompany("")] | ||
| [assembly: AssemblyProduct("CSharp.TestApplication")] | ||
| [assembly: AssemblyCopyright("Copyright © 2025")] | ||
| [assembly: AssemblyTrademark("")] | ||
| [assembly: AssemblyCulture("")] | ||
|
|
||
| // Setting ComVisible to false makes the types in this assembly not visible | ||
| // to COM components. If you need to access a type in this assembly from | ||
| // COM, set the ComVisible attribute to true on that type. | ||
| [assembly: ComVisible(false)] | ||
|
|
||
| // Version information for an assembly consists of the following four values: | ||
| // | ||
| // Major Version | ||
| // Minor Version | ||
| // Build Number | ||
| // Revision | ||
| // | ||
| // You can specify all the values or you can default the Build and Revision Numbers | ||
| // by using the '*' as shown below: | ||
| // [assembly: AssemblyVersion("1.0.*")] | ||
| [assembly: AssemblyVersion("1.0.0.0")] | ||
| [assembly: AssemblyFileVersion("1.0.0.0")] | ||
|
|
||
| ///////////////////////////////////////////////////////////////// | ||
| // This attribute is mandatory when building Interop libraries // | ||
| // update this whenever the native assembly signature changes // | ||
| [assembly: AssemblyNativeVersion("1.0.0.0")] | ||
| ///////////////////////////////////////////////////////////////// |
10 changes: 10 additions & 0 deletions
10
src/nf-telemetry-clients/Peripherals/Ds18b20.Sensor/packages.config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <packages> | ||
| <package id="nanoFramework.CoreLibrary" version="1.16.11" targetFramework="netnano1.0" /> | ||
| <package id="nanoFramework.Device.OneWire" version="1.4.32" targetFramework="netnano1.0" /> | ||
| <package id="nanoFramework.Hardware.Esp32" version="1.6.29" targetFramework="netnano1.0" /> | ||
| <package id="nanoFramework.Iot.Device.Ds18b20" version="1.0.726" targetFramework="netnano1.0" /> | ||
| <package id="nanoFramework.Runtime.Events" version="1.11.29" targetFramework="netnano1.0" /> | ||
| <package id="nanoFramework.System.Device.Model" version="1.2.771" targetFramework="netnano1.0" /> | ||
| <package id="UnitsNet.nanoFramework.Temperature" version="5.69.0" targetFramework="netnano1.0" /> | ||
| </packages> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.