You are on page 1of 2

COM T3, I2C_SPI assignment

Not all the parts below are required.


You can skip the “Optional” parts if you don’t have enough time.

Part 1
Put the X-NUCLEO-IKS01A3 shield from your Hardware Kit on the RedBoard (or Arduino, or Nucleo).
Access the Temperature sensor STTS751:
 Check out what the I2C address of this sensor is; you can find it on the schematic of the X-
NUCLEO-IKS01A3, see https://www.st.com/resource/en/schematic_pack/x-nucleo-
iks01a3_schematic.pdf.
 Read the high and low byte of the temperature. Check out how the STTS751 works in this
specification: https://www.st.com/resource/en/datasheet/stts751.pdf.
Read especially pages 13 and 14.
 Convert those into the correct float value.
As an example: if the high byte of the temperature is 0b00010101, and the low byte is
0b11000000, then the float value is 21.75 (16+4+1 for the integer part, and ½ + ¼ for the
fractional part).
 Send that float value to the PC, and show it in PuTTY, or in the Serial Monitor. You can use
the Serial library.

Do not use a dedicated X-NUCLEO-IKS01A3 library, but access the Temperature sensor directly.
On Arduino/Redboard, do this by using the Wire class.

Some remarks about the Wire class:


 Read this description carefully: https://www.arduino.cc/en/reference/wire.
Be aware of the “Note” on that page.
 Way of working:
o Join bus as Master or Slave: begin
o Master Writing: beginTransmission  *(write)  endTransmission
o Master Reading: requestFrom  *(available  read)
o Slave Writing: in onRequest: *(write)
o Slave Reading: in onReceive: *(available  read)

Part 2 (Optional)
Choose another sensor from the X-NUCLEO-IKS01A3, find its specification, and show data from that
sensor also in readable form on the PC.

Part 3
Connect also the Sparkfun Qwiic Joystick module (also in your Hardware Kit) to the Sparkfun
RedBoard controller using the special Qwiic cable in your HW Kit. You can also connect it to the I2C
lines of an Arduino or Nucleo, but then you have to solder the lines.
The technical description of the Sparkfun Qwiic Joystick can be found here:
https://learn.sparkfun.com/tutorials/qwiic-joystick-hookup-guide?
_ga=2.71618320.286045724.1599660497-229224066.1599660497.
Do the steps below, again without using a dedicated library, but by accessing the device directly
through I2C.
 Firstly: read the horizontal/vertical positions of the joystick, and show that on the PC
 Secondly: make it such that the Arduino/Redboard/Nucleo reads the input from the joystick,
and, depending on that input, shows certain values from the X-NUCLEO-IKS01A3.
For example: if the joystick is moved to the left, show the temperature; if it is moved to the
right, show the data from the other sensor that you implemented in part 2.
 Add more functionality as you like.

Part 4 (Optional)
The Sparkfun Qwiic Joystick has a predefined I2C address, that you used above in Part 3.
Change that I2C address into something else. Read the technical description of the Sparkfun Qwiic
Joystick to find out how to do that.
Warning: be careful doing this, because when you change the I2C address into something unknown,
you will have some trouble finding out what the new address is (you basically have to scan all
addresses then).

Part 5 (Optional)
Make a C# (or C or C++) program on the PC that graphically shows the position of the joystick as a
dot inside a square.

Part 6
Connect a second controller (another Arduino/Nucleo) to the first one as an SPI Slave. The first
controller obviously has to be SPI Master.
Make it such that you can switch on or off the LED on the second (Slave) controller from the PC.
For example: pressing the ‘a’ key on the PC, sends this to the first controller through the Serial
connection, and that one sends it on to the second controller through SPI, which then switches on its
LED.
Pressing ‘b’ on the PC must switch the LED on the Slave off.
You can make something else if you want, as long as it uses SPI in a comparable way.

You might want to look at this example to get started, especially for to see how an SPI Slave can be
programmed: http://www.gammon.com.au/spi

You might also like