Skip to main content
Intro to IoT Class Docs
Tech TLH Discord Code and Coffee TLH GitHub Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Testing

Time To Plug It In

It’s time to plug it in and see what happens.

  1. Connect your ESP32 board with a USB-C data cable.
  2. In the Arduino IDE toolbar, select the board and port from the dropdown.
    Selecting Board and Port
    Selecting Board and Port
  3. If it’s not already visible, open the Serial Monitor by clicking the magnifying glass icon in the top right.
    The Serial Monitor Icon
    The Serial Monitor Icon
  4. At this point, you should hopefully see data flowing back from the board.
    A Little Warm in the Workshop
    A Little Warm in the Workshop
  5. To visualize the data, open the Serial Plotter by clicking the spiky graph icon in the top right.
    The Serial Plotter Icon
    The Serial Plotter Icon
  6. You should see a chart window with data coming from the board. If you blow on it or put your finger on the little silver square on the temperature board, both values should start to change.
    I'm not dead yet!
    I'm not dead yet!

The Orginal Code

We’re going to overwrite the original code in the coming steps, but if you want to return to it, here it is:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <AHT20.h>

#define UPDATE_SECONDS 2

AHT20 AHT;

float humidity, temperature;

void setup()
{
  Serial.begin(115200);
  AHT.begin();
}

void loop()
{
  bool ok = AHT.getSensor(&humidity, &temperature);
  
  if(ok)
  {
    humidity = humidity * 100;
    temperature = temperature * 9 / 5 + 32;

    Serial.printf("Temperature:%.1f Humidity:%.0f \n", temperature, humidity);
  }
  else
  {
    Serial.println("ERROR: no temp data");
  }

  delay(UPDATE_SECONDS * 1000);
}

Just A Thing

Right now it’s not very useful: your laptop has essentially been turned into an expensive thermometer. Let’s change that by addressing the Internet part of IoT.

Next Up: Connecting To WiFi