Smart Water Dispenser

(Project Manager: Bradley Evans; Applications Engineering Interns: Ryan Brooks, Emily Dalton, Fiona Doyle, Gillian Fahey, Amdon Giday, Erik Holmgren, Michael Maxwell, Priscilla Vazquez, and Thomas Wilkinson)


The Water Cooler project began as an innovative idea for exemplifying the abilities of the Cypress and Arrow Quicksilver Board and the Cypress PSoC 5LP. The idea was to build a smart water dispenser that tracks the amount of water remaining in the container , daily water usage, and employee water consumption by day. At fixed time intervals, water level percentages are sent up to the IBM database with associated time stamps so that water levels can be tracked remotely and water refills can be planned accordingly. Additionally, gesture control using CapSense was included for ease of use and controlled water pouring. The goal of this post is to walk through how this demo can be replicated. All code, 3D models, and guides can be found attached to this post.





Water Level Sensor

In designing the water level sensor, the Quicksilver team initially experimented with the CapSense technology and the effects of water and proximity sensing. Our first working model was the water sense strip that could be taped to any bottle and be automatically calibrated. Soon after, we moved to a solution that did not rely on taping a sensor to the bottle, but rather using a spring-loaded hinge to create contact between a solid plate and a fixed water container.


Gesture Control

In designing the gesture control, the Quicksilver team tested the effects of proximity on CapSense sensors and developed algorithms for determining motion of close objects based on calibration techniques and calculated spacing between sensors. The first working version was a 4 directional motion pad that could inform the user of the motion of their gesture in real time. For the water cooler, we moved to a 2 directional solution that could be used for easily turning on and off the water supply.



To start the communication between the Quicksilver and IBM IoT Dashboard, we first connected to ArrrowConnect and posted the data to the ArrowConnect Dashboard. Then, we connected IBM through ArrowConnect to post the water level of the water cooler. Once the IBM account information is uploaded and the devices are provisioned in ArrowConnect, they will populate in IBM automatically.






Cypress PSoC 5LP

The Cypress PSoC CY8C5888LTI-LP097 was programmed using PSoC creator 4.2. The code controlling the PSoC in the water cooler governs the water level sensor, gesture control, valve control, LED control, and UART transmission. All the code is attached to the post.

The key functions in the PSoC include the following:


     >  void wait (uint16 seconds)

          >  Makes user wait for specified time and blinks LED slowly


     >  void waitForSwitch ()

          >  Makes user wait until the BLUE button is pressed and blinks LED quickly


     >  void readInEEPROMValues (uint16 address)

          >  Reads in the previously recorded water level sensor calibration values after the device is reset or restarted.


     >  void writeEEPROMValues (uint16 address)

          >  Writes over the previously recorded water level sensor calibration values so that the device can be unplugged and plugged back in again without losing calibration


     >  void adjustValve (uint8 status)

          >  Opens and closes valve


     >  void updateCapSensors ()

          >  Updates the perceived value of all water level sensors and gesture sensors


     >  void updateWaterFillMonitor ()

          >  Updates the status on the water level


     >  void updateGestureControl ()

          >  Updates the status on the gesture sensor

          >  Note: Since this process requires constant re-calibration to work, gesture control is a polling process rather than an interrupt


     >  void calibrateWaterFillMonitorEmpty ()

          >  Calibrates values for when water container is empty


     >  void calibrateWaterFillMonitorFull ()

          >  Calibrate values for when water container is full


     >  void calibrateWaterSensors ()

          >  Initiates process of calibrating the water level

          >  Includes wait times, empty calibration, and full calibration


     >  void calibrateGestureControl ()

          >  Calibrates gesture control at startup


     >  void recalibrateGestureControl ()

          >  Re-calibrates gesture control whenever perceived gesture values become consistent


Cypress Quicksilver

