In this project, I used the DS18B20 Temperature Sensor to read temperature in Fahrenheit.
Project Goals
Correctly connect the sensor to the Red Board
Write a program to read temperature from the sensor
Print the temperature value in degrees Fahrenheit
Why?
This was my first Arduino project! Because of that, this project was primarily meant to teach me the basics of wiring and embedded development.
Before connecting the component to the Red Board, I had to determine how it worked. The three connections at the bottom of the component were labelled "G", "R", and "Y", which were unfamiliar symbols to me in this context. I did some quick research, and found out that they represented Ground, Voltage, and Signal. After that, I was able to correctly connect the component to the Red Board.
Because the component only has three connections, the wiring was straightforward. I connected "G" to a GND pin, "R" to the 5V pin, and "Y" to pin 2. The image on the left is a wiring diagram for the component.
After connecting the component, I had to write a program to read temperature from it. I used the code for the component from the FYELIC GitHub page, making minor adjustments to get/print the temperature in Fahrenheit rather than Celsius.
The program is pictured on the right. It relies on libraries from the manufacturer, which contain a "getTempFByIndex()" function that returns the component's temperature reading in Fahrenheit. Because there was only one sensor in my circuit, the index parameter in my program was "0".
Because the project's wiring was simple and most of the programming was handled in the manufacturer's libraries, I only made two iterations. The first iteration used code taken directly from FYELIC's GitHub page, which read temperature in Celsius and printed temperature in a different format. The second (and final) iteration obtained temperature in Fahrenheit and printed it in the "Temperature: (temperature) °F" format. Everything worked as I expected it to in both iterations, so I didn't have to iterate further. Because of that, I didn't really have any problems with the wiring/programming aspect of the project.
Despite this, I did have problems at the very beginning of the project when I was trying to determine the name of the component. I needed to do this so I could find information on how to use/implement the component. This was particularly hard because there was no name or manufacturer listed on the component itself, so I had to start with features I could observe on the component and narrow things down from there. Additionally, searches for the component name (DS18B20) returned images of a device that looked very different to the one I had, so I didn't even realize I had found the correct name for a while. I eventually found the component's name and matched it to a folder in the FYELIC GitHub, but it took 20-30 minutes of searching to find it. I don't think it was wasted time though, since it was good practice for my searching skills.