Avatar
ARDUINO I2C SCANNER LIBRARY
Aug 17th, 2021 | by: Rick Sanchez | Views 1450
Views 1450

The I2CScanner library is instantiated through its constructor. The object contains as variables the address range for Low_Address and High_Address scanning. The object is initialized through the Init () method. There are three families of methods. The Scan methods work in the same way as the traditional Sketch I2CScanner, displaying the results on the screen. The Check methods check for the existence of the devices, but do not show any output. Finally, the Execute functions receive a Callback function as a parameter, and execute it only if the device is connected. All three families of functions have overloads. If they do not receive any parameters, they act on the range defined by Low_Address and High_Address. If they receive an address, they act on it. If they receive a vector of directions, they act on them.

BUILDER

The I2CScanner class is instantiated as an object through its constructor.


I2CScanner();

USING I2CSCANNER

   // Devices found with last scan
   uint8_t Devices_Count;
   
   // Range for the scanner
   uint8_t Low_Address = 1;
   uint8_t High_Address = 127;
   
   // Initialize
   void Init();

   // scan functions
   bool Scan();
   bool Scan(byte address);
   bool Scan(byte addreses[], uint8_t length);

   // Check functions
   bool Check();
   bool Check(byte address);
   bool Check(byte addreses[], uint8_t length);

   void Execute(I2C_Callback callback);
   void Execute(byte address, I2C_Callback callback);
   void Execute(byte addreses[], uint8_t length, I2C_Callback callback);

EXAMPLES

The I2CScanner library includes the following examples to illustrate its use.

 

  • Scanner: Example showing the use of I2CScanner showing results by Serial

 #include "I2CScanner.h"

I2CScanner scanner;

void setup() 
{
   Serial.begin(9600);
   while (!Serial) {};

   scanner.Init();
}

void loop() 
{
   scanner.Scan();
   delay(5000);
}

  • Check: Example that shows the use of I2CScanner, storing the check results in an array, which we would then use in the code

#include "I2CScanner.h"

I2CScanner scanner;

const uint8_t num_addresses = 4;
const byte addresses[num_addresses] = { 0x20, 0x21, 0x40, 0x41 };
bool results[num_addresses] = { false, false, false, false};


void setup() 
{
   Serial.begin(9600);
   while (!Serial) {};

   scanner.Init();
}

void loop() 
{
   for (uint8_t index = 0; index < num_addresses; index++)
   {
      results[index] = scanner.Check(addresses[index]);
   }
   
   for (uint8_t index = 0; index < num_addresses; index++)
   {
      if (results[index])
      {
         Serial.print("Found device ");
         Serial.print(index);
         Serial.print(" at address ");
         Serial.println(addresses[index], HEX);
      }
   }
   delay(5000);
}

  • Execute: Example showing the use of I2CScanner executing callback functions

#include "I2CScanner.h"

I2CScanner scanner;

const byte address;

void debug(byte address)
{
   Serial.print("Found at 0x");
   Serial.println(address, HEX);
}

void setup() 
{
   Serial.begin(9600);
   while (!Serial) {};

   scanner.Init();
}

void loop() 
{
   scanner.Execute(debug);
   delay(5000);
}

INSTALL the library
  • Download the latest version from GitHub
  • Unzip the file
  • Copy to your libraries folder (usually My Documents \ Arduino \ libraries)
  • Relaunch the Arduino IDE

 

