FINAL Project02 – The Use of Rainwater

Introduction of OLED I2C Display1891524023223_.pic.jpg

How to connect and program the Geekcreit 0.96 inch 4 pin white I2C OLED module with Arduino. OLED display based on a SSD1306 OLED driver IC.

The display connects to Arduino using only four wires – two for power and two for data, making the wiring very simple. The data connection is I2C (I²C, IIC or Inter-Integrated Circuit). This interface is sometimes called TWI (Two Wire Interface).

Reference from: https://startingelectronics.org/tutorials/arduino/modules/OLED-128×64-I2C-display/

Testing – 1 Display Text on OLED Screen

arduino-oled-connection.jpg

 

 

 

 

Connect the display to UNO board as the image shown.

Before start coding, I need to import two zip libraries for add graphic to the display.

屏幕快照 2018-04-18 04.50.39

 

 

 

1911524023224_.pic_hd.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

After reading the reviews of this module from Amazon, I’ve done some changes to the raw files, and started coding on a sketch template from https://startingelectronics.org/tutorials/arduino/modules/OLED-128×64-I2C-display/

Here’s the code.

屏幕快照 2018-04-18 05.08.50.png

This is how it shows on the display.

1921524025932_.pic_hd.jpg

Testing – 2   Display Sensor Data on the Screen

 2071524097426_.pic_hd.jpg

Add a water level sensor to the circuit on pin A0.

A Flow Chart for Programing

display.png

 

屏幕快照 2018-04-18 05.02.36.png

Then add these code before setup as a intro for the water level sensor.
屏幕快照 2018-04-18 05.03.53.png

 

 

 

Also add these to loop to run the program, so the reading will be taken from pin A0 and displayed on the screen.

 

 

 

Here’s the video show how it works.

https://youtu.be/CXJux2UsGps

And this is the full code for this part.

https://create.arduino.cc/editor/yusu1224/5c4b83ed-bc22-41dd-ab72-c5f25af18e65/preview

Conclusion

As I’ve make the valve and OLED display run perfectly, then I put them into one circuit, and merged the code together.

2061524097424_.pic_hd.jpg

The Full Version Flow Chart

rainwater.png

The full code for this project is here.

https://create.arduino.cc/editor/yusu1224/9c289f2c-b899-421a-b835-d8177f93cb41/preview

Prototype Building

1941524025939_.pic_hd.jpg1951524025944_.pic_hd.jpg1931524025935_.pic_hd.jpg1961524025944_.pic_hd.jpg

Here’s the video for the working prototype.

The model will leak water, so I use finger instead of water to show how it works.

https://youtu.be/wwJpjVUDl_8

 

Reference

 

WEEK 9 Project02 – The Use of Rainwater

How to use water level sensor to control a servo?

1821524016781_.pic_hd.jpg

Aim to fill the toilet tank by rainwater by using the non-contact liquid sensor to control the valve. When the toilet tank is empty, the servo will rotate to open the valve for rainwater filling, and it will rotate back to the original position as closing the valve when the tank is filled up.

Testing – 1  Make the Servo Rotate in Clockwise and Anti-clockwise

屏幕快照 2018-04-18 02.45.22.png

Connect the circuit as above, then upload the “sweep” code for servo testing.

屏幕快照 2018-04-18 00.35.04.png

Video: https://youtu.be/3wqJruDN9Ck

 

Testing – 2   Use Non-contact Liquid Sensor to Control Servo

1861524020247_.pic_hd.jpg

Add a non-contact liquid sensor at the servo testing circuit on digital pin2, then add the sensor sketch to the servo testing code and upload it.

A Flow Chart for Programing

servo.png

Full code: https://create.arduino.cc/editor/yusu1224/fc8f23ac-638f-4465-afb4-f08a8b7fe0a5/preview

屏幕快照 2018-04-18 03.34.07.png

Video: https://youtu.be/9k5xN5Z3_V0

This video shows how it works when it’s attached to the prototype, so the valve will open when there is no water detected from the toilet tank, and it will keep shut if water is detected. ( The model will leak water, so I use finger instead of water to show how it works.)

https://youtu.be/DUDP0mPUfiI

