Tutorial 6: One wire temperature sensor and sonar rangefinder


Digital thermometer

The DS18B20 chip is a digital thermometer that provides 9-bit to 12-bit Celsius temperature measurements (and has an alarm function with nonvolatile user-programmable upper and lower trigger points). It can be obtained as a waterproof sealed unit with a 1M lead. The DS18B20 chip is contained in the stainless steel tip, and communicates over a 1-Wire bus that requires only one data line (and ground) for communication with the Arduino. In addition, the DS18B20 can derive power directly from the data line (“parasite power”), eliminating the need for an external power supply. Each DS18B20 has a unique 64-bit serial code, which allows multiple sensors to be placed on the same 1-Wire bus. XOD provides a node in the "common hardware" library that can read single 18DSB20 devices in a circuit.

Download Arduino UNO and Multipurpose Shield pinouts (PDF. 1. MB)

Download Arduino UNO and Multipurpose Shield pinouts (PDF. 1. MB)

DS18B20error.png

The sensor measures temperatures from -55°C to +125°C with better than ±0.5°C Accuracy from -10°C to +85°C (see graph) - the chip is internally calibrated and returns a digital measurement that can be displayed directly. (For more information, see: https://create.arduino.cc/projecthub/TheGadgetBoy/ds18b20-digital-temperature-sensor-and-arduino-9cc806)

Your challenge is to devise and implement in XOD a temperature alarm system using the Arduino prototyping system, DS18B20 sensor, LCD panel readout and buzzer.

DS18B20_XOD.png
DS18B20unit.jpg
How to wire the DS18B20 sensor to an Arduino. (You will be using a waterproof, encapsulated version with connecting wires: red = 5V. black = GND, yellow = DATA)

How to wire the DS18B20 sensor to an Arduino. (You will be using a waterproof, encapsulated version with connecting wires: red = 5V. black = GND, yellow = DATA)

 

Sonar device

XOD contains a node that supports use of an ultrasonic sonar distance sensor, the HC-SR04. For more information about the device, see: (https://components101.com/ultrasonic-sensor-working-pinout-datasheet).

How-ultrasonic-sensor-works.jpg

The ultrasonic transmitter emits an sound waves at 40 000 Hz which travel through the air and if there is an object or obstacle on its path It will bounce back to the module. The module also has a receiver that allows measurement of the travel time. Knowing the speed of the sound allows calculation of the distance. The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The GND and the VCC pins of the module need to be connected to ground and the 5 volts pins on the Arduino board and the trig and echo pins to any Digital I/O pin on the Arduino Board.

There are two XOD nodes that allow calculation of (i) the travel time of for an acoustic pulse (hc-sr04-ultrasonic-time) and (ii) the range of an object in metres (hc-sr04-ultrasonic-range).

Can you use this code to create a theremin-like device, using different forms of input to control the (potentially) tuneful passive buzzer output device?

SonarWiring.jpg
HC-SR04.png
HC-SR04_image.jpg