The Cypress Quicksilver was programmed using WICED Studio 6.2. The code controlling the Quicksilver governs the UART communication, Wi-Fi connection, IBM database data transmission. We used existing ArrowConnect libraries from Arrow's Engineering Solution Center to start posting to IBM and ArrowConnect. To fit the water cooler project, we first change the data structure quicksilver_data telemetry_data to only have a unsigned int8 number called waterLevel. Then, we changed the code to accept UART transmissions. In application_start(), we added a UART initialize and a ring buffer initialize for the UART connection from the PSOC. In the arrow_mqtt_send_telemetry_routine() method, we changed the update_sensor_data to update the ring_buffer with the data coming in and storing it into quicksilver_data telemetry_data. To post onto IBM, we added:

json_append_member(_data, TELEMETRY_UART, json_mknumber(data->waterLevel));

to telemetry.c and we added:

#define TELEMETRY_UART              "f|waterLevel"

to config.h.

All this code is included in the post.



Data Flow

water data.png




Screenshot (32).png






Building the Circuit



>  Soldering bread board

>  1N1004 Diode

>  1K Ohm Resistor

>  TIP120 Transistor

>  5V Regulator

>  Small Heat Sink (x3)

>  10uF Capacitor (x2)









Water Level Sensor, Buttons, and Housing



>  3D Printed Contoured Face

>  Layered Copper Tape

>  3D Printed Backing

>  3D Printed Button Shelf

>  Red and Blue Buttons



>  10 Strips of folded copper tape (about 10 folds each) are glued to the surface of the sensor face. Wires are soldered onto the back of each sensor and are soldered the PSoC board according to the Figure. CapSensor 0 is at the bottom of the sensor face and CapSense 9 is at the top of the sensor face.

     >  Note: There is an 11th sensor spot at the base of the face however it is not being used (see unsoldered hold on the left side of the image.)




The Buttons

>  With each of the buttons assembled inside the button shelf, glue the button shelf to the back with the red LED on bottom and blue led on top.

>  Solder connections so that the GND is connected to both buttons, calibrate is connected to the blue button, and Reset is connected to the red button.

>  Once soldering, the face should snap into place in the backing.



Power Supply



>  12V 2A DC Adapter



>  Cut the ends of the wire, strip, and spread apart

>  Use the wire with dashed lines along it as the 12V source and the other as a GND

>  Feed wire though hole in the back of base and secure with tape so that it cannot get pulled back out




Gesture Sensor



>  Layered Copper tape

>  Clear Tape

>  White paper

>  Wire



>  Cut out layered copper tape into 1x4 inch strips. Solder wires onto each strip and tape each strip to the inside of the base using clear tape with white paper in between the copper and the outer part.

>  Each strip should be about 2 inches apart from each other and in the middle of the right side of the container.

>  Note: The white paper makes the copper strips less visible from the outside of the container.

>  Lastly, paint ON/OFF sign on the right side of container so that users know which side to use for controlling the valve







>   2V Solenoid Valve

>  Silicone Sealant

>  Zip ties

>  Valve Lead Connectors



>  Using the existing rubber tube connecting the faucet head to the base the container, cut out the center portion insert each end into the valve

>  Use silicone sealant to ensure no leakage

>  Connect the rubber ends back to the base and use zip ties to secure the connection

>  Connect the Valve Power and Valve Power to the valve using the valve lead connector. This too will ensure a secure electrical connection




LED and Faucet Head



>  3D Printed LED Cap

>  Blue LED

>  White Heat Shrink (x2)

>  Faucet cap

>  Faucet w/ nut



>  Drill hole directly above faucet

>  Attach faucet with nut

>  Feed white GND wire and another LED wire through hole, solder ends to the blue LED, and apply heat shrinks to cover exposed connections

>  Paint the faucet cap white and screw piece onto top of faucet

>  Mount blue LED inside of white LED cap and glue into top of faucet cap




Mount and Hinge



>  3D Printed Mount

>  3D Printed Backing

>  Metal Spring Hinge

>  Super Glue



>  Drill hole on the top back of the base of the water cooler.

>  Glue base piece onto back and let try

>  Place empty water container in base and align water sensor w/ backing so that the hinge can be glued on properly

>  Glue hinge piece to backing and to base

>  Pull wires through hole in base. Wires to include:

          >  Lower Gesture Sensor

          >  Upper Gesture Sensor

          >  LED wire

          >  Valve Control

          >  5V DC Power

          >  GND







