Skip to content

Commit 433cfed

Browse files
authored
update the DHTxx (ESP32) to nanoFramework.Hardware.Esp32.Rmt version 2.0.1 (#722)
1 parent 50c79f4 commit 433cfed

File tree

5 files changed

+32
-16
lines changed

5 files changed

+32
-16
lines changed

devices/Dhtxx.Esp32/DhtBase.cs

+21-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using nanoFramework.Hardware.Esp32.Rmt;
54
using System;
65
using System.Device;
76
using System.Device.Gpio;
87
using System.Device.I2c;
98
using System.Device.Model;
10-
using System.Diagnostics;
119
using System.Threading;
10+
11+
using nanoFramework.Hardware.Esp32.Rmt;
12+
1213
using UnitsNet;
1314

1415
namespace Iot.Device.DHTxx.Esp32
@@ -104,17 +105,26 @@ public DhtBase(int pinEcho, int pinTrigger, PinNumberingScheme pinNumberingSchem
104105
_shouldDispose = shouldDispose || gpioController is null;
105106
_controller = gpioController ?? new GpioController(pinNumberingScheme);
106107
_pin = pinTrigger;
107-
_rxChannel = new ReceiverChannel(pinEcho);
108-
// 1us clock ( 80Mhz / 80 ) = 1Mhz
109-
_rxChannel.ClockDivider = 80;
110-
// no filter
111-
_rxChannel.EnableFilter(false, 5);
112-
// max time 1us clock
113-
_rxChannel.SetIdleThresold(ushort.MaxValue);
114-
// timeout after 1 second
115-
_rxChannel.ReceiveTimeout = TimeSpan.FromSeconds(1);
116108

109+
var rxChannelSettings = new ReceiverChannelSettings(pinNumber: pinEcho)
110+
{
111+
// 1us clock ( 80Mhz / 80 ) = 1Mhz
112+
ClockDivider = 80,
113+
114+
// no filter
115+
EnableFilter = false,
116+
FilterThreshold = 5,
117+
118+
// max time 1us clock
119+
IdleThreshold = ushort.MaxValue,
120+
121+
// timeout after 1 second
122+
ReceiveTimeout = TimeSpan.FromSeconds(1)
123+
};
124+
125+
_rxChannel = new ReceiverChannel(rxChannelSettings);
117126
_controller.OpenPin(_pin, PinMode.Output);
127+
118128
// delay 1s to make sure DHT stable
119129
Thread.Sleep(1000);
120130
}

devices/Dhtxx.Esp32/Dhtxx.Esp32.nfproj

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
<HintPath>packages\nanoFramework.CoreLibrary.1.14.2\lib\mscorlib.dll</HintPath>
4444
<Private>True</Private>
4545
</Reference>
46+
<Reference Include="nanoFramework.Hardware.Esp32.Rmt">
47+
<HintPath>packages\nanoFramework.Hardware.Esp32.Rmt.2.0.1\lib\nanoFramework.Hardware.Esp32.Rmt.dll</HintPath>
48+
</Reference>
4649
<Reference Include="nanoFramework.Hardware.Esp32.Rmt, Version=1.3.6.3188, Culture=neutral, PublicKeyToken=c07d481e9758c731">
4750
<HintPath>packages\nanoFramework.Hardware.Esp32.Rmt.1.3.6\lib\nanoFramework.Hardware.Esp32.Rmt.dll</HintPath>
4851
<Private>True</Private>
@@ -87,6 +90,9 @@
8790
<ItemGroup>
8891
<None Include="packages.config" />
8992
</ItemGroup>
93+
<ItemGroup>
94+
<Content Include="packages.lock.json" />
95+
</ItemGroup>
9096
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
9197
<ProjectExtensions>
9298
<ProjectCapabilities>

devices/Dhtxx.Esp32/Dhtxx.Esp32.nuspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<tags>nanoFramework C# csharp netmf netnf Iot.Device.Dhtxx</tags>
2121
<dependencies>
2222
<dependency id="nanoFramework.CoreLibrary" version="1.14.2" />
23-
<dependency id="nanoFramework.Hardware.Esp32.Rmt" version="1.3.6" />
23+
<dependency id="nanoFramework.Hardware.Esp32.Rmt" version="2.0.1" />
2424
<dependency id="nanoFramework.Runtime.Events" version="1.11.6" />
2525
<dependency id="nanoFramework.Runtime.Native" version="1.6.6" />
2626
<dependency id="nanoFramework.System.Device.Gpio" version="1.1.28" />

devices/Dhtxx.Esp32/packages.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="nanoFramework.CoreLibrary" version="1.14.2" targetFramework="netnano1.0" />
4-
<package id="nanoFramework.Hardware.Esp32.Rmt" version="1.3.6" targetFramework="netnano1.0" />
4+
<package id="nanoFramework.Hardware.Esp32.Rmt" version="2.0.1" targetFramework="netnano1.0" />
55
<package id="nanoFramework.Runtime.Events" version="1.11.6" targetFramework="netnano1.0" />
66
<package id="nanoFramework.Runtime.Native" version="1.6.6" targetFramework="netnano1.0" />
77
<package id="nanoFramework.System.Device.Gpio" version="1.1.28" targetFramework="netnano1.0" />

devices/Dhtxx.Esp32/packages.lock.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
},
1111
"nanoFramework.Hardware.Esp32.Rmt": {
1212
"type": "Direct",
13-
"requested": "[1.3.6, 1.3.6]",
14-
"resolved": "1.3.6",
15-
"contentHash": "vn+KOC24pOs1BvuYcbWy4NgV7tR6Wjx5v8kFZBZUrwqpffb3C1N+jWHyO6EcGgKxbIFxDFDZKULSHqnQr/H0Xg=="
13+
"requested": "[2.0.1, 2.0.1]",
14+
"resolved": "2.0.1",
15+
"contentHash": "h3xaxgk1vIeWxFYxRa+6bvYmg5TlNuCS9GwYzbVba0T0mq2nYWUNqTUoWtLEGReZY17vmULzu5AXQzGz+q7tZQ=="
1616
},
1717
"nanoFramework.Runtime.Events": {
1818
"type": "Direct",

0 commit comments

Comments
 (0)