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 (136678 times)
  2. FAT32 Library (69913 times)
  3. Network Ethernet Library (55927 times)
  4. USB Device Library (46253 times)
  5. Network WiFi Library (41882 times)
  6. FT800 Library (41133 times)
  7. GSM click (28973 times)
  8. PID Library (26407 times)
  9. mikroSDK (26350 times)
  10. microSD click (25351 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

Current click

0

Current click is an add-on board used for measurement of electric current. It features INA196 current shunt monitor, MCP3201 12-bit ADC, MAX6106 voltage reference as well as two screw terminals.

[Learn More]

ECG click

0

This is an ECG (or EKG) machine on a click board. It measures the electrical activity of a beating heart through electrodes taped to the skin. The board requires little setup, and the final measurement results can be displayed as an Electrocardiogram using a free Windows app.

[Learn More]

ATA6571 click

5

ATA6571 Click is a compact add-on board that contains a transceiver designed for high-speed CAN applications. This board features the ATA6571, a standalone high-speed CAN FD transceiver that interfaces a CAN protocol controller and the physical two-wire CAN bus from Microchip.

[Learn More]