Next Step

I’m going to use a OLED I2C display to read the water level sensor in the rainwater tank for people to monitor the water level change .

WEEK 8 Project02 – The Use of Rainwater

Introduction of Reading Sensor Value on Blynk App

How Blynk Works

Blynk was designed for the Internet of Things. It can control hardware remotely, it can display sensor data, it can store data, vizualize it and do many other cool things.

There are three major components in the platform:

  • Blynk App – allows to you create amazing interfaces for your projects using various widgets we provide.
  • Blynk Server – responsible for all the communications between the smartphone and hardware. You can use our Blynk Cloud or run your private Blynk server locally. It’s open-source, could easily handle thousands of devices and can even be launched on a Raspberry Pi.
  • Blynk Libraries – for all the popular hardware platforms – enable communication with the server and process all the incoming and outcoming commands.

architecture.png

Features

  • Similar API & UI for all supported hardware & devices
  • Connection to the cloud using:
    • WiFi
    • Bluetooth and BLE
    • Ethernet
    • USB (Serial)
    • GSM
  • Set of easy-to-use Widgets
  • Direct pin manipulation with no code writing
  • Easy to integrate and add new functionality using virtual pins
  • History data monitoring via History Graph widget
  • Device-to-Device communication using Bridge Widget
  • Sending emails, tweets, push notifications, etc.

from: http://docs.blynk.cc/

Introduction of Arduino Ethernet Shield W5100

wiznet-ethernet-shield-500x500.jpg

The Arduino Wiznet Ethernet W5100 Shield allows an Arduino board to connect to the internet. It is based on the Wiznet W5100 ethernet chip providing a network (IP) stack capable of both TCP and UDP. The Arduino Ethernet Shield supports up to four simultaneous socket connections. Use the Ethernet library to write sketches which connect to the internet using the shield.

From: http://www.hobbytronics.co.uk/arduino-wiznet-shield

Testing

From the tutorial provided by Blynk website :https://youtu.be/egGs_jSIKbc

I connected the shield to UNO board, and got a sketch example from: https://examples.blynk.cc/?board=Arduino%20Uno&shield=Ethernet%20Shield%20W5100&example=GettingStarted%2FPushData&auth=07f57ca292e749e488934fb0ff6e87f3

1781523589753_.pic_hd.jpg

屏幕快照 2018-04-13 04.08.23.png
4781523556013_.pic_hd.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

However I can get the IP address, but couldn’t connect to the blynk cloud web.

 

 

 

 

 

 

 

 

 

 

 

 

 

Introduction of ESP-01 / ESP8266 Wifi module

As the ethernet shield is not working, I decided to try the small wifi chip to make the Arduino UNO connect to the internet.

ESP-01.jpg

 

The ESP8266 WiFi Module is a self contained SOC with integrated TCP/IP protocol stack that can give any micro controller access to your WiFi network. The ESP8266 is capable of either hosting an application or offloading all Wi-Fi networking functions from another application processor.

 

Testing

I Added an adapter to this module and connect it as below.

1791523591597_.pic_hd.jpg

屏幕快照 2018-04-13 04.54.48.png

I got a sketch example from: https://examples.blynk.cc/?board=Arduino%20Uno&shield=ESP8266%20WiFi%20Shield&example=GettingStarted%2FPushData&auth=07f57ca292e749e488934fb0ff6e87f3

However the network kept showing “not responding”, it doesn’t work as well. Probably because the module wasn’t in the latest firmware, it should be flashed.

Next Step

As reading the sensor on App seems quite difficult to come true, I ‘m planning on reading sensor data on a LCD or OLED display.

 

 

 

 

 

WEEK 7 Project02 – The Use of Rainwater

Introduce Water Level Sensor

NO.1 Testing

15-1.jpg

Water level sensor is a module that can sense the depth of water, whose core part is an amplification circuit composed of a transistor and several comb-shape PCB cables. When placed in water, the comb-shape cable will change its resistance with the depth of the water and convert the depth signal into an electrical signal. With an ADC on the SunFounder Uno board dealing with that signal, we can know the water depth changes.

