[Waterproof DS18B20 Sensor Kit Tutorial_2] a BATHING CAT FOR YOUR BATHING
by Juncheng in Living > Life Hacks
422 Views, 0 Favorites, 0 Comments
[Waterproof DS18B20 Sensor Kit Tutorial_2] a BATHING CAT FOR YOUR BATHING
![06.jpg](/proxy/?url=https://content.instructables.com/FGA/WXCI/J63V1545/FGAWXCIJ63V1545.jpg&filename=06.jpg)
I have to admit that taking a bath can greatly help relax. And I prefer hot tubbing, no matter it’s summer or winter season. But that can be annoying when you can not estimate whether the temperature is proper. What's more, I bag most of us need a timer when you enjoy yourselves in the tub.So I decided to deal with such a BATHING COMPANION.The anime character is from RIPNDIP one of my favorite brands.
Material List
# LR44 cell battery(with a case) [for independent power supply]
some PMMA, and some wire
![Screen Shot 2017-08-09 at 10.37.17 PM.png](/proxy/?url=https://content.instructables.com/F5T/E7A5/J63V1BK9/F5TE7A5J63V1BK9.png&filename=Screen Shot 2017-08-09 at 10.37.17 PM.png)
![Screen Shot 2017-08-09 at 5.00.17 PM.png](/proxy/?url=https://content.instructables.com/F9S/M79V/J63V14DH/F9SM79VJ63V14DH.png&filename=Screen Shot 2017-08-09 at 5.00.17 PM.png)
Circuit Logic & Code
![Screen Shot 2017-08-09 at 5.00.23 PM.png](/proxy/?url=https://content.instructables.com/FJJ/Z2SG/J63V14EH/FJJZ2SGJ63V14EH.png&filename=Screen Shot 2017-08-09 at 5.00.23 PM.png)
#include <OneWire.h>
#include <RGBLED.h>
RGBLED myled = RGBLED(9,10,11);
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2
//Temperature chip i/o
OneWire ds(DS18S20_Pin); // on digital pin 2
int ledPin = 9; // Connect LED on pin 9, or use the onboard one
int KEY = 3; // Connect Touch sensor on Digital Pin 3
void setup(){
Serial.begin(9600);
pinMode(ledPin, OUTPUT); // Set ledPin to output mode
pinMode(12, OUTPUT);
pinMode(KEY, INPUT); //Set touch sensor pin to input mode
}
void loop(){
float temperature = getTemp();
Serial.println(temperature);
delay(100); //just here to slow down the output so it is easier to read
if(temperature >= 40) { //Read Touch sensor signal
digitalWrite(12, LOW);
digitalWrite(ledPin, HIGH); // if Touch sensor is HIGH, then turn on
}
else if(digitalRead(KEY)==HIGH){ //start the timer
delay(1800000);
digitalWrite(12, LOW);
digitalWrite(10, HIGH);
delay(60000);
}
else{
digitalWrite(ledPin, LOW); // if Touch sensor is LOW, then turn off the led
}
}
float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius
byte data[12];
byte addr[8];
if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -1000;
}
if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return -1000;
}
if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print("Device is not recognized");
return -1000;
}
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end
byte present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
for (int i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
}
ds.reset_search();
byte MSB = data[1];
byte LSB = data[0];
float tempRead = ((MSB << 8) | LSB); //using two's compliment
float TemperatureSum = tempRead / 16;
return TemperatureSum;
}
Structure
![Screen Shot 2017-08-09 at 5.01.49 PM.png](/proxy/?url=https://content.instructables.com/FZ9/8SAJ/J63V14H2/FZ98SAJJ63V14H2.png&filename=Screen Shot 2017-08-09 at 5.01.49 PM.png)
![Screen Shot 2017-08-09 at 5.01.37 PM.png](/proxy/?url=https://content.instructables.com/FIZ/I23I/J63V14ET/FIZI23IJ63V14ET.png&filename=Screen Shot 2017-08-09 at 5.01.37 PM.png)
![Screen Shot 2017-08-09 at 5.01.56 PM.png](/proxy/?url=https://content.instructables.com/FTY/P65P/J63V14IB/FTYP65PJ63V14IB.png&filename=Screen Shot 2017-08-09 at 5.01.56 PM.png)
I wanted to make it as simple as possible, so I did some laser-cutting stuff.
And then screw on.
Assembling
![Screen Shot 2017-08-09 at 5.02.03 PM.png](/proxy/?url=https://content.instructables.com/FNM/K3A3/J63V14LC/FNMK3A3J63V14LC.png&filename=Screen Shot 2017-08-09 at 5.02.03 PM.png)
Adjust the Screw to Make Sure the Case Can Hold ‘the Cat Tail’
![Screen Shot 2017-08-09 at 5.02.12 PM.png](/proxy/?url=https://content.instructables.com/F3I/TNS7/J63V14MN/F3ITNS7J63V14MN.png&filename=Screen Shot 2017-08-09 at 5.02.12 PM.png)
![Screen Shot 2017-08-09 at 5.02.21 PM.png](/proxy/?url=https://content.instructables.com/FJB/MJMC/J63V14OM/FJBMJMCJ63V14OM.png&filename=Screen Shot 2017-08-09 at 5.02.21 PM.png)