What it Does

The IOT drinking system is a portable device that dispenses water depending on the working status and multiple analyzed information. To be more specific, there are two buttons, namely start and lock, for users to switch the working status. When the system is locked, it is on sleeping mode and there will be no any response. A LED light on the board is to stand for the working status. The lock status will not be ended until the start mode is on. The system continually detects and displays the temperature and distance information. When the temperature is not within the safe range, the status automatically changes to the lock mode. Otherwise, when a cup approaches the system, water will be dispensed by a pump when the temperature is appropriate.

Inspiration

To stay hydrated, having plenty of drinks is a daily necessity. However, as Harvard Health Publishing states, many of us aren't getting enough to drink, especially older adults." The issue also perplexed our students in daily life. My teammate and I find it is hard to drink on a regular basis during extremely busy final weeks. It is often the case that we get dehydrated and are bothered putting brakes on the ongoing work to drink water, which leads to body unwell and several physical problems.

Lack of corresponding effective solutions, we are motivated by the ambition to address such an issue for a wide range of people, taking care of their body health. We decide to design a IOT drinking system, a small, portable device that can be placed on the desk. We believe that this water dispenser can help people to live in a healthier lifestyle.

How it works

System Overview Overall, we use ultrasonic distance sensor, i.e., US-100 to detect distance between a cup and the drinking system. SHTC3 is to measure the temperature. A pump connected with a relay serves as an actuator to dispense water, and a LED is to indicate the working mode, i.e., start or lock. Two virtual buttons, i.e., start and lock are for users to switch the working modes. The details are showed on the image with the caption IoT Drinking System Overview Diagram.

Temperature Sensor As the Temperature sensor diagram shows, the sensorThread keeps being executed after initialization. Within the thread, CMD 0x7866 is written to get temperature and humidity values as well as choose the clock stretching disabled mode. MCU will send signals at most 20 times until it receives ACK signals from the temperature sensor, which means the measurement is completed. It is time to read the measurement values. A 6 bytes data is received and is divided into two 3 bytes data, the first 3 bytes are for temperature and the rest 3 bytes are for humidity. Each 3 bytes data contains 1 CRC on the end for us to perform the CRC check. Then, each 2 bytes data without the CRC bit is extracted and converted into float numbers, showing the temperature and humidity measurement results.

Distance Sensor Driver for US-100 distance sensor is in serial mode, working with an UART driver. The MCU sends 0x55 and receives 2 bytes indicating the distance in mm. To be more specific, we get distance results via DistanceSensorGetDistance function. The Get Distance Value image shows the flow and details.

Pump and LED The ways to config GPIO for pump and LED light are similar. Here, we take the pump as the example. The pump is connected to PA20, which is set as an output pin with logical high level using config pump GPIO function on sensorThread.c. When the distance value is below 70, PA20 is set to low, leading the pump to dispense water.

Challenges we ran into

There are a lot of challenges, for example, creating a new thread by ourselves, extracting useful part of the MQTT messages, figuring out the actual CMD written into the temperature sensor, writing the pulling function to read the temperature and humidity data and so on. Overall, all the problems can be solved by reading the data sheets and being familiar with the FreeRTOS APIs.

What we Learned with the prototype

We learned how to use debug mode to find out the exact blocks. By placing the breakpoints, the error values and the variable values are monitored, enabling us to analyze the issues and localize the problems.

In addition, we also learned the MQTT messages, especially the MQTT packet format. The useful contents are contained in the payload part. We got the value we need by a function which extract the long int numbers among characters.

What we learned

After taking this course, we have a clearer picture of Internet of Things, especially the multi-threads. We learned how to use semaphore and mutex, as well as how to design the front and backend of Node Red. We also have an interesting experience of designing our PCB.

Next Steps

In the future, advanced functions should be added. For instance, either a real keyboard or a virtual keyboard together can be an interesting human-computer interaction design. Users can simply set the temperature and distance threshold rather than revising the value on Node Red website. In addition, an exquisite model should be made, for a more fantastic look and higher quality. It can also protect the circuit not to be ruined by the splashing water.

Built With

  • atmel
  • c
  • distance
  • gpio
  • i2c
  • iot
  • pump
  • samw25
  • sensor
  • temperature
Share this project:

Updates