From: https://www.sunfounder.com/learn/lesson-15-water-level-sensor-rfid-v1-0-for-arduino.html

屏幕快照 2018-04-12 21.13.03.png

Connect the circuit like above. Connect the sensor to A0, and led to pin3.

屏幕快照 2018-04-12 21.14.22.png

Select the AnalogInOutSerial code in Example, and make sure the Output pin is correct.

Reference from: https://www.youtube.com/watch?v=3Qvdl0q9soE

Video:

https://youtu.be/CyA6pyqFk_U

 

NO.2 Non-contact Liquid Level Sensor

SEN0204.jpgSEN0204_adapter.jpg

The non-contact liquid level sensor utilizes advanced signal processing technology by using a powerful chip with high-speed operation capacity to achieve non-contact liquid level detection. No contact with liquid makes the module suitable for hazardous applications such as detecting toxic substances, strong acid, strong alkali and all kinds of liquid in an airtight container under high pressure. There are no special requirements for the liquid or container and the sensor is easy to use and easy to install.
The liquid level sensor is equipped with an interface adapter that makes it compatible with DFRobot “Gravity” interface. There are 4 levels of sensitivity which are set by pressing the SET button.

from: https://www.dfrobot.com/wiki/index.php/Non-contact_Liquid_Level_Sensor_XKC-Y25-T12V_SKU:_SEN0204

Testing

Using the same connection and code as the previous one to test the non-contact liquid sensor.

video:

https://youtu.be/81gTjEkq6CE

Next Step

I’m going to work out how to use water level sensor to control a servo for valve opening and closing, also have a look at how to read sensor data on a smart phone App.

WEEK 6 Project02 – The Use of Rainwater

Project Aim

By collecting rainwater for home using to reduce the water consumption and make our lives more sustainable.

Initial Idea

1471521414816_.pic_hd.jpg

To create a smart toilet flushing system by using collected rainwater. When the toilet water tank is empty, the Valve1 will open to let rainwater flush the toilet. If the rainwater tank is empty as well, the Valve2 will open to use city tap water to flush.

Developing Concept

1741523560149_.pic_hd.jpg

Using one water level sensor in toilet tank to control the valve in the rainwater tank for opening and closing, and using smart phone app to observe the volume of the water in the tank by reading the value from the sensor in the rainwater tank.

Component needed:

Arduino UNO Board

Cables

Water Level Sensor x2

Servo

Wifi Shield / Wifi Module / Bluetooth Module

Smart Phone App

 

WEEK 5 Project02 – The Use of Rainwater

20170222_eauxdePluieLinge.png

Introduction

Water consumption is always a big problem for our human in nowadays. How to use water efficiently in our lives should be an important aim for everyone. Therefore it reminds me that we can use rainwater to reduce the pressure of city water supply. Rainwater itself is generally clean, but it can pick up microorganisms, pollutants and debris when it hits the roof. This is why systems for rainwater use inside home often include filtration or other treatments for safety.

Uses for Rainwater

Flushing Toilets

This is another huge water drain. Toilets use almost 27 percent of water in your home. To use collected rainwater instead, try keeping a bucket of it next to your toilet. When you need to flush, pour the rainwater straight into the bowl of the toilet. This will automatically flush your toilet. Make sure your bucket can hold the amount of your toilet’s tank. For instance, if you have a toilet with a 6 gallon (22.7 liter) tank, use at least a 6 gallon bucket of water

Another option is to plumb a pipe for rainwater directly into your house and connect it to your toilet for flushing.

Watering Lawns, Gardens and Houseplants

Rainwater is naturally designed to water plants, and it can easily be used for your indoor and outdoor gardens. You can use rainwater in watering cans to water plants by hand. You can also attach any rainwater storage tanks directly to an automatic irrigation system.

Passive systems to conserve and collect water in your soil are also helpful. Plant garden beds along the edges of your driveway, or at the bottom of a hill, to take advantage of water’s natural movement. Also, try planting a rain garden at the ends of your eavestroughs to catch any excess runoff.

Rinsing Vegetables

Dirty rainwater is great for rinsing vegetables straight from your garden, especially root vegetables. Try filling a large bucket with rainwater, adding some carrots, potatoes, beets or other hard vegetables, and swish them together to knock the soil off.

