Go Down

Topic: Connecting an Si7021 Temperature/Humidity Sensor to an Adafruit HUZZAH ESP826 (Read 569 times) previous topic - next topic


     For the life of me, I cannot get the Si7021 to function correctly with this board. I have the Huzzah communicating with an MQTT server without issue and I want it to send temperature data to the server. I currently have the sensor connected to 3V power and ground with the SCL and SDA at pins 4 and 5 respectively. The following is code in progress which should print temperature data in the serial port. I want the sensor to print data before I program in the sending to the cloud. The code will compile but will run into an issue uploading at about 90% or so. This happens every time if the temperature sensor related lines are kept in. If the lines related to the temperature sensor are removed the code uploads correctly. Any ideas on the issue? Thank you!

Code: [Select]
#include <EEPROM.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <Wire.h>
#include <Adafruit_Si7021.h>

// Connect to the WiFi
const char* ssid = "******";
const char* password = "**********";
const char* mqtt_server = "********";

WiFiClient espClient;
PubSubClient client(espClient);

const byte ledPin = LED_BUILTIN; // Pin with LED on Adafruit Huzzah
Adafruit_Si7021 sensor;
float temp;

void callback(char* topic, byte* payload, unsigned int length) {
 Serial.print("Message arrived [");
 Serial.print("] ");
 for (int i=0;i<length;i++) {
  char receivedChar = (char)payload[i];
  if (receivedChar == '0')
  // ESP8266 Huzzah outputs are "reversed"
  digitalWrite(ledPin, HIGH);
  if (receivedChar == '1')
   digitalWrite(ledPin, LOW);

void reconnect() {
 // Loop until we're reconnected
 while (!client.connected()) {
 Serial.print("Attempting MQTT connection...");
 // Attempt to connect
 if (client.connect("ESP8266 Client")) {
  // ... and subscribe to topic
 } else {
  Serial.print("failed, rc=");
  Serial.println(" try again in 5 seconds");
  // Wait 5 seconds before retrying

void setup()

 client.setServer(mqtt_server, 1883);
sensor = Adafruit_Si7021();
 if (sensor.begin()) {
  /Serial.println('Sensor ready');
 } else {
   // TODO: We should probably reset the device if this happens
   Serial.println('SENSOR FAILED TO START');

 pinMode(ledPin, OUTPUT);

void loop()
 if (!client.connected()) {



The code will compile but will run into an issue uploading at about 90% or so.
And that issue is?

Go Up