JB's Electronics Club - Project #4

Mission: Combine the principles of Project 1 & Project 2 to create a functioning LED thermometer, where a reading from a temperature sensor circuit will control the illumination of multiple LEDs

How

  1. Build the temperature sensor circuit from Project 1
  2. Build a series of basic LED circuits
  3. Connect the circuits to the Raspberry Pi
  4. Copy/write the code for the temperature sensor circuit into the Pi
  5. Run the code to check the temperature reading of the room

What you will need

  • 4x Male to Male Jumper Cables (Black, Purple, Grey & Brown)
  • 6x Male to Female Jumper Cables (Black, Yellow, Red, Orange, Green, Blue)
  • 1x DS18S20+ Temperature Sensor
  • 1x 4.7K Ohm (4K7) 0.25W Resistor
  • 3x 330 Ohm (330R) 0.25W Resistor
  • 3x LEDs

Part 1: Build the temperature sensor circuit from Project 1

For our thermometer, we need a way to measure the temperature of the environment. This can be done using the same circuit as the temperature sensor from Project 1, but this time we’ll build it across columns 2 to 4, instead of 1 to 2.

1. Install the temperature sensor so the flat part is facing you and all pins are in Row G

  1. Left pin -> Column 2
  2. Middle pin -> Column 3
  3. Right pin -> Column 5

2. Place a 4k7 resistor between Column’s 3 and Column 5 in Row L

3. Connect the black male to male jumper cable between Column 2, Row L and the second hole of the negative power rail

4. Connect the male end of the yellow jumper cable into Column 3, Row K

5. Connect the male end of the red jumper cable, into Column 5, Row K

6. Connect the male end of the black male to female jumper cable, into the first port of the negative power rail

Note: The ports next to the black line without Column/Row numbers are linked. This will be useful for the multiple circuits we need to build during this project

7. Test the sensor, by connecting the red, yellow and black female ends of the cables to the GPIO of the Raspberry Pi, just as you did during the temperature sensor project and running the same code from that project.

8. After verifying the sensor is working, write down the temperature of the room, disconnect the cables from the GPIO of the Raspberry Pi, and move on to Step 2

Part 2: Build a series of basic LED circuits

1. Place the "long leg" of the first LED in Row G, Column 12, and the "short leg" in column 13 of the same row

2. Place a 330 Ohm (330R) resistor across Column 10 & Column 12 of Row K (one leg will be in the same column as the positive side of the LED)

3. Repeat the same process with two more LEDs and Resistors

  1. LED Two – Row G, Column 19 (Long leg) & Column 20 (Short leg)
  2. LED Three – Row G, Column 27 (Long leg) & Column 28 (Short leg)
  3. Resistor Two – Row K, Column 17 & Column 19
  4. Resistor Three – Row K, Column 25 & Column 27

4. Connect Row L, Column 13 to the negative rail with the purple male to male jumper cable

5. Repeat the process, using the grey and brown jumper cables to connect Row L, Column 20 & Row L, Column 28 to the negative rail

6. Insert the male end of the orange male to female jumper cable, into Row L, Column 10

7. Connect the male end of the green male/female jumper cable, into Row L, Column 17

8. Connect the male end of the male/female jumper cable, to Row L, Column 25. You should end up with something like the image below

You have just built three basic LED circuits next to your temperature sensor, that can each be controlled separately.

Part 3: Connect the circuits to the Raspberry Pi

1. Begin by connecting the temperature sensor part of the circuit, just as you did in Part 1 of this guide

2. Connect the orange jumper to GPIO 23 (Next to the Ground connection)

3. Connect the green jumper to GPIO 24 (Next to the orange jumper)

4. Connect the blue jumper to GPIO 25 (One-pin gap from the orange jumper)

Part 4: Copy/write the code for the temperature sensor circuit into the Pi

1. Open Thonny Python IDE

2. Download and copy the code from HERE into Thonny Python IDE

Part 5: Run the code to check the temperature reading of the room

1. Run the code, checking that each LED completes their testing cycle. Each one should turn on and off in a sequence

2. Make a note of the temperature reading and the number of lit LEDs. The LED’s and text output can be controlled by adjusting rules of the IF and ELIF (else/if) sections of the "while True" loop

3. To test the thermometer, ensure that the program will light two LEDs at your current room’s temperature. Then set the program to light up three LEDs when the temperature increases by one degree

4. Try blowing on the sensor to increase the temperature, and see if the third LED lights up!