Washing Vehicles and Equipment

Washing outdoor items is another excellent use for untreated rainwater. Cars, garden tools, lawnmowers, tractors and even the driveway and sides of your house are all perfect candidates.

Reference from:https://www.care2.com/greenliving/10-uses-for-rainwater.html

Rainwater harvesting

Rainwater from roofs and hard surfaces such as car parks can be stored and used in and around properties. The simple rainwater butt, used for garden watering, is a familiar method of storage.

There has been a recent growth in the use of the collected water for a range of non-potable uses, particularly for flushing toilets. Stored water is generally held in a suitably sized underground tank and pumped to the point of use. A mains water supply is usually provided as a back-up if rainwater is not available.

rainwater-harvesting-diagra.jpg

Reference from:https://www.sudswales.com/types/source-control/rainwater-harvesting/

WEEK 4 – Individual Project 01- MusiCake

Project Aim

I’ve done the testing of flame sensor and stepper motor at the previous stage, and the aim for this stage is to run these two components at the same time. The motor, led lights and buzzer will be on when flame is detected, and they will stop when the flame goes out.

Components needed:

Flame sensor

Buzzer

Led lights

Stepper Motor

Cables

 

Circuit Diagram

屏幕快照 2018-02-25 02.17.04.png

I connected the stepper motor to the Digital Pin 8 to ~11, the buzzer to digital pin ~5, the red led light to pin ~6, the green led light to pin 7. And I connect the AO pin of the sensor to pin A2, the DO pin to the pin ~3.

Schematic Diagram

屏幕快照 2018-02-25 02.32.14.png

Task 1 –  How to use flame sensor to control the stepper motor?

Coding

屏幕快照 2018-02-25 20.37.16.png

 

 

 

 

I put stepper motor speed into Setup { } with other component set up.

 

 

 

And, I put the direction of motor rotate under the ” if ( val == HIGH) “, which means if flame is detected by the sensor, the motor will start to run.

 

屏幕快照 2018-02-25 20.25.21.png

 

These code is for birthday song playing by the buzzer.

These code is for birthday song playing by the buzzer.

After upload this code to Arduino, the stepper motor will run when flame is detected, however, the led lights and buzzer only can run after the stepper finish one rotation. Also, the lights and buzzer won’t stop running if the flame goes out already, they only stop until the birthday song is finished. This situation is not what I want.

Please check the video to see the problem.

video: 

Task 2 – How to run stepper motor, led lights and buzzer at the same time when flame is detected?

Final flowchart.png

The flowchart shows the overall structure of the code should be.

As the myStepper.set function is to control a certain number of step, the next instruction cannot be executed before the motor finish one step, so the led lights and buzzer will run afterward.

final code-1.png
final code-2.png

To solve the problem, I set the ” stepsPerRev = 128 ” and the speed = 200.

 

 

Then, I insert ” myStepper.step(stepPerRev) ” after every set of output instruction instead of “delay( )”, so that the motor will run with other components at the same time.

The birthday song has 4 parts, this is a small part of part one.

 

 

 

 

final code-3.pngAlso, I set every 3  tone as a group in every “if(val=HIGH)” loop, which aims to make sure the program will check if there is flame detected after 3 tone produced, so that the program can stop when flame goes out.

 

 

 

The complete code is here.

 

https://create.arduino.cc/editor/yusu1224/bae0e22b-80ec-4158-8d1a-850c17261ad3/preview

Please check the video for final working model.

1351519611514_.pic_hd.jpg

video: 

Reference:

Flame sensor coding reference from: http://arduinosensors.nl/index.php?route=product/product&path=20&product_id=50

 

WEEK 3 – Individual Project 01- MusiCake

Project Brief

This project is to break the common sense about a flame sensor not only can be used on fire alarm but also can be applied to many other creative projects.

1371519614466_.pic_hd.jpg

The idea is about using the flame sensor to control the stepper motor, buzzer and LED lights to build a creative music box which can put a cake on it. The buzzer will play the music when flame is detected, and music stop when flame goes out. And, the motor will start to rotate the cake when flame is detected.

