Dependancies
logic-analyzer-signal.ino
#include "DHT.h"
#define DHTPIN 7
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
Serial.println("Start DHT11");
dht.begin();
}
void loop() {
float t = dht.readTemperature();
if (isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
Serial.println(t);
}
BOARD?=arduino:avr:uno
PORT?=/dev/cu.usbmodem14*
.PHONY: default lint all flash clean
default: lint all flash clean
lint:
cpplint --extensions=ino --filter=-legal/copyright *.ino
all:
arduino-cli compile --fqbn $(BOARD) ./
flash:
arduino-cli upload -p $(PORT) --fqbn $(BOARD)
clean:
rm -rf build
View the decoded non-standard signal from the graph produced by Saleae to read temperature from a DHT11
sensor.
Capture the signal in Saleae:
Manually decoding the signal gives us:
0010 0110 0000 0000 0001 1100 0000 0000 0100 0010
RH MSB RH LSB T MSB T LSB Checksum
Take the temperature MSB which is 0001 1100
in binary and 28
in decimal, which is the same as what is shown i the serial monitor.