Table Of ContentMicrocontroller and Smart
River Publishers Series in Communications
Home Networks M
i
c Microcontroller and Smart
r
o
H
c
o o
Home Networks
Dawoud Shenouda Dawoud and Peter Dawoud m n
t
e r
o
Over recent years industries have faced the problem of how to connect devices N l
l
to ‘speak’ to each other with minimum wiring. Philips Semiconductors faced this e e
problem when they needed to connect many ICs together. The Automotive Industry tw r
faced the same problem when it needed to connect tens of microcontrollers in each a
o n Dawoud Shenouda Dawoud and Peter Dawoud
car. Recently, with smart homes, the problem has started to be part of each home. r d
For instance, you may want to build your smart home with accessories from different k
s S
manufacturers and you want the devices to ‘speak’ to each other. Added to that, you
m
may want to control them from a central App or voice assist.
a
Solutions for this problem started with the introduction of Inter Integrated Circuits
r
(IIC) and Controller Area Networks (CAN). Both solutions are wired networks that t
allow ICs and microcontrollers to be connected in a network to communicate together.
In smart home automation, a number of common smart home automation protocols
that allow different devices to speak and communicate together have appeared during
the last few decades. Some of the smart home protocols come under the umbrella of
D
what is called the “Internet of Things (IoT)”. The proposed protocols can be grouped
a
into wired networks e.g. X10, UPB; wireless or radio networks as ZigBee, Z-Wave, w
Bluetooth; or dual (wired and radio) such as Insteon. o
This book introduces to the reader some of the most popular Microcontroller and u
d
Smart home networks. The book covers in detail the following protocols:
P S
∙ I2C e h
∙ 3C te e
n
∙ CAN r o
D
∙ ZigBee u
a d
∙ ZigBee Pro
w a
∙ Z-Wave
o D
∙ Bluetooth u
a
d
Wi-Fi, WiMax and Insteon are part of our companion book “Serial Communication w
Protocols and Standards”. o
This book gives detailed comparisons between the various protocols. To complete u
d
the knowledge of the reader, the book gives in the last chapter a short summary on the
a
protocols that we did not fully cover in this volume: Ethernet, Thread, Insteon, X10
n
and UPB. d
River Publishers River River Publishers
Microcontroller and Smart
Home Networks
RIVER PUBLISHERS SERIES IN COMMUNICATIONS
SeriesEditors:
ABBASJAMALIPOUR MARINARUGGIERI
TheUniversityofSydney UniversityofRomeTorVergata
Australia Italy
JUNSHANZHANG
ArizonaStateUniversity
USA
Indexing: All books published in this series are submitted to the Web of
ScienceBookCitationIndex(BkCI),toSCOPUS,toCrossRefandtoGoogle
Scholarforevaluationandindexing.
The “River Publishers Series in Communications” is a series of comprehen-
sive academic and professional books which focus on communication and
networksystems.Topicsrangefromthetheoryanduseofsystemsinvolving
all terminals, computers, and information processors to wired and wireless
networksandnetworklayouts,protocols,architectures,andimplementations.
Alsocoveredaredevelopmentsstemmingfromnewmarketdemandsinsys-
tems, products, and technologies such as personal communications services,
multimediasystems,enterprisenetworks,andopticalcommunications.
The series includes research monographs, edited volumes, handbooks
andtextbooks,providingprofessionals,researchers,educators,andadvanced
students in the field with an invaluable insight into the latest research and
developments.
Foralistofotherbooksinthisseries,visitwww.riverpublishers.com
Microcontroller and Smart
Home Networks
Dawoud Shenouda Dawoud
InternationalUniversityofEastAfrica
Uganda
Peter Dawoud
Microsoft
USA
River Publishers
Published,soldanddistributedby:
RiverPublishers
Alsbjergvej10
9260Gistrup
Denmark
www.riverpublishers.com
ISBN:978-87-7022-156-6(Hardback)
978-87-7022-155-9(Ebook)
©2020RiverPublishers
Allrightsreserved.Nopartofthispublicationmaybereproduced,storedin
aretrievalsystem,ortransmittedinanyformorbyanymeans,mechanical,
photocopying,recordingorotherwise,withoutpriorwrittenpermissionof
thepublishers.
ToNadia,Dalia,Dina,Bahya,andAdam
D.S.D.
ToDajana
P.D
Contents
Preface xxv
Acknowledgment xxix
ListofFigures xxxi
ListofTables xli
ListofAbbreviations xliii
I Inter-integratedCircuits(IIC) 1
1 Inter-integratedCircuits(IIC/I2C) 3
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.1 I2CRevisions . . . . . . . . . . . . . . . . . . . . 4
1.2 I2CBusTerminology . . . . . . . . . . . . . . . . . . . . . 6
1.3 I2CProtocol . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3.1 TransactionFormat–MessageFormat . . . . . . . 6
1.3.2 TimingDiagram . . . . . . . . . . . . . . . . . . 7
1.4 TheI2CBusHardwareStructure . . . . . . . . . . . . . . . 8
1.4.1 ElectricalConsideration . . . . . . . . . . . . . . 9
1.4.1.1 Typesofdevicesthatcanbeconnectedto
I2Cbus . . . . . . . . . . . . . . . . . . 9
1.4.1.2 Electrical considerations that limits I2C
buslength . . . . . . . . . . . . . . . . 10
1.5 ThePhysicalBus–I2CBusInterface . . . . . . . . . . . . . 13
1.6 SDAandSCLSignals . . . . . . . . . . . . . . . . . . . . 15
1.7 MastersandSlaves . . . . . . . . . . . . . . . . . . . . . . 15
1.7.1 BufferingandMultiplexing . . . . . . . . . . . . . 16
1.8 I2CDataValidity . . . . . . . . . . . . . . . . . . . . . . . 17
1.9 VoltageLevelsandResistorValues . . . . . . . . . . . . . 17
vii
viii Contents
1.10 Start/StopSequence . . . . . . . . . . . . . . . . . . . . . 18
1.11 RepeatedSTARTCondition . . . . . . . . . . . . . . . . . 19
1.12 AddressingStructure . . . . . . . . . . . . . . . . . . . . . 19
1.12.1 7-bitAddressing . . . . . . . . . . . . . . . . . . 19
1.12.2 AcknowledgeScheme . . . . . . . . . . . . . . . 20
1.12.3 I2CAddressesStandard:10-bitAddressing . . . . 22
1.12.3.1 I2C bus transactions in case of 10-bit
address . . . . . . . . . . . . . . . . . . 23
1.12.4 I2C Addresses Standard: Special Addresses and
Exceptionsin7-bitAddressSpace . . . . . . . . . 25
1.12.4.1 Reservedandnone-reservedaddressesin
7-bitaddressspace . . . . . . . . . . . . 25
1.12.4.1.1 Reserved addresses in 7-bit
addressspace . . . . . . . . 25
1.12.4.2 Non-reserved addresses in 7-bit address
space . . . . . . . . . . . . . . . . . . . 30
1.13 I2CBusTransaction . . . . . . . . . . . . . . . . . . . . . 30
1.13.1 I2C Bus Events 1: Master (Transmitter) to Slave
(Receiver)DataTransfer . . . . . . . . . . . . . . 32
1.13.2 I2C Bus Events 2: Slave (Transmitter) to Master
(Receiver)DataTransfer . . . . . . . . . . . . . . 33
1.13.3 I2CBusEvents3:BidirectionalReadandWritein
SameDataTransfer . . . . . . . . . . . . . . . . . 35
1.14 ClockStretching . . . . . . . . . . . . . . . . . . . . . . . 36
1.15 PossibleModificationsontheTimingDiagram . . . . . . . 37
1.16 BusClear . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
1.17 ApplicabilityofI2CBusFeatures . . . . . . . . . . . . . . 39
1.18 I2CModes:BusSpeeds . . . . . . . . . . . . . . . . . . . 39
1.18.1 Low-speedModeorStandardMode . . . . . . . . 40
1.18.2 EnhancedI2C(FastMode) . . . . . . . . . . . . . 40
1.18.3 Fast-modeplus(FM+) . . . . . . . . . . . . . . . 41
1.18.4 High-speedMode(HSmode) . . . . . . . . . . . 42
1.18.4.1 ElectricalcharacteristicsofHSmode . . 42
1.18.4.2 Transmissionformatofhigh-speed
mode . . . . . . . . . . . . . . . . . . . 44
1.18.5 Ultra-fastMode(UFm) . . . . . . . . . . . . . . . 46
1.19 I2CasaMulti-masterBus:BusArbitration . . . . . . . . . 46
1.19.1 Arbitration . . . . . . . . . . . . . . . . . . . . . 47
1.19.2 BusMonitoring . . . . . . . . . . . . . . . . . . . 48
Contents ix
1.19.3 PossibilityofCollision . . . . . . . . . . . . . . . 49
1.19.4 ClockSynchronizationandHandshaking . . . . . 49
1.19.4.1 Clocksynchronization . . . . . . . . . . 49
1.19.4.2 Handshaking: Using the clock synchro-
nizingmechanismasahandshake . . . . 50
1.20 I2CInterface:ConnectingI2CBustoaPC . . . . . . . . . 52
2 DesignofI2CBusandOperation 55
2.1 DesignofI2CBus . . . . . . . . . . . . . . . . . . . . . . 55
2.1.1 Open-drainLines . . . . . . . . . . . . . . . . . . 55
2.1.1.1 Open-drainforBidirectional
Communication . . . . . . . . . . . . . 55
2.1.2 CalculationofthePull-upResistor . . . . . . . . . 57
2.1.2.1 Supplyvoltage(Vcc) . . . . . . . . . . 58
2.1.2.2 Total bus capacitance (C or Cb) and
BUS
Rp(max) . . . . . . . . . . . . . . . . . 59
2.1.2.3 Total high-level input current (I ):
IH
Inputleakage . . . . . . . . . . . . . . . 63
2.1.2.4 Busspeedversuspowerconsumption . . 64
2.1.3 MaximumClockFrequencyofI2CBus . . . . . . 65
2.1.3.1 Using repeaters: Effect of increasing the
numberofdevices–useofrepeaters . . . 65
2.1.3.2 I2Cbuswithoutarepeater . . . . . . . . 65
2.1.3.3 I2Cbuswitharepeater . . . . . . . . . 67
2.1.4 SeriesProtectionResistors . . . . . . . . . . . . . 71
2.1.4.1 Effect of the serial resistance on static
lowlevelofI2Cline . . . . . . . . . . . 71
2.1.4.2 Serialresistanceanddebugging . . . . . 73
2.1.4.3 Terminationversuscapacitance . . . . . 74
2.1.5 Cross Channel Capacitance: Crosstalk between
SDAandSCL . . . . . . . . . . . . . . . . . . . . 74
2.2 OperatingabovetheMaximumAllowableBus
Capacitance . . . . . . . . . . . . . . . . . . . . . . . . . . 76
2.2.1 Reducedf . . . . . . . . . . . . . . . . . . . . 76
SCL
2.2.2 HigherDriveOutputs . . . . . . . . . . . . . . . . 78
2.3 Managing the Delays in Large Systems: Use of Buffers,
Repeaters,MultiplexersandSwitches . . . . . . . . . . . . 80
2.4 BusBuffers,Repeaters,Multiplexers,andSwitches . . . . . 82
2.4.1 UseofBuffers/Repeaters . . . . . . . . . . . . . . 82
2.4.2 UseofMultiplexorsandSwitches . . . . . . . . . 83
2.4.3 SwitchedPull-upCircuit . . . . . . . . . . . . . . 84