TASK 1 – How to use flame sensor to control a buzzer and a LED light at the same time?

Component:

Flame sensor

LED light

Buzzer

Cables

屏幕快照 2018-02-23 23.18.04.png

I connected the AO pin of the sensor to A0 input pin on UNO board, the LED light goes to Digital ~9, and the buzzer goes to Digital 12.

1281519428683_.pic_hd.jpg

Schematic Diagram

屏幕快照 2018-02-25 02.41.58.png

Flowchart

sensor testing flowchart.png

Coding

Reference from:https://kandrproject.blogspot.co.uk/2018/01/arduino-with-fire-sensor-led-and-buzzer.html

屏幕快照 2018-02-25 05.52.26.png

I tried to add a tone for the buzzer. The “tones[] = (525)” means the buzzer will produce sound in 525Hz.

This is a video I’ve done about how it works.

 

Task 2 – How to drive a stepper motor?

屏幕快照 2018-02-24 00.22.38.png

Connect the stepper motor to the UNO board as above.

1321519433984_.pic_hd.jpg

Coding

屏幕快照 2018-02-24 00.45.16.png

This code I’ve done during the tutorial session is for running the stepper motor.

Video:

WEEK 2 – Individual Research – Flame Sensor

How does flame sensor work?

The flame sensor has both outputs, analog and digital. The analog output gives us a real-time voltage output signal on thermal resistance while the digital output allows us to set a threshold via a potentiometer.  We can use the flame sensor to make an alarm when detecting the fire, for safety purpose in many projects and in many more ways.

Flame Sensor Interfacing with Arduino Using Digital Pin

屏幕快照 2018-02-23 19.40.44.png

First, connect the + and the GND pin of the sensor to the +5V and the GND of the Arduino. Then connect the DO pin to the Digital Pin 2 of the Arduino. Next, I connect the led at the pin 12 of the Arduino. When the sensor will detect a flame, then the led will light up.

1311519431300_.pic_hd.jpg

Code for Flame Detection Using Digital Pin

digital pin.png

Flame Sensor Interfacing with Arduino Using Analog Pin

屏幕快照 2018-02-23 19.58.25.png

When using the analog input of the Arduino. The Arduino will read from the sensor and gives us values from 0 to 1023. The only difference is to connect the AO pin to the Analog Input A0 pin on Arduino.

1301519431296_.pic_hd.jpg

Code for Flame Detection Using Analog Pin

analog pin.png

Reference from:

http://microcontrollerslab.com/flame-sensor-arduino-fire-detection/#Code_for_flame_sensor_arduino

WEEK 1 – Individual Research – Flame Sensor

What is flame sensor?

1251519225524_.pic_hd.jpg

The flame sensor is used to detect the fire or other infra red light which are in the range of wavelength from 760nm to 1100nm. The module consists of an IR sensor, potentiometer, OP-Amp circuitry and a LED indicator. When a flame will be detected, the module will turn on its red led. This module is sensitive to flame but it can also detect ordinary light. The detection point is 60 degrees. The sensitivity of this sensor is adjustable and it also has a stable performance.

 

What does flame sensor have?

sensor intro.jpg

A0: This is the analog pin and this will be connected to the analog input of the Arduino.

G: This is the ground pin and this will be connected to the ground of the Arduino.

+: This is the input voltage pin of the sensor and this will be connected to the +5V of Arduino.

D0: This is the digital pin and this will be connected to the digital input of Arduino

Flame Sensor Circuit Diagram

fdsfassa.png

Circuit diagram Source: http://forum.arduino.cc/index.php?topic=394981.0

The flame sensor module has the following features.

  • The operating voltage is from 3.3 – 5V.
  • It gives us both analog and digital output.
  • It has a led indicator, which indicates that whether the flame is detected or not.
  • The threshold value can be changes by rotating the top of potentiometer.
  • Flame detection distance, lighter flame test can be triggered within 0.8m, if the intensity of flame is high, the detection distance will be increased.
  • The detection angle of the flame sensor module is about 60 degrees.Reference From:http://microcontrollerslab.com/flame-sensor-arduino-fire-detection/#Code_for_flame_sensor_arduino