TOP Contributors

  1. MIKROE (2653 codes)
  2. Alcides Ramos (351 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136668 times)
  2. FAT32 Library (69910 times)
  3. Network Ethernet Library (55924 times)
  4. USB Device Library (46251 times)
  5. Network WiFi Library (41882 times)
  6. FT800 Library (41129 times)
  7. GSM click (28973 times)
  8. PID Library (26406 times)
  9. mikroSDK (26346 times)
  10. microSD click (25350 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

I2C 1-Wire click

Rating:

5

Author: MIKROE

Last Updated: 2019-05-29

Package Version: 1.0.0.1

mikroSDK Library: 1.0.0.0

Category: 1-Wire

Downloaded: 5398 times

Followed by: 2 users

License: MIT license  

This example shows ID numbers from Unique ID Click and several Thermo Sensors (DS1820), connected on each channel. If there is no device detected on the channel, warning note is shown on TFT.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "I2C 1-Wire click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "I2C 1-Wire click" changes.

Do you want to report abuse regarding "I2C 1-Wire click".

  • mikroSDK Library 2.0.0.0
  • Comments (0)
DOWNLOAD LINK RELATED COMPILER CONTAINS
mikroBasic PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc

mikroSDK Library Blog

I2C 1-Wire click

I2C 1-Wire click

Front and back view of I2C 1-Wire Click Board designed in mikroBUS form factor.

View full image

Library Description

The library covers all the necessary functions to control I2C OneWire click board. 
Library performs the communication with the device via I2C protocol by writing to registers and by reading from registers.

Key functions:

  • uint8_t i2conewire_setChannel( uint8_t channel ) - Set the channel function.
  • void i2conewire_writeByteOneWire( uint8_t writeData ) - Generic One Wire writes the byte of data function.
  • uint8_t i2conewire_readByteOneWire() - Generic One Wire read the byte of data function.

Examples description

The application is composed of the three sections :

  • System Initialization - Initializes I2C structures and start to write log.
  • Application Initialization - Initialization driver enables - I2C, also write log.
  • Application Task - This is an example which demonstrates the use of I2C OneWire click board. I2C OneWire click communicates with register via I2C protocol by the write to register and read from the register. This example shows ID numbers for any click with OneWire protocol connected on each channel. Results are being sent to the Usart Terminal where you can track their changes. All data logs write on USB uart changes for every 1 sec.
void applicationTask()
{
    stateOfCh = 1;
    i2conewire_softReset();
    Delay_10ms();

    i2conewire_setConfig( _I2CONEWIRE_CONFIG_1WS_HIGH | _I2CONEWIRE_CONFIG_SPU_HIGH | _I2CONEWIRE_CONFIG_APU_LOW );
    Delay_10ms();

    for( cntCh = 0; cntCh < 8; cntCh++ )
    {
        i2conewire_setChannel( cntCh );
        i2conewire_oneWireReset();
        Delay_10ms();

        i2conewire_writeByteOneWire( _I2CONEWIRE_WIRE_COMMAND_READ_ROM );
        Delay_10ms();

        for ( cntVal = 8; cntVal > 0; cntVal-- )
        {
            idCode[ cntVal ] = i2conewire_readByteOneWire();

            if( idCode[ cntVal ] == _I2CONEWIRE_WIRE_RESULT_OK )
            {
                ByteToStr( cntCh, logText );
                ltrim( logText );
                mikrobus_logWrite( " Channel ", _LOG_TEXT );
                mikrobus_logWrite( logText, _LOG_TEXT );
                mikrobus_logWrite( " : No device on the channel! ", _LOG_TEXT );
                Delay_100ms();
                break;
            }
            else if ( stateOfCh )
            {
                ByteToStr( cntCh, logText );
                ltrim( logText );
                mikrobus_logWrite( " Channel ", _LOG_TEXT );
                mikrobus_logWrite( logText, _LOG_TEXT );
                mikrobus_logWrite( " : ID = 0x", _LOG_TEXT );
                stateOfCh = 0;
            }

            ByteToHex( idCode[ cntVal ], logText );
            ltrim( logText );
            mikrobus_logWrite( logText, _LOG_TEXT );
            Delay_100ms();
        }

        mikrobus_logWrite( " ", _LOG_LINE );
        mikrobus_logWrite( "---------------------------------------", _LOG_LINE );
   }
}

Other mikroE Libraries used in the example:

  • I2C
  • UART
  • Conversions

Additional notes and informations

Depending on the development board you are using, you may need USB UART clickUSB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.

ALSO FROM THIS AUTHOR

CAN FD 5 click

0

CAN FD 5 Click is a compact add-on board that contains CAN transceiver that supports both CAN and CAN FD protocols.

[Learn More]

EnOcean 2 click

5

EnOcean 2 click carries the TCM 515Z transceiver, based on the 2.4 GHz IEEE 802.15.4 radio standard. The click is designed to run on a 3.3V power supply. It communicates with the target microcontroller over UART interface.

[Learn More]

Terminal 2 click

0

Terminal 2 Click is an adapter Click board™ used as a mikroBUS™ socket expansion board. It provides an easy and elegant solution for adding the external connection capability to the Click board™, plugged on a mikroBUS™ socket. Featuring two 9-position 2.54mm pitch terminal blocks makes it an easy way to expand the development system's connectivity with the mikroBUS™ socket while keeping the bus free to use with any Click board™.

[Learn More]