CamJam EduKit Sensors Worksheet Three. Equipment Required. The Parts

Similar documents
CamJam EduKit Robotics Worksheet Six Distance Sensor camjam.me/edukit

Soldering Pi2Go Lite. Soldering the Line-Follower PCB

Experimental Procedure

General Electrical Information

Techgirlz Workshop Scratch and Raspberry Pi

Lab 4.4 Arduino Microcontroller, Resistors, and Simple Circuits

TIMER PROJECT KIT ESSENTIAL INFORMATION. Version 2.0 TIME SOMETHING WITH THIS

Temperature Sensor. Positive + (to 5 volts.) Ground. To A0 To GND Signal. To 5v

CMPT Wire Tri-Colour LED and Magnetic Contact Switch

CHAPTER 2. Current and Voltage

ALARM KIT ESSENTIAL INFORMATION. Version 2.0 WHAT CAN YOU PROTECT WITH THIS

Basic Electronics Course Part 1

Quiz Buzzer. Build Instructions. Issue 1.2

Chapter 04 how to control stepper motor using Python

LIGHT ACTIVATED SWITCH

LAB 7. SERIES AND PARALLEL RESISTORS

Lab 4: Robot Assembly

Installation Tips Crimestopper/ProStart Remote Start system + PLJX + DLRM + SPDT (for GM vehicles) T0760 v1.1 updated 2/5/14

LAMBDA SENSOR CONTROLLER

Jitterbug. Project description. Activity 1 Create a Design brief that would best fit this project description

ASSEMBLY INSTRUCTIONS FOR NEW FK109 4 LED Railroad Crossing Flasher Kit WITH ADJUSTABLE FLASHING SPEED CONTROL with 4 Red 3mm Leds

Laboratory 2 Electronics Engineering 1270

EMG SpikerShield v1.2 Instructions

General Purpose Flasher Circuit

