appendix-b

Appendix B. Building a custom IoT sensor

 

Sometimes the exact sensor you need isn’t available off the shelf or in the right configuration. For example, you might need to combine temperature, humidity, and soil moisture in a single affordable unit. I needed to correlate soil moisture with ambient humidity to understand how indoor plants affect the home climate. No commercial sensor offered this combination affordably, so I built one.

B.1 Hardware

You’ll need:

  • ESP32 development board (for example, a WROOM 32E board) (~$6)
  • DHT22 temperature/humidity sensor (~$9)
  • Capacitive soil moisture sensor (~$2)
  • Miscellaneous: 10kΩ pull-up resistor, wires, breadboard (~$5)

The circuit (figure B.1) connects the DHT22 to GPIO 23 with a 10kΩ pull-up resistor, the moisture sensor to GPIO 33 (ADC1 channel), and both sensors to 3.3V and ground.

Figure B.1 Sensor circuit design.
appendixb f01 biegel

B.2 Cloud configuration

Before writing device code, configure AWS IoT Core so your device can securely publish readings.

B.2.1 Step 1: Create a thing

  1. Navigate to AWS IoT Core → Manage → All devices → Things
  2. Click Create Thing. Choose to create a single thing, and you see the screen shown in figure B.2, where you must give your thing a name.
Figure B.2 Thing properties within AWS. Give your thing a name here.
appendixb f02 biegel

B.2.2 Step 2: Generate certificates

Select the option to auto-generate a new certificate, as shown in figure B.3.

Figure B.3 Create device certificates.
appendixb f03 biegel

B.2.3 Step 3: Attach an access policy

B.2.4 Step 4: Download certificates

B.3 Device software

B.4 Verifying the connection