Analyzing I2C signals

dev board Arduino UNO
chip Si7021
tool Saleae Logic Analyser
features I2C logic analyser

Before starting

Dependancies

Ensure the following requirements are available:

Description

View the decoded I2C signal from the graph produced by Saleae to read temperature from an Si7021 breakout board.

Capture the signal in Saleae:

All signals

Add asynchronous serial to decode the captured signal:

Decoded I2C signal

MS Byte for temperature is 0x6D and LS Byte for temperature is 0xAC which is 0x6DAC in hexadecimal and 28076 in decimal. Using the equation given in the datasheet, the temperature in Celcius is 28076*175.72 / 65536 - 46.85 = 28, 28 C, which is same as what is shown in the serial monitor.

Code

Download code
#include "Adafruit_Si7021.h"

Adafruit_Si7021 sensor = Adafruit_Si7021();

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);
  Serial.println("Start Si7021");

  if (!sensor.begin()) {
    Serial.println("Did not find Si7021 sensor!");
    while (true) {}
  } else {
    Serial.println("Temperature in Celsius:");
  }
}

void loop() {
  Serial.println(sensor.readTemperature());

  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);

  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}

Makefile

BOARD?=arduino:avr:uno
PORT?=/dev/cu.usbmodem14*

.PHONY: default lint all flash clean

default: lint all flash clean

lint:
	cpplint --extensions=ino --filter=-legal/copyright *.ino

all:
	arduino-cli compile --fqbn $(BOARD) ./

flash:
	arduino-cli upload --fqbn $(BOARD) --port $(PORT)

clean:
	rm -r build

Serial console

Serial output from the firmware.

Analyzing I2C signals serial console

Schematic

Wire up the hardware accordingly

Analyzing I2C signals schematic

Prototype

A photo of the actual setup.

Analyzing I2C signals prototype

References

Watch