Using the EMC2101 with Arduino is a simple matter of wiring up the sensor to your Arduino-compatible microcontroller, installing the Adafruit EMC2101 library we've written, and running the provided example code.

I2C Wiring

Use this wiring if you want to connect via I2C interface. The I2C address for the EMC2101 is 0x4C.

Here is how to wire the sensor to a board using a breadboard, using a NPN transistor as a makeshift temperature diode. The examples show a Metro but wiring will work the same for an Arduino or other compatible board.

 

Carefully check the fan connections. Accidentally wiring the Fan V+ to the EMC2101 or Metro can permanently damage the boards
  • Connect board VIN (red wire) to Arduino 5V if you are running a 5V board Arduino (Uno, etc.). If your board is 3V, connect to that instead.
  • Connect board GND (black wire) to Arduino GND
  • Connect board SCL (yellow wire) to Arduino SCL
  • Connect board SDA (blue wire) to Arduino SDA
  • Connect board DP (orange wire) to Transistor Base
  • Connect board DN (gray wire) to Transistor Emitter
  • Connect transistor Collector (orange wire) to Transistor Base
  • Connect board FAN to fan PWM input
  • Connect board TACH to fan Tach output
  • Connect DC jack positive pin to Fan V+ input
  • Connect DC jack GND to Fan V-/GND input
  • Connect DC jack GND to Arduino GND

Library Installation

You can install the Adafruit EMC2101 library for Arduino using the Library Manager in the Arduino IDE.

Click the Manage Libraries ... menu item, search for Adafruit EMC2101 , and select the Adafruit EMC2101 library:

Follow the same process for the Adafruit BusIO library.

Load Example

Open up File -> Examples -> Adafruit EMC2101 -> adafruit_emc2101_test

After opening the demo file, upload to your Arduino wired up to the EMC2101. Once you upload the code, you will see the Internal and External Temperature, Fan speed and PWM duty cycle values being printed when you open the Serial Monitor (Tools->Serial Monitor) at 115200 baud, similar to this:

Example Code

 

// Basic demo for readings from Adafruit EMC2101
#include <Adafruit_EMC2101.h>

Adafruit_EMC2101  emc2101;

void setup(void) {
  Serial.begin(115200);
  while (!Serial) delay(10);     // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("Adafruit EMC2101 test!");

  // Try to initialize!
  if (!emc2101.begin()) {
    Serial.println("Failed to find EMC2101 chip");
    while (1) { delay(10); }
  }
  Serial.println("EMC2101 Found!");

  //  emc2101.setDataRate(EMC2101_RATE_1_16_HZ);
  Serial.print("Data rate set to: ");
  switch (emc2101.getDataRate()) {
    case EMC2101_RATE_1_16_HZ: Serial.println("1/16_HZ"); break;
    case EMC2101_RATE_1_8_HZ: Serial.println("1/8_HZ"); break;
    case EMC2101_RATE_1_4_HZ: Serial.println("1/4_HZ"); break;
    case EMC2101_RATE_1_2_HZ: Serial.println("1/2_HZ"); break;
    case EMC2101_RATE_1_HZ: Serial.println("1 HZ"); break;
    case EMC2101_RATE_2_HZ: Serial.println("2 HZ"); break;
    case EMC2101_RATE_4_HZ: Serial.println("4 HZ"); break;
    case EMC2101_RATE_8_HZ: Serial.println("8 HZ"); break;
    case EMC2101_RATE_16_HZ: Serial.println("16 HZ"); break;
    case EMC2101_RATE_32_HZ: Serial.println("32 HZ"); break;
  }

  emc2101.enableTachInput(true);
  emc2101.setPWMDivisor(0);
  emc2101.setDutyCycle(50);
}



void loop() {
  Serial.print("External Temperature: ");
  Serial.print(emc2101.getExternalTemperature());
  Serial.println(" degrees C");

  Serial.print("Internal Temperature: ");
  Serial.print(emc2101.getInternalTemperature());
  Serial.println(" degrees C");

  Serial.print("Duty Cycle: ");
  Serial.print(emc2101.getDutyCycle());
  Serial.print("% / Fan RPM: ");
  Serial.print(emc2101.getFanRPM());
  Serial.println(" RPM");
  Serial.println("");

  delay(100);
}

This guide was first published on Dec 15, 2020. It was last updated on Dec 15, 2020.

This page (Arduino) was last updated on Apr 14, 2021.

Text editor powered by tinymce.