Smart Water Bottle Circuit Documentation
Summary
The Smart Water Bottle circuit is designed to monitor and display various parameters of water, including temperature, water level, and turbidity. The system uses an Arduino UNO microcontroller to read data from a temperature sensor, an ultrasonic sensor, and a turbidity sensor. The readings are then displayed on a 0.96" OLED display.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
Ultrasonic Sensor
- Description: A sensor used to measure distance by using ultrasonic waves.
- Pins: +VCC, Trigger, Echo, GND
Temperature Sensor (TEMP)
- Description: A sensor used to measure temperature.
- Pins: 5V, D3, GND
0.96" OLED Display
- Description: A small OLED display used to show readings.
- Pins: GND, VDD, SCK, SDA
Turbidity Sensor
- Description: A sensor used to measure the turbidity (cloudiness) of water.
- Pins: OUT, VCC, GND
Wiring Details
Arduino UNO
- 5V: Connected to the 5V pin of the Temperature Sensor, VCC pin of the Turbidity Sensor, +VCC pin of the Ultrasonic Sensor, and VDD pin of the OLED Display.
- A0: Connected to the OUT pin of the Turbidity Sensor.
- SCL: Connected to the SCK pin of the OLED Display.
- SDA: Connected to the SDA pin of the OLED Display.
- GND: Connected to the GND pin of the Temperature Sensor, GND pin of the Turbidity Sensor, GND pin of the Ultrasonic Sensor, and GND pin of the OLED Display.
- D8: Connected to the Echo pin of the Ultrasonic Sensor.
- D7: Connected to the Trigger pin of the Ultrasonic Sensor.
- D3: Connected to the D3 pin of the Temperature Sensor.
Ultrasonic Sensor
- +VCC: Connected to the 5V pin of the Arduino UNO.
- Trigger: Connected to the D7 pin of the Arduino UNO.
- Echo: Connected to the D8 pin of the Arduino UNO.
- GND: Connected to the GND pin of the Arduino UNO.
Temperature Sensor (TEMP)
- 5V: Connected to the 5V pin of the Arduino UNO.
- D3: Connected to the D3 pin of the Arduino UNO.
- GND: Connected to the GND pin of the Arduino UNO.
0.96" OLED Display
- GND: Connected to the GND pin of the Arduino UNO.
- VDD: Connected to the 5V pin of the Arduino UNO.
- SCK: Connected to the SCL pin of the Arduino UNO.
- SDA: Connected to the SDA pin of the Arduino UNO.
Turbidity Sensor
- OUT: Connected to the A0 pin of the Arduino UNO.
- VCC: Connected to the 5V pin of the Arduino UNO.
- GND: Connected to the GND pin of the Arduino UNO.
Code Documentation
/*
* Smart Water Bottle
* This Arduino sketch reads data from a temperature sensor, an ultrasonic sensor
* for water level, and a turbidity sensor. It then displays the readings on a
* 0.96" OLED display.
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const int tempPin = 3;
const int trigPin = 7;
const int echoPin = 8;
const int turbidityPin = A0;
void setup() {
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(tempPin, INPUT);
pinMode(turbidityPin, INPUT);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.display();
delay(2000);
display.clearDisplay();
}
void loop() {
float temperature = analogRead(tempPin) * (5.0 / 1023.0) * 100;
float turbidity = analogRead(turbidityPin) * (5.0 / 1023.0);
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration / 2) / 29.1;
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0,0);
display.print("Temp: ");
display.print(temperature);
display.println(" C");
display.print("Water Level: ");
display.print(distance);
display.println(" cm");
display.print("Turbidity: ");
display.print(turbidity);
display.println(" NTU");
display.display();
delay(2000);
}
This code initializes the sensors and the OLED display, reads data from the sensors, and displays the readings on the OLED display. The temperature is read from an analog pin, the water level is measured using the ultrasonic sensor, and the turbidity is read from another analog pin. The readings are updated every 2 seconds.