>  Follow Figure to connect:

          >  LED

          >  Valve Control

          >  Upper Gesture Control

          >  Lower Gesture Control

>  Connect white UART wire according to the figure

>  Connect red VDD and black GND wires according to the figure










>  3D Printed Quicksilver case

>  Quicksilver board



>  Glue case to the left side of the base and place Quicksilver inside

>  Connect 5V Power and Ground from base to Quicksilver according to the figure

>  Connect white, red, and black wires from PSoC to Quicksilver according to the figure







We can connect our data stream to a cloud computing platform for insight about usage and water levels. Analytics can also aid in planning the best delivery routes, focusing on need based delivery, limiting wasted resources. Here we describe how to connect our data stream to Arrow Connect and IBM Cloud.


Here’s What You’ll Need To Do

1) Set up an account with ArrowConnect


2) Sign up for an IBMid and register with IBM Cloud


3) Connect ArrowConnect to the IBM Watson IoT Platform. Detailed instructions on how to do this can be found on the Developer Hub or here.

     i) Create an IoT Watson Platform

     ii) Generate a Watson IoT Application Key & Authentication Token

     iii) Connect Arrow Connect to IBM


4) Provision devices in ArrowConnect, and they should populate in IBM automatically. For each device:

     i) Create an Asset Type (the same one will be used by all our Quicksilver devices)

     ii) Create a Gateway (one for each Quicksilver)

     iii) Create a Device (one for each Quicksilver)

     iv) Find HID, API Keys, and Certificates:

          a) HID:

               >  Click on the Assets tab, then select Devices.

               >  Select the device you have created.

               >  Select Developer in the menu on the left.

               >  Under the Ingestion tab, find the HID of the Device and copy it.

          b) API Keys:

               >  Click on the Access Keys tab next to the Ingestion tab.

               >  Click on the the Raw API Key to expand it, and copy it.

          c) Certificates:

               >  Click on the button labeled Secure next to the url at the top of the browser.

               >  Click on Site Settings at the bottom of the box.

               >  Click on the back arrow twice, until you are in the Content Settings.

               >  Select Manage Certificates.

               >  Select Settings in the drop down box, then scroll down to the bottom of the page and select Advanced.

               >  Select the Intermediate Certification Authorities tab.

               >  Find and click on DigiCert SHA2 Secu...

               >  Click on View.

               >  Select the Details tab.

               >  Click on copy to File.

               >  Click on Next.

               >  Select Base-64 encoded X.509 (.CER)

               >  Click on Next.

               >  Name the file, and save it where you want.


5) Download the code and modify using the HID, API keys, and Certificate.




Connecting Quicksilver to IBM IoT Dashboard

1) Copy and paste the Raw API and the Secret API key above into the private.h file below.



2) Open the terminal for the Quicksilver and set the Baud Rate to 115200.


3) Program the Quicksilver with the ArrowConnect.c code.


4) The Quicksilver will be broadcasting “Quicksilver Config Access Point” network. Connect to this network in your Wi-Fi settings


5) The IP address for the Quicksilver will be posted in the terminal. Copy and paste the IP address into your internet browser.



6) After this, the website below will load, where you can connect to Wi-Fi for the demo. If the Wi-Fi network is not there, refresh the page.



7) After connecting, the terminal will display information about connecting to the network, making a new gateway, and making a new device. This is the gateway and device that will be shown in IBM.

    1. Once connected, the green light on the Quicksilver should be on. If not, the connection is not correct.
    2. The connection is also correct is the data streaming from the PSoc is displaying in the terminal. This should be a number from 0-100.



8) Log into the IBM Cloud Account and click on Internet of Things Platform. Launch the Platform. The page that loads after you launch is a list of devices and gateways. Make note of the gateway that you made with your Quicksilver.



9) Go to the Boards tab (the grid of circles). Click on make a new card. Select the gateway that you created. The event should have a telemetry option and the property should have a f|waterlevel option. If it does not, the connection is not correct or you have the wrong gateway selected. Make the type a number from 0 to 100.



10) After you make a new card, the data displayed should match the data in the terminal streaming every second. This means the connection is correct and you are ready to demo.