In this project, we'll use RGB LEDs, an environment sensor, and an Arduino Nano to send a message or make an alarm with colored lights. At the end of this project, you can:
- Read environment temperature from the DS18B20 sensor by Arduino.
- Control RGB LEDs by PWM.
- Make a cool smart mug.
Step 1: Things Used in This Project
Step 2: A Short Note on DS18B20
The DS18B20 digital thermometer provides 9-bit to 12-bit Celsius temperature measurements and has an alarm function with nonvolatile user-programmable upper and lower trigger points. The DS18B20 communicates over a 1-Wire bus that by definition requires only one data line(and ground) for communication with a central microprocessor.In addition, the DS18B20 can derive power directly from the data line (“parasite power”), eliminating the need for an external power supply.Each DS18B20 has a unique 64-bit serial code, which allows multiple DS18B20s to function on the same 1-Wire bus. Thus, it is simple to use one microprocessor to control several DS18B20s distributed over a large area. Applications that can benefit from this feature include HVAC environmental controls, temperature monitoring systems inside buildings, equipment, or machinery, and process monitoring and control systems.
Regarding combining technology to life, using colored light is amazing and attractive. Replacing RGB LEDs with displays to send a message or alarm can make projects more beautiful and also more simple.In this project, we want to make a mug smart, so that you can show you the temperature of the coffee or soft drinks and alarm when it’s ready to drink. As thermopile, we’ll use DS18B20 and stick that on the bottom of the mug. It can send temperature of the liquid in the mug to the controller in a digital data. Arduino Nano is our choice as the controller because of its small size and mini USB connector on board. Therefore it can be programmed and the battery can be charged by USB port. To show the temperature, we use 2 simple 4-pin RGB LEDs and connect them to separate PWM units in Arduino Nano. Now, We only need a battery, a mug, and a plastic shell to put the component in. Let’s do it.
Step 3: Circuit
The battery size depends on the LEDs and the mug size. A 500mAh battery is a good choice. You can use either polymer or ion batteries. The LEDs used here have common cathodes. If yours have common anodes, you must make small changes in the code. If your LEDs cannot work without a resistor, you have two ways. Adding a resistor or adding more LEDs. You should connect both voltage and data pin of DS18b20 to a 4.7K ohm resistor. Although it may not be necessary.
Step 4: Code
You should copy the following code in the Arduino IDE. But first You must add the library and then upload the code. Download the “One Wire” and “Dallas” library from the attachment. If it is the first time you run an Arduino board, don’t worry. Just follow these steps:
- Go to www.arduino.cc/en/Main/Software and download the software of your OS. Install the IDE software as instructed.
- Run the Arduino IDE and clear the text editor and copy the following code in the text editor.
- Navigate to sketch and include the libraries (Download libraries from the following links). Now click add ZIP library and add the libraries
- Choose the board in tools and boards, select Arduino Nano.
- Connect the Arduino to your PC and set the COM port in tools and port.
- Press the Upload (Arrow sign) button.
The following lines of code belong to the color calculation and it depends on your mug. If your mug does not transfer heat fast enough, you should change it to achieve desired results.
Step 5: Assembling
Initially, you must drill the bottom of the mug. The number of holes depends on the circuit and how you implement it. We have considered 3 holes for this project. One for the thermometer and two for connecting screws (electrodes) with liquid inside the mug. You can do this project without piercing the mug. Tick the thermometer to the bottom of the mug and connect the 2 wires of the electrodes to an on/off switch.After attaching the thermometer and the electrodes and sealing them, it is time to make a frame for the bottom of the mug. Use glues to seal the glass, which will not be solved by hot or cold water.To make the shell for the bottom of the mug. you must first measure the outer diameter of the mug. Then design a circle with exactly the same size of the bottom of the mug, and two rings with the outer diameter with a thickness of 3 mm (and of course with the diameter of the bottom of the mug).You can use plexiglass and a laser cut machine to make the prescribed shell. One of the rings must be transparent, you can choose the color of the rest of them as you wish.You should sand the transparent ring to achieve a matte finish. Glue them as shown in the images.Now glue the battery to the shell and connect its pins to Arduino. Slice the portion of the transparent ring as much as the Arduino micro USB port, and attach the Arduino to the battery so that the connector drops out of the ring. Now solder the LEDs to the Arduino and connected other wires to Arduino. Finally, glue the shell to the bottom of the mug and upload the code to Arduino.
Step 6: What’s Next?
Now, improve the smart mug by adding new functionalities to the code. For example, you can add some lines to alarm you when your coffee is at the desired temperature and it’s ready to drink. You can light up the green LEDs for alarming. In the next step, you can add a heater element to the bottom of your mug and write some code to stop decreasing the temperature of the drink.
You can also read this project on ElectroPeak's official website.