Skip to content

Instantly share code, notes, and snippets.

@kamiyaowl
Created May 10, 2020 05:59
Show Gist options
  • Save kamiyaowl/b3810792df7f7d647064894aa6efe5d6 to your computer and use it in GitHub Desktop.
Save kamiyaowl/b3810792df7f7d647064894aa6efe5d6 to your computer and use it in GitHub Desktop.
/************************************************************************
M5StackFire I2C Scanner
The M5StackFire has a connector for I2C devices.
This program scans the addresses 1-127 continuosly and shows
the devices found on the TFT.
The M5Stack fire has two internal I2C devices at address 0x68 and 0x75.
If they do not appear on the TFT it could mean you made a short cut on
the I2C bus.
October 2018, ChrisMicro
************************************************************************/
#include <TFT_eSPI.h> // Graphics and font library for ILI9341 driver chip
#include <SPI.h>
#include <Wire.h>
#define TFT_GREY 0x5AEB // New colour
TFT_eSPI tft = TFT_eSPI(); // Invoke library
void setup()
{
tft.init();
tft.setRotation(2);
Wire.begin();
delay(3000);
tft.fillScreen(TFT_BLACK);
}
int textColor = TFT_YELLOW;
void loop()
{
int address;
int error;
tft.setCursor(0, 0);
tft.println("scanning Address [HEX]");
for (address = 1; address < 127; address++)
{
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
tft.print(address, HEX);
tft.print(" ");
}
else
tft.print(".");
delay(10);
}
if (textColor == TFT_YELLOW)
textColor = TFT_GREEN;
else
textColor = TFT_YELLOW;
tft.setTextColor(textColor, TFT_BLACK);
}
@kamiyaowl
Copy link
Author

昨日のI2C Tester(M5StickCにいたやつ)移植、認識しているようだった pic.twitter.com/sfSd8QuG8t

— おふとん.co.jp (@kamiya_owl) May 10, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment