This document is relevant to: Duet 2, Duet 3
Firmware versions: RepRapFirmware 1.20 and later
DHT sensors are low-cost digital temperature and humidity sensors. They use a capacitive humidity sensor and a thermistor to measure the surrounding air, and transmit a digital signal on the data pin to the host, so no analog input pins are needed.
RepRapFirmware from v1.20 supports DHT11, DHT21 and DHT22 sensors.
Which sensor you use will depend on your application. DHT sensors can be bought as a bare sensor, on a PCB, or as a wired version in a large plastic case.
Recommended. More precise, more accurate and works in a bigger range of temperature/humidity. Larger and more expensive than DHT11, and only updates once every 2 seconds.
NOTE: Cloned DHT22 sensors. One customers reported problems getting a DHT22 sensor working with RRF, even though the sensor worked with an Arduino. The issue was investigated and it was discovered that the sensor did not conform to the specification of the DHT22 sensor as on the datasheet provided by Adafruit.
The customer's sensor is pictured above (top in picture) and a sensor that works (below in picture). The working sensor carries the identification "AOSONG AM2302" whereas the customer's sensor carries no markings at all. The vast majority of images of DHT22 sensors on Amazon and eBay do carry the part identification, but a few do not and look like the sensor received from the customer. Therefore, if you need a DHT22 sensor for your Duet-based system, please make sure to buy a genuine one bearing the correct part identification. See this forum thread for more information.
Usually packaged in a large case, with three wires. Similar specification to DHT22, but less accurate.
Usually cheapest, with limited range for temperature and humidity, but small and updates every second. Not supported in RRF 3.4. or later
Connect the sensor to +3.3V and GND. Do not use 5V unless you use a bidirectional level shifter between the Duet and the DHT22.
The one-wire bus used by the DHT sensor for data is sensitive to noise, so if you use unshielded cable it is very likely to pick up interference from any stepper motor cables that it runs close to. We recommend using shielded cable (stereo microphone cable should work), using the shield for the ground connection.
Bare DHT sensors usually come with a pullup resistor of between 4k7 and 10k ohms. DHT sensors on a PCB, or encased and pre-wired, usually have the pullup resistor already fitted on the PCB. The pullup resistor goes between the signal line and 3.3V.
Cable capacitance should not exceed about 2000pF. Using a lower value resistor will allow longer cable runs, eg a 2k2 ohm, but be more susceptible to noise. Shielded cables normally specify the capacitance/meter, so you should be able to work out the highest value pullup resistor you can use for a specific length and type of cable. If a higher pullup resistor is used then the max cable length is reduced. In testing, dc42 uses a 10K pullup resistor and 400mm of cable.
Connect the DHT I/O line to either one of the SPI CS lines on the Temperature Daughterboard connector, or one of the IOx.OUT pins. Both of these connectors also provides +3.3V and ground.
Connect the DHT I/O line to both IOx.IN and the IOx.OUT pin of an IO connector. The IO connector also provides +3.3V and ground. Using the Temperature Daughterboard connector is NOT supported. RepRapFirmware 3.3beta1 or later is required.
Connect the DHT I/O line to one of the SPI CS lines on the temperature daughterboard connector, which also provides +3.3V and ground. For systems on RRF 3 without a DueX, some of the expansion connector pins could be used instead, for example the E2 to E6 endstop pins (E0 and E1 on the Duet cannot be used).
In RRF 3, M308 is used to define the DHT sensor. Use the following parameters:
All DHT variants have a primary output for temperature and a secondary output that delivers the humidity values. "dhthumidity" will be attached to an existing DHT sensor's secondary output by using its full sensor number (including the leading S) and the output's index separated by a dot.
Example:
;DHT Sensor on Temperature Daughterboard SPI CS1 pin
M308 S10 P"0.spi.cs1" Y"dht22" A"Filament Temp" ; define DHT22 temperature sensor
M308 S11 P"S10.1" Y"dhthumidity" A"Filament Hum[%]" ; Attach DHT22 humidity sensor to secondary output of temperature sensor
On Duet 3 Mini 5+, as you connect the DHT data line to both IOx.out and IOx. in, you need to specify both pins in the M308 command.
;DHT Sensor on IO4 on Duet 3 Mini 5+
M308 S10 P"io4.out+io4.in" Y"dht22" A"Chbr Temp[C]"
M308 S11 P"S10.1" Y"dhthumidity" A"Chbr Hum[%]"
In RRF 2 and earlier, M305 is used to define the DHT sensor. In RRF 2, every temperature sensor belongs to a heater. For sensors with no controllable heater (e.g. DHT sensors) you have to create a "virtual heater" in order to be able to use the sensor. Use the following parameters:
The X parameter tells the firmware which temperature sensor channel to use. For DHT sensors, set as follows:
Example:
;DHT Sensor on Temperature Daughterboard SPI CS1 pin
M305 P103 X400 T22 S"DHT Temperature"
M305 P104 X450 T22 S"DHT Humidity [%]"
View the DHT sensor data in DWC, in the main Printer Status section, in the 'Extra' view of the 'Tools' section (see Duet Web Control manual).