|
ATTINY85-20SUMICROCHIP
|
x 1 | |
|
TIP31onsemi
|
x 2 | |
|
TIP32onsemi / Fairchild
|
x 2 | |
|
CPS-4013-110TCUI DEVICES
|
x 1 | |
|
2N2222ABLUE ROCKET(蓝箭)
|
x 3 |
|
arduino IDEArduino
|
|
|
Proteus 8 |
|
|
blender2.82blender
|
|
|
3d buildermicrosoft corporation
|
|
|
TinkerCad |
EGYsmart touch sensor smart faucet device.
Project name : EGYsmart touch sensor smart faucet device.
Introduction :
First I saw xiaomi smart faucet device on internet. it was pretty impressive for me , that I wanted to perform the same technology on my own.
hoping to achieve a similar reliable, beautiful and environmentally friendly technology, that would be a very good in demand product for people in Egypt.
Working principle : capacitive touch sensor-dependent smart faucet device, with programmable IC (attiny85) , bistable 9v solenoid valve.
uses and advantages :
1- water saving device.
2- less germs transmission.
3- low consumption of electricity (on-battery application).
4- beautiful decoration for faucets.
5- using technology to introduce welfare into our daily life.
Mechanical Engineering and graphics :
9v bistable solenoid valve making principle : replacing 220v 60mA coil by 9v 2000mA one.
inserting a small permanent magnet inside the solenoid valve.(turns on by an electric impulse and off by an electric impulse in the other current direction).
enclosure :
many trials were done to achieve the most reliable and beautiful design.
with the addition of a tap filter for a smooth water flow, as in the figure.
Electrical Engineering :
schematic view: I just prefer paper and pencil design.
H-bridge : used for changing direction of current applied on the solenoid valve.
components : 2 tip31(npn) transistor, 2 tip32(pnp) transistor, 2 2n2222 transistors, resistors and 4 protective diodes.
Low battery charge detector buzzer .
IC power is delivered through 2.2 kohm resistor.
Software Engineering :
direct mode : if the touch sensor is touched , the solenoid valve is turned on (water is turned on) through an electric impulse , then is turned off through an electric impulse in the other current direction after 3 seconds of nontouching.
toggle mode : if the sensor is touched for 3 seconds continously, it turns on the toggle mode , that the solenoid valve is turned on for a longer time , then turned off again by touching the sensor for 1 second continuously, or by auto switch off when turned on for 60 seconds.
detecting battery voltage : done through readVcc() function , then multiplying the result by a constant multiplier giving the battery voltage.
battery saver : done through applying sleep mode, with watchdog timer interrupts every 1 second in order to wake up the IC during usage.
software programs used :
1-Arduino IDE
2- blender2.82
3- 3d builder
4- proteus8
5- tinkercad simulation
Hardware components:
1- IC attiny85
2- 9v solenoid valve
3- transistor tip31
4- transistor tip32
5- low charge indicator buzzer
6- 9v battery
versions : 1- infrared sensor wooden device with 12v adapter.
2- infrared sensor device in a purchased plastic container with 12v adapter.
3- infrared sensor device in a 3d printed plastic container with 12v adapter.
4- transistor-dependent touch sensor device in a 3d printed plastic container with 12v adapter.
5- IC dependent capacitive touch sensor device in a 3d printed plastic container with 12v 18650 protected battery.
6- IC dependent capacitive touch sensor device in a 3d printed plastic container with 9v rechargeable battery and bistable solenoid valve.
problems , difficulties and their solutions :
1- in Egyptian homes we don't use environmentally isolated rooms , so sun infrared rays interfere with my IR sensor leading to errors .
I tried many solutions in order to isolate sun rays , and they comparatively worked , but I had another effictive problem with IR sensor , that it consumes high energy and that would consume the battery fast.
so , I replaced the IR sensor with a nice , practical and less consuming touch sensor.
2-touching the signal end with my other hand touching another metal results in (earthing), that the other metal attracts the charge and prevents hand effect on the sensor, causing the device not to work.
so , I isolated the touching signal end in order to prevent earthing from happenning , but this introduced another small problem , that the sensitivity of the sensor is reduced , causing the device to take a relatively longer time to work.
in order to solve this new problem , I put another metal around the isolating plate , so that increasing the surface of charge surrounding the signal end . and I am pleased that it works perfectly.
3- purchased containers such as woody or plastic ones have many problems such as : water leakage to inside , large size , heavy weight and inappropriate application.
so , I had to learn 3d design modeling in order to make my own appropriate design for my device , and that is what I did .
I learned using blender program , and I achieved a reliable , beautiful and stylish design.
I also used 3d builder program to check and repair small errors in my design before 3d printing.
4- high consumption of normally closed solenoid valve.
I managed to involve a small permanent magnet inside the solenoid valve , so that I can turn on the solenoid valve with just a small electric impulse , and turn it off with a small electric impulse in the opposte direction of electric current.
thus converting the purchased 220v normally closed solenoid valve into a 9v bistable latching solenoid valve.
and that's because I couldn't purchase a latching solenoid valve , since it doesn't exist in Egypt and I couldn't import it.
5 - attiny85 consumes around 1.5 mA per hour , making it difficult to use a battery in the project.
solving this problem could be achieved by adding SLEEP_MODE into my code with involving watchdog timer interrupts in order to wake up the IC during usage.
with sleep mode , the consumption is reduced during unuse, reaching around 5 micro amperes / hour , and that's considerably low.
#include <CapacitiveSensor.h>
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>
int pulse = 30; // delay value of solenoid-on state
int toggle = 0;
long direct = 0;
long toggle1 = 0;
long cutToggle = 0;
int mx = 20;
int v = 0;
long volt = 0;
long vcc = 0;
int x = 0 ;
int rst = 0;
int b = 1;
int z = 0;
int y = 0;
long counter = 0;
int q = 0; // prevents buzzing after resetting
byte saveADCSRA; // variable to save the content of the ADC for later. if needed.
CapacitiveSensor sensor = CapacitiveSensor(2, 0);
void setup() {
// put your setup code here, to run once:
pinMode(3 , OUTPUT); // buzzer pin
pinMode(1 , OUTPUT); // water on pin
pinMode(4 , OUTPUT); // water off pin
pinMode(0 , INPUT);
resetWatchDog (); // do this first in case WDog fires
vcc = readVcc();
}
void loop() {
// put your main code here, to run repeatedly:
unsigned long total1 = sensor.capacitiveSensor(10);
volt = vcc * 2.35;
// if (volt > 10000 && volt < 8500) {
// digitalWrite (1 , HIGH);
// }
// if (volt > 10500) {
// digitalWrite (1 , HIGH);
// delay(50);
// digitalWrite (1 , LOW);
// delay(50);
// }
if (total1 >= mx) {
if (y == 0) {
counter = millis();
y = 1;
}
if (millis() - counter >= 1 && y == 1) {
if (x >= 0) {
if (x == 0) {
if (toggle == 0) {
digitalWrite(3 , HIGH);
delay(pulse);
digitalWrite(3 , LOW);
}
toggle1 = millis();
if (toggle == 1 && v == 0) { // manual cut off the toggle mode
cutToggle = millis();
z = 1; // prevent cutting toggle mode instantly
}
rst++;
}
x++;
}
direct = millis();
if (millis() - toggle1 >= 3000 && millis() - toggle1 < 20000 && toggle == 0) { // toggle mode of the touch sensor
toggle = 1;
}
if (millis() - toggle1 > 20000) { // auto reset when touching more than 20 seconds
x = 0;
toggle = 0;
rst = 0;
v = 0;
z = 0;
digitalWrite(4 , HIGH);
delay(pulse);
digitalWrite(4 , LOW);
delay(1000);
}
if (millis() - cutToggle >= 1000 && z == 1) { // cut toggle mode after touching for 1 second
toggle = 0;
x = 0;
z = 0;
digitalWrite(4 , HIGH);
delay(pulse);
digitalWrite(4 , LOW);
delay(1000);
}
v = 1;
y = 0;
}
}
if (total1 < mx) {
y = 0;
toggle1 = millis(); // to enter the toggle mode only when touching continuously for 6 seconds.
if (x == 0 && q == 0) {
sleepNow ();
}
if (millis() - direct >= 3000 && v == 1 && toggle == 0) { // direct mode of the touch sensor.
digitalWrite(4 , HIGH);
delay(pulse);
digitalWrite(4 , LOW);
x = 0;
v = 0;
if (volt < 7000) {
q = 1;
}
}
if (millis() - direct >= 6000 && b == 1 && q == 1 && toggle == 0) {
if (volt < 7000) {
digitalWrite(1, HIGH);
delay(500);
digitalWrite(1, LOW);
}
b = 0;
q = 0;
}
if (millis() - direct >= 60000 && toggle == 1) { // auto reset when turned on for 60 seconds
x = 0;
toggle = 0;
rst = 0;
v = 0;
digitalWrite(4 , HIGH);
delay(pulse);
digitalWrite(4 , LOW);
}
if (toggle == 1) {
v = 0;
x = 0;
}
if (rst >= 5 && x == 0 && toggle == 0) {
toggle = 0;
v = 0;
x = 0 ;
rst = 0;
b = 1;
z = 0;
y = 0;
counter = 0;
q = 0;
}
}
}
void sleepNow ()
{
set_sleep_mode ( SLEEP_MODE_PWR_DOWN ); // set sleep mode Power Down
saveADCSRA = ADCSRA; // save the state of the ADC. We can either restore it or leave it turned off.
ADCSRA = 0; // turn off the ADC
power_all_disable (); // turn power off to ADC, TIMER 1 and 2, Serial Interface
noInterrupts (); // turn off interrupts as a precaution
resetWatchDog (); // reset the WatchDog before beddy bies
sleep_enable (); // allows the system to be commanded to sleep
interrupts (); // turn on interrupts
sleep_cpu (); // send the system to sleep, night night!
sleep_disable (); // after ISR fires, return to here and disable sleep
power_all_enable (); // turn on power to ADC, TIMER1 and 2, Serial Interface
ADCSRA = saveADCSRA; // turn on and restore the ADC if needed. Commented out, not needed.
} // end of sleepNow ()
void resetWatchDog ()
{
MCUSR = 0;
WDTCR = bit ( WDCE ) | bit ( WDE ) | bit ( WDIF ); // allow changes, disable reset, clear existing interrupt
WDTCR = bit ( WDIE ) | bit ( WDP2 ) | bit ( WDP1 ); // set WDIE ( Interrupt only, no Reset ) and 1 second TimeOut
wdt_reset (); // reset WDog to parameters
} // end of resetWatchDog ()
ISR ( WDT_vect )
{
wdt_disable (); // until next time....
} // end of ISR (interrupt service routine)
long readVcc() {
// Read 1.1V reference against AVcc
// set the reference to Vcc and the measurement to the internal 1.1V reference
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
ADMUX = _BV(MUX5) | _BV(MUX0);
#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
ADMUX = _BV(MUX3) | _BV(MUX2);
#else
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#endif
delay(50); // Wait for Vref to settle increased delay by islam
ADCSRA |= _BV(ADSC); // Start conversion
while (bit_is_set(ADCSRA, ADSC)); // measuring
uint8_t low = ADCL; // must read ADCL first - it then locks ADCH
uint8_t high = ADCH; // unlocks both
long result = (high << 8) | low;
result = 1.1 * 1023 * 1000L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
return result; // Vcc in millivolts
}
EGYsmart touch sensor smart faucet device.
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(3)
- Likes(3)
- Umut ucgmka Dec 27,2023
- Engineer Dec 31,2022
- Engineer Dec 31,2022
- 3 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
8design
-
9usability
-
7creativity
-
8content
-
7design
-
8usability
-
9creativity
-
8content
-
10design
-
10usability
-
10creativity
-
10content
More by Islam Lawaty
-
-
Micro Planck - 3D Printable Low Profile Mechanical Keyboard
164 1 0 -
Corazon LED intermitente
54 0 0 -
-