Lab 6: The Internet of Things and Serial Peripheral Interface

Introduction

In this lab, we were tasked to write an SPI library that would read from temperature sensor DS1722 and dislay the reading in celsius on an HTML website provided in the starter code. From this websitee we are also to control an LED, with buttons turning it on and off

Design

To begin, first I made sure our HTML website worked beacuse it was already included with the starter code. Running it barebones while commenting out anything SPI related, the website worked and the LED state was changed. Now comes the implementation. From the datasheet, we can see our Microcontroller has 3 SPIs we can use. I decided to use SPI1 because it seemed straight forward and did not have any pin clashing with USART. When setting it up, I decided to set the BR to 0’111 or 80MHz / 2^8, this is to make sure things were running smoothly. As for the resolution for DS1722, I set it to 10 Bit, reason being that I felt that 2 decimal points is all I needed.

Technical Documentation:

The source code can be found here: LAB6

Schematic

The following schematic is my wiring for this lab Figure1

Conclusion

It was a struggle getting everything set up. I constently read the data sheet to make sure I did not miss a step. Things did ended up working perfectly. This lab took me about 16 hrs.

AI Prototype Summary

Now…the AI prototype. Under the first prompt, it gave me an html file. It wanted me to plug it directly into an existing HTML file but our USART doesn’t take it in. I say this mainly due to the fact it had the settings for the website too.

Now for the second prompt, it gave me a complete c file. It also performs configurations, but does not touch any of the NSS settings. The reason why this doesn’t work though is that it assumes DS1722 is inactive at high logic when it is the opposite.