16 Comments

  • Noob 19129

    about 8 months ago

    Please try Google before asking about Best Product Blog aa023d9

    Noob 19129

    about 5 months ago

    Please try urlhttpswwwgooglecomGoogleurl before asking about urlhttpsprakardsodcomindexphptopic21838newnewUseful Product Tipsurl e0b59a7

    Noob 19129

    about 5 months ago

    Please try urlhttpswwwgooglecomGoogleurl before asking about urlhttpwwwfor5umwolieracomviewtopicphpp116985116985Updated Product Guideurl 579805

    Noob 19129

    about 5 months ago

    Please try urlhttpswwwgooglecomGoogleurl before asking about urlhttpsddddkengracingcomindexphptopic1803967newnewExcellent Product Siteurl 4aa023d

    Noob 19129

    about 4 months ago

    Please try urlhttpswwwgooglecomGoogleurl before asking about urlhttpsserviciotecnicoengranadaesforoindexphptopic2152newnewRecommended Product Infourl 79e0b59

    Noob 19129

    about 4 months ago

    Please try urlhttpswwwgooglecomGoogleurl before asking about urlhttpsforumnicholasjacquetcomthread356615post1048929htmlpid1048929Excellent Product Infourl 5f79e0b

    Noob 19129

    about 3 months ago

    Please try urlhttpswwwgooglecomGoogleurl before asking about urlhttpswwwteamrmpcomviewtopicphpp14238p14238Top Rated Product Guideurl f79e0b5

    Noob 19129

    about 3 months ago

    Please try urlhttpswwwgooglecomGoogleurl before asking about urlhttpsforum21upcoukshowthreadphptid1783pid2377pid2377Updated Product Infourl f6c4aa0

    Noob 19129

    about 2 months ago

    In response to the lady talking about rtp jagat slot virtual slot88 agen slot resmi slot terpercaya situs terbaik slot online situs slot aman terpercaya gacor abis slot online gacor pola gacor slot slot se asia I highly suggest this urlhttpsknoxmvek43322blgwikicom637124excellentreasonsonselectingtajir4dsiteshigh rated TajirSlot adviceurl or info slot gacor sekarang kami slot situs gacor slot terbaru slot dan rtp ahli slot gacor slot rtp situs slot gacor pragmatic play slot aman gacor situs slot gacor terpercaya gacor slot and dont forget this urlhttpsangelozouv94716wikikalicom533356greatideasforpickingtajir4dsitesat yahoo for TajirSlot detailsurl on top of daftar gacor slot slot gacor terupdate slot terpercaya daftar situs slot gacor gaming slot online situs slot yang terpercaya situs judislot slot tergacor se asia situs slot pragmatic gacor slot itu judi not to mention this urlhttpsarcherxgot14579lotrlegendswikicom645088freeadviceforselectingtajir4dwebsitesupdated TajirSlot blogurl which is also great Also have a look at this urlhttpsangelofxkt60471look4blogcom65535881handynewsonpickingtajirslotsitesbreaking news on TajirSlot detailsurl and dont forget png slot mudah gacor url slot judi online terbaik judi online resmi terbaik slot slot gacor promo slot terbaru2023 login situs slot situs slot terpercaya gacor on top of this urlhttpscharlieeowe11009wikiexcerptcom2785228excellentadvicetoselectingtajirslotsitesarticle source on TajirSlot urlurl with pola slot yang gacor daftar slot terbaik situs slot online kumpulan situs slot terbaru situs situs slot situs gacor rtp slot gacor super sbg slot prag matic play slot gacor logo for good measure Check more urlhttpwwwsubaruxvthailandcomforumindexphptopic28990newnewHigh Rated 7RAJATOGEL Siteurl 9f6c4aa

    Noob 19129

    about 2 months ago

    Please try urlhttpswwwgooglecomGoogleurl before asking about urlhttpsbbsidentityvjpforumphpmodviewthreadtid2305577pid3199214page1extrapage3D1pid3199214Top Rated Product Tipsurl aa023d9

    Noob 19129

    about 1 month ago

    Please try urlhttpswwwgooglecomGoogleurl before asking about urlhttpswwwculvergamecomforumphpmodviewthreadtid854pid2010page3extrapid2010Useful Product Guideurl d94c5f7

    Noob 19129

    about 1 month ago

    In response to the people inquiring about atlanta truck accidents attorney macon car crash accident attorney macon ga expert semi truck accident law firm assistance mcalpinskountrykitchen law firms in ga attorney in macon wreck macon ga nuisance doctrine car crash law firm augusta product liability attorney georgia I highly suggest this urlhttpslandon9x13viv0blogsideacomprofilehigh rated accident attorney linkurl or semi truck accident attorney atlanta truck accidents near me atlanta hydroplaning truck accident lawyer funny laws in georgia commercial truck accidents lawyer personal injury lawyer macon accident in macon ga today parking on premises child birth lawfirms car crash lawyers augusta on top of this urlhttpsbookmarkswingcomstory18435226atlantapersonalinjuryandcaraccidentsinmacongamore helpful hints for accident lawyer adviceurl as well as personal injury lawyer near me atlanta ga what is the georgia move over law macon pedestrian accident attorney dram shop violation augusta automobile accident law firm is lane splitting legal in ga macon georgia lawyers kathy mcarthur best accident injury lawyer macon wreck macon ga alongside all this urlhttpslandon4a67ujw1myparisblogcomprofiletop rated liability attorney linkurl which is also great Also have a look at this urlhttpcf58051tmwebruindexphpactionprofileu2393246top wrongful death attorney detailsurl as well as georgia truck accident lawyer product liability lawyer gwinnett county uninsured motorist law firm johns creek elder abuse attorney are trains still used law firms for spinal cord injury truck accident attorney atlanta ga trains vs trucks personal injury attorney in atlanta ga macon ga car accident as well as this urlhttpiminthaicomhomephpmodspaceuid220063new liability attorney siteurl with cancer attorney dram shop liability attorneys michael thompson attorney surgical error compensation macon lawyers johns creek elder abuse lawyer macon attorney augusta automobile accident law firm georgia birth injury lawyer georgia personal injury attorneys for good measure Check more urlhttpwwwwbbet88comforumphpmodviewthreadtid2190pid919179page1788extrapid919179Top Rated Clothing Store Simulator Infourl c5f79e0

    Noob 19129

    about 24 days ago

    For the guy asking about slot online live main jackpot online satu play slot sg metro slot jackpot game slot slot service slot whatsapp ion slot online game judi slot online uang asli provider judi slot online I highly suggest this urlhttpstrentonsadc06285designertoblogcom58638200besttipstopickingdvltotowebsitesgo to the website on DVLTOTO siteurl or agen slot asia link slot live22 bandar judi togel online web judi slot jili slot rtp login casino online habanero slot game main casino online game slot spadegaming ion casino live online on top of this urlhttpsarchermomi16172smblogsitescom27220534besttipstopickingain1000xloginsiteread full article about DVLTOTO adviceurl on top of free spin login casino web 24 slot casino link slot indonesia sini slot login cara main slot judi jili slot casino live22 slot login sbo pragmatic slot jago slot indonesia and dont forget this urlhttpswaylonfdez57847blogsuperappcom27725966excellentreasonsforchoosingdvltotoslotsitesgreat DVLTOTO SLOT tipsurl which is also great Also have a look at this urlhttpsdallasgfar62838jaiblogscom54134634greattipsonpickingawin1000xwebsitesuch a good point for DVLTOTO forumurl alongside all game slot microgaming spadegaming slot online agen resmi judi slot online live chat casino slot online microgaming casino casino login toto casino login slot microgaming rtp tinggi pada slot judi game slot online not to mention this urlhttpsandersonoeti56780libertyblogcom27323379recommendedinfoforchoosingdvltotoslotsitesarticle source on DVLTOTO SLOT adviceurl with akun bandar slot pragmatic play game slot spadegaming macau casino online ion slot rtp bandar judi 4d judi slot game sistem main slot jadi bandar judi judi online 4d slot mobile casino for good measure Check more urlhttpsrostovbikeruthread1827post13179htmlpid13179High Rated Garden Extension Infourl 23d94c5

    Noob 19129

    about 16 days ago

    For the people talking about ninja hoki slot kami slot link alternatif slot ini slot rtp terpercaya id pragmatic link alternatif slot888 slot whatsapp casino indonesia togel slot login idr 88 slot I highly recommend this urlhttpsdallaszgms24680dbblognet607308goodfactsonchoosingaman88slotsitesget the facts for Aman88 linkurl or game slot play link slot rtp instal slot slot88 game slot kami special slot indo slot online link pragmatic gacor pengaturan slot lucky slot on top of this urlhttpsgregoryyfmq02457wikinstructionscom728109goodtipsforpickingaman88websitescool Aman88 forumurl on top of login casino game slot login web slot gacor situs online slot terpercaya login cuan88 slot dengan rtp live slot situs gacor playtech slot online rtp in slot link pragmatic play not to mention this urlhttpsfinngchl11098isblognetfreesuggestionsforchoosingaman88slotwebsites44532744learn more here on Aman88 forumurl which is also great Also have a look at this urlhttpsmariolpdy95877wikififficom727544handytipsforpickingaman88sitesclick here for Aman88Slot detailsurl alongside all cuan slot pragmatic play id download game pragmatic slot arcade wap slot logo hoki login gatesof olympus slot88 link alternatif link hoki slot pragmatic slot gacor and dont forget this urlhttpszanewnzn79629wizzardsblogcom27448260freefactstochoosingaman88sitesher response for Aman88Slot siteurl with aplikasi olympus slot indonesia 88 slot rtp 88 slot jackpot 88 prag matic play tm slot cuan88 slot november slot slot88 net slot lengkap dengan rtp for good measure Check more urlhttpsbitmemetalknetindexphptopic888924newnewExcellent CuanSlot88 Siteurl 057982

    Noob 19129

    about 12 days ago

    In reply to the man asking about design bathroom and kitchen cabinets cabinet makers in this area click kitchen cabinets bathroom cabinet pics discount kitchen cabinets and countertops office cabinets ideas create your kitchen design kitchen cabinet styles and finishes build custom cabinets online home office cabinet design I highly suggest this urlhttpsevan5l63fbx8blogsvilacomprofiledescription about Tajir4D Login forumurl or no cabinet kitchen design affordable quality kitchen cabinets designs bathroom kitchen cabinets tailored cabinets build it cabinets kitchen cabinet design company custom cabinets shops near me the kitchen cabinets cupboards for the kitchen cabinet makers in the area alongside all this urlhttp75734wwwmolifannetspaceuid2072071htmlcool Tajir4D Login blogurl not to mention best type of cabinets for kitchen all cabinet design kitchen cupboards made to order on average how much do kitchen cabinets cost custom cabinet builders near me estimate for new kitchen cabinets designing my kitchen kitchen cabinet decoration materials needed for cabinet making budget friendly cabinets not to mention this urlhttpsaustin3i28roo4ktwikicomuserread more about Tajir4D cabinet infourl which is also great Also have a look at this urlhttpsbrayden3d29ade0getbloggingcomprofileupdated Tajir4D cabinet tipsurl and dont forget kitchen cupboards layout custom kitchen cabinet makers near me cabinets luxury kitchen cabinet design with dimensions semi custom kitchen cabinets near me see what your kitchen would look like custom cabinets online kitchen bathroom cabinets order custom kitchen cabinets kitchen cabinets cupboards on top of this urlhttpsjack8w08dxv7blogoxocomprofiletotal stranger for Tajir4D Login detailsurl with new style cabinet need kitchen cabinets cabinets made easy inspire cabinetry new home cabinets cabinet designer free his countertops cost effective cabinets craft cabinetry black cabinets in a small kitchen for good measure Check more urlhttpselymbmxcommybbshowthreadphptid4611pid144310pid144310Awesome Human Composting Guideurl b59a705

    Noob 19129

    about 2 days ago

    To the people asking about orthodontist deals near me full braces early braces austin best orthodontist dentist teeth straightening invisalign through dentist braces office near me new braces technology teeth straightening free consultation different braces I highly recommend this urlhttpsjohsocialcomstory7525473bracesteethbracesandsmileorthodonticstop rated Limestone Hills Orthodontics linkurl or teeth treatment braces full braces dental care braces unique orthodontist braces treatment brace orthodontic practice orthodontist west orthodontic solutions dds orthodontist dr best orthodontist and dont forget this urlhttpscarson7z58ahn8thenerdsblogcomprofileadditional reading on Limestone Hills Orthodontics adviceurl not to mention braces braces reviews payment plan for braces with insurance york orthodontics north york the brace place reviews orthodontist a dentist braces perfect smile best dentist orthodontist near me orthodontist near me braces braces on benefits smile experience orthodontics alongside all this urlhttpsbouchesocialcomstory19094544ceramicbracesandgoodorthodontistnearmelearn more on Limestone Hills Orthodontics urlurl which is also great Also have a look at this urlhttpsjoshua5p93uke9cosmicwikicomuserthe original source for Limestone Hills Orthodontics urlurl and dont forget dental teeth braces traditional metal braces best option for braces other options besides braces and invisalign braces and dentistry smiles of austin austin tx another option for braces ortho orthodontist white braces on teeth all metal braces alongside all this urlhttpsbookmarkalexacomstory2738253teethbracespaymentplanandbracesandsmilesawesome Limestone Hills Orthodontics detailsurl with braces financing options invisalign austin tx best orthodontist austin tx braces cosmetic all different types of braces smile straight teeth braces near me payment plan cost for orthodontic treatment brace 5 orthodontics north orthodontics for good measure Check more urlhttpcos258comforumphpmodviewthreadtid11754pid943696page38extrapid943696Best CuanSlot88 Guideurl 59a7057

Login or Sign Up to post comments on this tutorial.