FPGA-to-DHT11 Serial Communication

Serial communication firmware written in VHDL to read temperature and humidity data from a DHT11 sensor.

  • Taoyuan Vocational HS (NTUT-affiliated)
  • HS Year 2
  • 2023
  • Solo project
A DHT11 temperature and humidity sensor at the bottom left, an FPGA at the top right, and a seven-segment display at the top left showing the current temperature and humidity

Background

I got picked to represent my school in the digital electronics category of the national vocational skills competition, which is how my VHDL training started. After two months of drilling the basic syntax, I started reading the sensor’s datasheet and generating the signals it asked for, so I could talk to a DHT11 and pull temperature and humidity readings from it.

How It Works

  1. Use a Moore state machine to talk to the DHT11
    1. Set the data pin as an output and send the start signal
    2. Set the data pin as an input and receive the DHT11’s response
    3. Store the data in a signal so other modules can read it
    4. Wait about 1 second to give the DHT11 time to recover
    5. Repeat
  2. Convert the integer temperature and humidity signals into output for a 4-digit seven-segment display

Reflections

Learning this hardware description language was honestly pretty frustrating. VHDL doesn’t run sequentially like a normal programming language: some parts run concurrently and some run in sequence, so my whole way of thinking exploded. None of my habits from writing C++ or Python applied. I had to picture what the synthesized circuit would roughly look like as I wrote, just to work out the order things would happen in, and even when I had it all figured out in my head, the result could turn out completely different 😭

This serial communication project took me a whole week of debugging, but the rush when it finally worked was way better than reading a DHT11 with an Arduino 😆

After pulling this off, I got a lot more comfortable with state machines, understood serial communication much more deeply, and leveled up my debugging a ton. I didn’t have a logic analyzer, so I debugged everything with an oscilloscope, and now I can practically use one in my sleep!