Test code for SI7021 temperature/humidity sensor doesn't work with Micro Pro

I downloaded and placed a SI7021.h library in to the appropriate folder.
wire.h is I2C library?

Library for the sensor.
Than I tried to compile this code:

#include <Wire.h>
#include <SI7021.h>


SI7021 sensor;
int led1 = 3;
int led2 = 4;

void setup() {
    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);
    sensor.begin();
}


void loop() {

    // temperature is an integer in hundredths
    int temperature = sensor.getCelsiusHundredths();
    temperature = temperature / 100;
    for (int i = 0; i < temperature; i++) {
        pulse(led1); 
    }
    
    delay(5000);
    
    // humidity is an integer representing percent
    int humidity = sensor.getHumidityPercent();
    for (int i = 0; i < humidity; i++) {
        pulse(led2); 
    }
    
    delay(5000);
    
    // this driver should work for SI7020 and SI7021, this returns 20 or 21
    int deviceid = sensor.getDeviceId();
    for (int i = 0; i < deviceid; i++) {
        pulse(led1); 
    }
    delay(5000);

    // enable internal heater for testing
    sensor.setHeater(true);
    delay(20000);
    sensor.setHeater(false);
    
    // see if heater changed temperature
    temperature = sensor.getCelsiusHundredths();
    temperature = temperature / 100;
    for (int i = 0; i < temperature; i++) {
        pulse(led2); 
    }
    
    //cool down
    delay(20000);

    // get humidity and temperature in one shot, saves power because sensor takes temperature when doing humidity anyway
    si7021_env data = sensor.getHumidityAndTemperature();
    for (int i = 0; i < data.celsiusHundredths/100; i++) {
        pulse(led1); 
    }
    for (int i = 0; i < data.humidityBasisPoints/100; i++) {
        pulse(led2); 
    }
    delay(5000);
}

void pulse(int pin) {
   // software pwm, flash light for ~1 second with short duty cycle
   for (int i = 0; i < 20; i++) {
       digitalWrite(pin, HIGH);
       delay(1);
       digitalWrite(pin,LOW);
       delay(9);
   }
   digitalWrite(pin,LOW);
   delay(300);
}

And I get an error message that tells me this:

Arduino: 1.6.8 (Windows 8.1), Board: "Arduino/Genuino Micro"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware "C:\Program Files (x86)\Arduino\hardware" -tools "C:\Program Files (x86)\Arduino\tools-builder" -tools "C:\Program Files (x86)\Arduino\hardware\tools\avr" -built-in-libraries "C:\Program Files (x86)\Arduino\libraries" -libraries "C:\Users\VTolskiy\Documents\Arduino\libraries" -fqbn=arduino:avr:micro -ide-version=10608 -build-path "C:\Users\VTolskiy\AppData\Local\Temp\build7537f1e8d7b3037aacbc45185d0dc793.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\VTolskiy\AppData\Local\Temp\arduino_modified_sketch_358014\readsensor.ino"
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware "C:\Program Files (x86)\Arduino\hardware" -tools "C:\Program Files (x86)\Arduino\tools-builder" -tools "C:\Program Files (x86)\Arduino\hardware\tools\avr" -built-in-libraries "C:\Program Files (x86)\Arduino\libraries" -libraries "C:\Users\VTolskiy\Documents\Arduino\libraries" -fqbn=arduino:avr:micro -ide-version=10608 -build-path "C:\Users\VTolskiy\AppData\Local\Temp\build7537f1e8d7b3037aacbc45185d0dc793.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "C:\Users\VTolskiy\AppData\Local\Temp\arduino_modified_sketch_358014\readsensor.ino"
Build options changed, rebuilding all
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR  -DUSB_VID=0x2341 -DUSB_PID=0x8037 '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="Arduino Micro"' "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\micro" "C:\Users\VTolskiy\AppData\Local\Temp\build7537f1e8d7b3037aacbc45185d0dc793.tmp\sketch\readsensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR  -DUSB_VID=0x2341 -DUSB_PID=0x8037 '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="Arduino Micro"' "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\micro" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "C:\Users\VTolskiy\AppData\Local\Temp\build7537f1e8d7b3037aacbc45185d0dc793.tmp\sketch\readsensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR  -DUSB_VID=0x2341 -DUSB_PID=0x8037 '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="Arduino Micro"' "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\micro" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Program Files (x86)\Arduino\libraries\SI7021-master" "C:\Users\VTolskiy\AppData\Local\Temp\build7537f1e8d7b3037aacbc45185d0dc793.tmp\sketch\readsensor.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10608 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR  -DUSB_VID=0x2341 -DUSB_PID=0x8037 '-DUSB_MANUFACTURER="Unknown"' '-DUSB_PRODUCT="Arduino Micro"' "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\micro" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src" "-IC:\Program Files (x86)\Arduino\libraries\SI7021-master" "C:\Users\VTolskiy\AppData\Local\Temp\build7537f1e8d7b3037aacbc45185d0dc793.tmp\sketch\readsensor.ino.cpp" -o "C:\Users\VTolskiy\AppData\Local\Temp\build7537f1e8d7b3037aacbc45185d0dc793.tmp\preproc\ctags_target_for_gcc_minus_e.cpp"
C:\Users\VTolskiy\AppData\Local\Temp\arduino_modified_sketch_358014\readsensor_esp8266.ino:1:25: fatal error: ESP8266WiFi.h: No such file or directory

 #include <ESP8266WiFi.h>

                         ^

