Close
0%
0%

Embedded Serial Buses

HackadayU course all about serial buses! Part 1 includes I2C and 1-Wire.

Instructors alexanderAlexander
Wednesday, September 30, 2020 08:00 am PDT Local time zone:
Register for thiscourse
Similar projects worth following

Course Overview

Attendees of this course will learn how serial communication works, as well as the most common standardised protocols for serial communication. In Part 1 of this course, we will be covering I2C and 1-Wire. Hardware is not required to succeed with this course, but students are encouraged to try out examples and/or play around with the material presented in class. Remember, using skills is what sharpens them!

I2C

I2C is an extremely common serial bus standard developed by Phillips in the 1980s. It is the most common bus used for communicating with sensors and EEPROMs. There is a lot more to the I2C bus than meets the eye. It's a multi-controller, multi-peripheral bus with in-built arbitration and signalling. Extensions to the original standard have allowed for faster transfer speeds and an increased address space. A derived standard called SMBus is widely used on computer motherboards for temperature sensors, fan sensors, and more. We will examine the differences between I2C and SMBus, but the focus of the course will be on I2C.

1-Wire

1-Wire is, as the name suggests, a bi-directional serial protocol that uses only one wire for communication. This single wire can also be used to power the device, meaning a sensor can be powered and communicated with over just 2 wires! The standard only allows for one controller, but a huge number of peripherals. Sensors and EEPROMs are also quite common. The hardware is similar to I2C, which is why these two have been grouped together in Part 1.

Goals of this course

We will be taking a close look at who developed these standards; why they were developed; why they became popular; how they work at multiple layers (hardware, protocol, software); and we will examine common use cases as well as example code. Example libraries will be briefly covered, as well as how to find more information if needed.

After completion of this course, you will be ready to tackle any project that uses these serial bus standards!

Hardware/Software Requirements

Though not necessary, a wide range of hardware can be used to implement the things you learn in this course. Almost any development board will work -- Arduino, BeagleBone, Adafruit Feathers/Trinkets, Teensy, MSP430, PIC32, ESP8266/ESP32. Any microcontroller will do, even those without hardware support for I2C or 1-Wire. This course will be providing sample code for the MSP430F5529 Launchpad, which you can get from Digikey for under $20. Adafruit has an ATMEGA 328p development board for just $12.95 which supports hardware I2C and SPI. It's programmable with Arduino, which makes getting up to speed quite easy. Or, if you want to support other hackers from around the world, Tindie has literally hundreds and hundreds of development boards that you can use! A personal favourite is the Ladybug STM32 Development Board.

Again, I would stress that it's not necessary to complete the course and succeed in using these skills in the future, but practical applications will boost your confidence and sharpen your skills!

Playlist for the Embedded Serial Buses series:
https://www.youtube.com/playlist?list=PL_tws4AXg7atqQzq27o-GFGJWtBsXplTd


SB_Week_4.odp

These are the slides for the fourth week

presentation - 8.49 MB - 10/01/2020 at 22:20

Download

completedVersion.zip

A zipped version of the more or less final version of the codebase

Zip Archive - 1.80 MB - 09/28/2020 at 01:13

Download

SB_Week_3.odp

Slides for week 3!

presentation - 481.43 kB - 09/24/2020 at 23:21

Download

sht21_polling_for_data.sr

PulseView file for the week 2 SHT21 transaction example

session - 2.38 kB - 09/13/2020 at 17:34

Download

i2c_eeprom_example.sr

PulseView file for the week 1 I2C EEPROM example

session - 5.48 kB - 09/13/2020 at 17:34

Download

View all 7 files

  • Update for SHT31 Users!

    Alexander09/19/2020 at 21:25 0 comments

    The suggested sensor add-on board for this course actually uses a different command set to the SHT21 and SHT11 (my bad, I shouldn't have assumed).

    So, there is a new branch on the Git repo called "sht31" that contains example code for use with the SHT31. I don't have an SHT31 handy to test with, so if you find any bugs, feel free to submit pull requests, or just file it as an issue and I will fix it!


    Apologies to those who were wondering why the code wasn't working - this is all on me.

  • Class 1: Intro to I2C

    Alexander09/30/2020 at 12:45 0 comments

    Class 1 video: 

    For the first week of the course, we look at the basics of I2C. Starting at how it works at the hardware level, and working up through the protocol level, this first class should get you up to speed on how I2C devices are connected together, and how they signal each other.

    An understanding of circuit diagrams and how transistors work is helpful, but not necessary. At the end of this video, you'll be ready for the next video. Make sure you have Code Composer Studio installed, and your MSP430F5529 Launchpad ready!

  • Class 2: I2C Implementation on MSP430

    Alexander09/30/2020 at 12:48 0 comments

    Class 2 video: 

    In the second week of this course, we dive deep into how microcontrollers implement the I2C protocol. Using the MSP430F5529 as an example, we take a look at how I2C registers are organized, and what procedures you need to go through to get I2C communication working. For this example, we look at the SHT21 temperature and humidity sensor. Code is also provided for the SHT31 in the git repository.

    One of the most important skills that I hope you develop is the ability to use and read datasheets. More important than memorizing information is knowing where to look for it. To this end, we look at the real documents used to create the example code, and I explain what to look for in datasheets from other manufacturers.

  • Class 3: 1-Wire

    Alexander09/30/2020 at 12:51 0 comments

    Class 3 video: 

    In this video, we examine 1-Wire from start to finish. It's a very simple protocol, and it shares many features with I2C. We look at the hardware, protocol and software levels in this week's video. We look at an example implementation via bit-banging of GPIO, and communication with a DS2401 Silicon Serial Number. Similarities and differences from I2C are examined. Again, examples are created on the MSP430F5529.

    Example code is available at the git repo as well. Adapting this code to other 1-Wire devices should be quite trivial.

  • Class 4: Bringing it All Together

    Alexander09/30/2020 at 12:53 0 comments

    Class 4 video: 

    In the final week of this course, we look at an example project which uses the code from the previous weeks to communicate with additional sensors, and display the data on an I2C-enabled character LCD. We also take a look at how important logic analyzers are when working with serial buses. At the end of the video, a short quiz of 9 questions is offered to self-evaluate how much you learned from this course!

    Any questions, as always, can be left in the comments on this course page, or asked in the course chatroom. You are also welcome to email me directly. A big thanks to HackadayU for partnering with me for this course! 

View all 5 course classes

Enjoy this course?

Share

Discussions

Eldridgesongrantt815 wrote 05/29/2022 at 03:13 point

Thanks for sharing such a valuable content and specially video lecture. As i helped me alot and I also share the link with the team members of https://geouniversalremotecodes.com/rca-universal-remote-codes/ so that they could also lean something new from it. Really appreciate your efforts.

  Are you sure? yes | no

kirby.james wrote 09/18/2020 at 10:40 point

Hi Alexander, Are the C++ source files available for Lesson 2? ta Kirby

  Are you sure? yes | no

Alexander wrote 09/20/2020 at 04:16 point

Yes they are, at https://gitlab.com/FrozenElectronics/SerialBusesHackadayU
The example code for week 2 is in the sht21 or sht31 branches, depending on which version of the sensor you got.

  Are you sure? yes | no

Alexander wrote 09/18/2020 at 00:17 point

If you have any questions at all, please post them here so everyone can see the questions and answers!

  Are you sure? yes | no

Does this project spark your interest?

Become a member to follow this project and never miss any updates