MGV (Marshall TM Guv'nor TM Replica) Instructions

DIY Synth Kit - Manual STUTTER SYNTH

White Light CLASSIC PEDAL KIT. Assembly Instructions WHEN YOU CAN T BUY IT BUILD IT. StewMac RARE / VINTAGE / HARD TO GET

Digital Multimeter: This handheld device is used by this course to measure voltage and resistance we will not use this to measure current or capacitan

Build Instructions and User Guide

Online Capacity Tester MK70 User and PC-Software Manual

Wired Real Time GPS Installation Instructions

Tip: LED Lighting Improvements for Rheingold Set Date:

CLASSIC PEDAL KIT. Assembly Instructions WHEN YOU CAN T BUY IT BUILD IT. StewMac Monarch RARE / VINTAGE / HARD TO GET

BehringerMods.com. Instructions for modification of Behringer DCX analog inputs and outputs

These instructions show how to build the Remote Controlled Fart machine Sound Kit.

UltraSmartCharger TM

Assembly Manual for New Control Board 22 June 2018

IDC-136II-KIT 136kHz DC RX Assembly Guide

Assembly Manual for ISDR-136-KIT

DIY Synth Kit - Manual

Installation Manual for the Pantera Ignition Switch Bypass

Chapter 2. Battery Charger and Base Assembly

SOC-Meter Kit Building R9b

SUPERCAPACITOR BASED ENERGY STORAGE MODULE

Instruction of connection and programming of the VECTOR controller

LED PICTURE FRAME KIT

SB-GVS Shield v1.0. ! Ideal for servo & sensor accessories (Phidgets, Seeed Bricks)! Full break-out for all 12 digital lines & 6 analog lines 2

STAY ON TRACK WITH THIS LINE FOLLOW BUGGY WITH :MOVE LINE FOLLOW BOARD FOR BBC MICRO:BIT

Simple Eurorack Row. Kit Builder's Guide. 4mspedals.com

Installation Tips for your Crimestopper/ProStart Remote Start system (add-on for GM vehicles) v1.02 updated 1/16/2013

Installation Motor driven valve

OMEGA KUSTOM INSTRUMENTS

Prototyping Walk through for PIC24HJ32GP202 Startup Schematic

INSTALLATION INSTRUCTIONS THERMOCOUPLE EXPANSION MODULE

2 CHANNEL MULTI-PURPOSE RECEIVER

TIP SHEET T2352, T3396. Installation Tips for RS1 + EVO-ALL 1-BUTTON REMOTE STARTER FOR: Acura RDX PUSH-TO-START / AUTOMATIC

This appendix gives you a general introduction to what electricity is

CARM INTERNATIONAL TOWING MODULES

SUPER CAPACITOR CHARGE CONTROLLER KIT

ECT Display Driver Installation for AP2 Module

ALARM KIT TEACHING RESOURCES. Version 2.0 WHAT CAN YOU PROTECT WITH THIS

PARTS LIST. Beams: 72x. 16x. 64x. 16x. 12x. 2x Breadboards CYB x TotemDuino 1x LabBoard 1x 30cm 34way Flat Cable 1x Power Supply 12v 1,5A

Installation Tips for your Crimestopper/ProStart Remote Start system (for GM vehicles) v1.01 updated 2/27/2012

TIMED NIGHT LIGHT KIT

Building an Electric Circuit to Convert the Sensor Resistance into a Usable Voltage INSTRUCTIONS

Exhaust Alert Installation & Operating Instructions THE SCIENCE OF SILENCE. Exhaust Alert Operating & Fitting Instructions 1

DARK ACTIVATED COLOUR CHANGING NIGHT LIGHT KIT

Application Note. Walthers/Proto 2000 E7A Tsunami Digital Sound Decoder Installation Notes

INDEX 1 Introduction 2- Software installation 3 Open the program 4 General - F2 5 Configuration - F3 6 - Calibration - F5 7 Model - F6 8 - Map - F7

Build Manual. for Studying Electrical Conductivity using a 3D Printed 4-Point Probe Station

An Arduino Based. Motorised Pool Cover. Controller

Prototyping and Soldering Kit UK

The next step is to determine your signal wire from each 02 sensor. This again will be identified in your repair manual wiring diagram.

Idle Timer Controller - A-ITC520-A Ford E Series Ford F250 - F Ford F250 - F550 (*B-ITC520-A) F650/F750

CCL LLC 88 Black Falcon Ave., Ste. 247, Boston, MA USA Contact: Antea Risso

Micro USB Lamp Kit ESSENTIAL INFORMATION. Version 2.1 DESIGN A STYLISH LAMP WITH THIS

QRPGuys Digital RF Probe

C capacitance, 91 capacitors, codes for, 283 coupling, polarized and nonpolarized,

Adding an LED indicator to the X10-WS467 wall switch Credit: Bruce Stydnicki

Step 1 Wiring your remote start. Installation Tips for your Remote Start system (for GM vehicles) V3.3 revised 9/12/2013

Uno Compatible Pogobed Kit

LED Flasher. R1 R2 100 F + C1 100 F +

To be taken together with Paper 1 in one session of 2 hours 45 minutes.

COMPONENT WORK SAMPLE 15 Electrical Circuitry & Print Reading MAINTENANCE MANUAL

Reading on meter (set to ohms) when the leads are NOT touching

Installation Instructions for the Plug & Play Chrysler/Dodge/Jeep Remote Start Package w/mux T5

BUMP AND SPIN KIT ESSENTIAL INFORMATION. Version 1.0 PROGRAM AND DESIGN YOUR OWN BUGGY WITH THIS

K Wiring and Electronics

BAPI-Stat 4 Room Humidity Sensor (BA/ B4 -H200 Series)

Bachmann Digital Sound Decoder Installation Notes

ThePiHut.com/motozero

V=I R P=V I P=I 2 R. E=P t V 2 R

Mini EV Prize Solar Car Kit

UNISTEER Performance Products UNIVERSAL HOT ROD ELECTRA-STEER KIT

Tip: - Württemberg Era 1 Open Platform Cars LED Lighting Upgrade Date: , Photos

Electrical Wiring Practices

A device that measures the current in a circuit. It is always connected in SERIES to the device through which it is measuring current.

Lab Electronics Reference: Tips, Techniques, and Generally Useful Information for the Labs

Upgrade v3 to v3.2. SeeMeCNC Guides. Upgrade v3 to v3.2. Rostock Max v3 Uprgade to v3.2. Written By: SeeMeCNC seemecnc.dozuki.

Step #1 From your spool of 18 gauge primary wire, cut between 11 and 21 three inch strips of wire. You will only need 11 for the ROV, but it is good t

Transcription:

CamJam EduKit Sensors Worksheet Three Project Temperature Sensor Description In this project, you will learn how to use a temperature sensor. NOTE: This worksheet can used on all Raspberry Pi Models. The first 26 pins on the 40Pin Pi s (when looking at the Pi with the pins in the top left) are exactly the same as the 26 pin Pi s. Equipment Required Raspberry Pi & SD card Power supply 1 x 4.7k Ω resistor Keyboard & Mouse 400 Point Breadboard 3 x m/f jumper wires Monitor & HDMI Cable Temperature Sensor (DS18B20) 3 x m/m jumper wire The Parts In this circuit you will be connecting a temperature sensor to the GPIO header of your Raspberry Pi and using Python to measure the temperature where you put the sensor. The sensor supplied in this kit is on the end of a long wire and is waterproof, which will allow you to easily measure the temperature of the room, outside a window, or even a cup of water. Remember that electronics and water do not mix well, so keep the water away from the rest of the kit and the Raspberry Pi! Before you build the circuit, look at the additional parts you are going to use. The Temperature Sensor The sensor supplied in the kit is a Dallas DS18B20 sealed into a metal tube and extended with wires, and looks like the photo on the left. The sensor inside the tube looks like the device on the right. The sensor has a 1-wire serial interface, which means that it sends digital messages through its output pin to the Raspberry Pi. The Pi reads these messages and puts them in a device file, which is like a text file. You can read this file just as you would any other text file, although you cannot edit it. When the Raspberry Pi has received a good message from the sensor, two lines will appear in the device file. The first one will end in YES, and the second one will end in a t=xxxxx, where xxxxx is the temperature in 1/1000 th of a degree Celsius. For example: a3 01 4b 46 7f ff 0e 10 d8 : crc=d8 YES a3 01 4b 46 7f ff 0e 10 d8 t=32768 Which means that the temperature is 32.8 C. Rev 2.0 Page 1 of 5 March 07, 2015

The Parts The sensor has three wires (or legs); the black one is ground (GND), the red one for the power supply (3.3v) and a white or yellow one is the output from the sensor. They may come unstripped or with very short wires. Strip off about 5mm of the coloured plastic to expose the wire, and twist those wires together. If you are confident with a soldering iron, you may want to coat the wires with solder to make them easier to insert onto the breadboard. Alternatively, you could solder small (10mm) lengths of solid wire onto the sensor s wires. You may also need to strip off some of the black outer cover to lengthen the smaller wires. The Resistor The additional resistor used in this circuit is the 4.7kΩ (or 4700Ω) resistor. You can identify the 4.7kΩ resistor by the colour bands along the body. There will be either four or five colour bands on the resistor: If there are four bands, the colours will be Yellow, Purple, Red, and then Gold. If there are five bands, the colours will be Yellow, Purple, Black, Brown, Brown. The resistor is used as a 'pull-up' for the data-line, and is required to keep the data transfer stable by supplying power to the signal circuit. Building the Circuit Before building this circuit, you must turn the Raspberry Pi off. You should leave the LED and buzzer circuit connected on the breadboard, and add this new circuit to the other end. The circuit will be using another ground (GND) pin to act like the negative or 0 volt ends of a battery. One of the pins marked 3v3 will provide the power for the sensor. 3v3 means that it is a 3.3 volt power supply. Use two female to male jumper wires to connect the GND and 3v3 GPIO pins to the bottom two rows of holes on the breadboard. Match up the colours marked on the breadboard - red and blue - with the jumper wires from the Pi connect 3v3 to the red row, and GND to the blue row. These two rails (as they are known) will provide the ground and power supply for the whole of the breadboard. Connect the temperature sensor as shown, with a male/male jumper wire going to the Rev 2.0 Page 2 of 5 March 07, 2015

Building the Circuit bottom rail attached to the Pi s ground (GND). Connect the red wire using a jumper to the 3v3 rail at the bottom. This supplies the temperature sensor with its power. If you have problems pressing the wire strands into the breadboard holes, use the leg of a resistor or jumper to guide them into place. The yellow lead goes into a column with one end of the 4.7k Ω resistor and another jumper wire (shown in yellow) that goes to GPIO pin 4. The program will read the temperature from this pin. The other end of the resistor should be inserted into another column of the breadboard, between the red lead of the temperature sensor and the jumper wire connected to the 3v3 rail. Now it is time to write the code: Code 1. Change directory to the directory we created in Worksheet One using: cd ~/EduKitSensors/ 2. Create a new text file 3-temperature.py by typing the following: nano 3-temperature.py 3. Type in the following code: # Import Libraries import os import glob import time # Initialize the GPIO Pins os.system('modprobe w1-gpio') # Turns on the GPIO module os.system('modprobe w1-therm') # Turns on the Temperature module # Finds the correct device file that holds the temperature data base_dir = '/sys/bus/w1/devices/' device_folder = glob.glob(base_dir + '28*')[0] device_file = device_folder + '/w1_slave' # A function that reads the sensors data def read_temp_raw(): f = open(device_file, 'r') # Opens the temperature device file lines = f.readlines() # Returns the text f.close() return lines # Convert the value of the sensor into a temperature def read_temp(): lines = read_temp_raw() # Read the temperature 'device file' # While the first line does not contain 'YES', wait for 0.2s Rev 2.0 Page 3 of 5 March 07, 2015

Code # and then read the device file again. while lines[0].strip()[-3:]!= 'YES': time.sleep(0.2) lines = read_temp_raw() # Look for the position of the '=' in the second line of the # device file. equals_pos = lines[1].find('t=') # If the '=' is found, convert the rest of the line after the # '=' into degrees Celsius, then degrees Fahrenheit if equals_pos!= -1: temp_string = lines[1][equals_pos+2:] temp_c = float(temp_string) / 1000.0 temp_f = temp_c * 9.0 / 5.0 + 32.0 return temp_c, temp_f # Print out the temperature until the program is stopped. while True: print(read_temp()) time.sleep(1) Once complete use Ctrl + x then y then enter to save the file. Running the Code To run this code type: sudo python 3-temperature.py The temperature readings will be printed out until the program is stopped (by pressing Ctrl+C). Challenge One Measure the temperature of a glass of cold water by putting the silver end of the temperature probe into a glass of water. Try this again with a glass of hot water, and watch the temperature change as it cools down (maybe by adding in cold water). Rev 2.0 Page 4 of 5 March 07, 2015

Challenge Two Alter the code to light the LEDs and sound the buzzer under the following conditions: Light the blue LED when the temperature is near 0 C - the sensor is accurate to 0.5 C, so light the blue LED when the temperature is at or below 0.5 C. Light the red LED when the temperature is above 50 C. Sound the buzzer when the temperature is above 75 C. Rev 2.0 Page 5 of 5 March 07, 2015