compilation terminated.

Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire 
Using library SI7021-master in folder: C:\Program Files (x86)\Arduino\libraries\SI7021-master (legacy)
exit status 1
Error compiling for board Arduino/Genuino Micro.

So looking at the last six lines, why can’t I compile this program for Arduino Micro Pro with atmega32u4?

SDA and SCL pins are different. They are 2 and 3 respectively. I changed the pins and still Arduino compiler won’t let me upload it.

Please save your sketch before compiling. Somehow you have mixed the normal example with the example for the ESP8266, but you don’t have a ESP8266.
Examples : SI7021/examples/readsensor at master · LowPowerLab/SI7021 · GitHub
Try again with the normal example.

For getting the values for temperature and humidity from SI7021 sensor, you can try this code SI7021 Arduino Code. This does not include SI7021 library.If still you are facing any compiling errors while compiling and saving the code, try doing the same for a simple arduino code first and uploading it, checking everything else is working fine.

batman_d408:
For getting the values for temperature and humidity from SI7021 sensor, you can try this code SI7021 Arduino Code. This does not include SI7021 library.If still you are facing any compiling errors while compiling and saving the code, try doing the same for a simple arduino code first and uploading it, checking everything else is working fine.

That was easy. I don’t know why I didn’t find this code when I googled for information to use Si7021. It works with all of the libraries I have in place by now.
Thank you.

Can I change addresses on this chip so I can use several temp/humidity sensors like this in one system?

Hii..
I am glad it helped you out. Well, you can then try the codes for other sensors also from the same community. :slight_smile:
I have heard of something called Software I2C but have never used it. If you are able to make your digital pins as SDA, SCL, I think you can use several sensors on different lines with the same I2C address.

To prevent yourself from complexity, you can try out other sensors that measure the same temperature and humidity for you but use different I2C address than SI7021. Also you can connect sensor that can be connected more than one per I2C port i.e. you can change chip address for those.

Two sensors per I2C port can be used: BME-280, SI-7013, SHT-31, SHT-30

Four of HDC1000 can be used at one I2C port. By, connecting jumpers at different combination of pins on the module, you can get different chip addresses. You can get them easily and interface them.

Can several such sensors work together on one I2C bus?

Yes, several such sensors can work together on one I2C bus. You can connect one sensor to other different sensor with different I2C address on the same I2C line like this.
Here, you can see BME-280 and SHT31 connected.Two sensor on same i2c line

You can connect 4 i2c sensors like this:
Four I2C sensors

And also you can use jumpers to change the i2c addresses of BME-280 or HDC-1000 to get two BME-280 or four HDC-1000 connected (if you want to use the same modules) on the same I2C line.

I looked at all the sensors. HDC 1008 are quite expensive. It makes sense to use a mix of three different I2C sensors.

http://www.ebay.com/itm/141975982004?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

I bought 2 of this. Where do I cut a traceo n the PCB to change address?

In real life left and middle sectors don't look connected at all.
Can I check them with a multimeter to see if they are without burning anything?

I know this is resurrecting, but I wanted to thank whoever made that code. That really helped out with my Mega.