In this experiment, we will be learning to make a wireless temperature and humidity monitoring system using the Witty Fox ESP 32 Dev Board and Witty Fox Si7021 Breakout board. The Si7021 I2C Humidity and Temperature Sensor is a monolithic CMOS IC integrating humidity and temperature sensor elements, an analog-to-digital converter, signal processing, calibration data and an I2C Interface. The Si7021 breakout is directly compatible with the WittyFox ESP 32 Dev Board through the dedicated I2C ports P9 or P10.

This experiment requires certain prerequisites on creating a Thingspeak account and channel. You also need to know how to program the Witty Fox ESP 32 Dev Board. Please refer to the following links to learn more about the same.


To learn about creating a thingspeak channel and uploading data on the cloud using ESP32, refer our guide on DS18B20 -ALL YOU NEED TO KNOW

To learn about programming the Witty Fox ESP 32 Dev Board using Witty Fox programmer (or any generic USB to TTL converter), please refer to the WITTY FOX ESP32 DEV BOARD


The code for this experiment is given below. Link for the libraries required is given below:


Adafruit Si7021 library:


Thingspeak library:


Upload the following code to an ESP32 module after making appropriate changes. Login to your thingspeak account and you can monitor live temperature and humidity data of the sensor's environment.




  WittyFox Si7021 Thingspeak experiment


  Demonstrates the capabilities of the WittyFox ESP 32 Dev Board.


  This sketch gets Temperature and Humidity readings from Si7021 I2C based sensor and uploads the same data to thingspeak.




#include <ThingSpeak.h>

#include <WiFi.h>

#include "Adafruit_Si7021.h"


Adafruit_Si7021 sensor = Adafruit_Si7021();


#define NETWORK_SSID "MySSID"  // replace MySSID with your WiFi network name

#define NETWORK_PASS "MyPassword" // replace MyPassword with your WiFi password


#define CH_ID_Temp 000000 // replace 0000000 with your channel number corresponding to Temperature

#define CH_ID_Humidity 000000 // replace 0000000 with your channel number corresponding to Humidity


#define WRITE_APIKEY_TEMP "XYZ" // replace XYZ with your channel write API Key

#define WRITE_APIKEY_HUMIDITY "XYZ" // replace XYZ with your channel write API Key


int keyIndex = 0;          // your network key Index number (needed only for WEP)

WiFiClient client;





  Serial.begin(115200); //Initialize serial

  sensor.begin();       //Initialize the sensor


  ThingSpeak.begin(client); // Initialize ThingSpeak


  Serial.println("Si7021 test!");


  if (!sensor.begin()) {    //TO check if the sensor is connected properly

    Serial.println("Did not find Si7021 sensor!");

    while (true);






  // Connect or reconnect to WiFi

  if (WiFi.status() != WL_CONNECTED)


    Serial.print("Attempting to connect to SSID: ");


    while (WiFi.status() != WL_CONNECTED)


      //todo : change to defined here

      WiFi.begin(NETWORK_SSID, NETWORK_PASS); // Connect to WPA/WPA2 network. Change this line if using open or WEP network







  ThingSpeak.writeField(CH_ID_Temp, 1, sensor.readTemperature(), WRITE_APIKEY_TEMP);      //Updates the specified channel with current temperature using the WriteAPIkey

  ThingSpeak.writeField(CH_ID_Humidity, 1, sensor.readHumidity(), WRITE_APIKEY_HUMIDITY); //Updates the specified channel with current humidity using the WriteAPIkey


  Serial.print("Humidity: ");


  Serial.print("\tTemperature: ");



  delay(10000); // Wait 10 seconds to update the channel again


Components and Supplies

You may also like to read

Frequently Asked Questions

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.

Components and Supplies

You may also like to read