This Little Robot's Eyes Reveal Your Room's Health
by Arpan Mondal in Circuits > Microcontrollers
220 Views, 6 Favorites, 0 Comments
This Little Robot's Eyes Reveal Your Room's Health
Are you tired of staring at confusing numbers from your smart home sensors? Do you wish there was a more engaging way to understand your room's environment?
Meet Gus, a smart robot that makes air quality, temperature, and humidity monitoring fun and intuitive. This little guy sits on your desk, blinking with his animated eyes. He's not just cute, he's packed with sensors, constantly assessing your room's health.
If the air quality is poor, it’s too hot or cold, or the humidity’s off, his eyes get smaller as he gets dozy. Your job is to keep Gus wide awake and energized! It's a game that encourages you to actively improve your surroundings. Open a window, turn on the fan, or adjust the heat. Once the room is healthy again, his eyes will pop wide open.
Ready to build the coolest room monitor you've ever seen? Let's get started!
Supplies
0.96" OLED display Link to buy
MQ135 Air quality sensor Link to buy
DHT22 Temperature and humidity sensor Link to buy
Xiao esp32 s3 Link to buy
USB C cable
Perfboard Link to buy
Foam board Link to buy
Plexiglass Link to buy
Acrylic paint
Soldering iron
Craft knife
Rubber adhesive
Scissors
Double sided tape
Prepare the Brain
First step is to get the main component ready – his brain!
I started with a small piece of perfboard and soldered some female headers for the Xiao module. Applying some solder flux to the pins will help the solder stick better. Next, we’ll solder some wires to the female headers. Specifically, we need to connect wires to where the pins for D0, D1, D4, D5, 5V, and GND of the Xiao will be aligned after it is inserted into the female headers.
Once all the wires are soldered, it’s time to push the Xiao into the female headers. I previously soldered male headers onto the Xiao.
Code the OLED Display
Next, it’s time to test the OLED display and get a sneak peek at how Gus’s eyes will look. To do this, we need to write some code to create two blinking ellipses on the display.
But why stress when we’ve got ChatGPT? Just ask for the code you need, copy the generated snippet, paste it into the Arduino IDE, and hit upload. Simple, right?
Well... not exactly. There were errors. Even after asking it to fix the code multiple times, things only seemed to get worse.
So, I decided to read the documentation for the display, and write the code myself. You can find the code attached below.
Before uploading it to the Xiao, I tested it on an online simulator. After a bit of tweaking, it was starting to look pretty good!
Downloads
Test the OLED Display
To test the OLED display, I plugged in a connector and connected the other end to the Xiao.
The display uses the I2C communication protocol, so we need to connect VCC to the 5V pin on the Xiao, GND to GND, SDA to D4, and SCL to D5. D4 and D5 are the SDA and SCL pins on the Xiao.
Now, we are ready to upload the code and give it a test run.
Prepare the Air Quality Sensor
Before we start building Gus’s body, it’s a good time to get the air quality sensor ready.
If you check the documentation for the sensor, you'll notice that it suggests using a 20kΩ load resistor. However, the actual sensor module comes with a 1kΩ resistor.
To fix this, I desoldered the 1kΩ resistor and soldered two 10kΩ resistors in series to replace it.
Now, we need to "burn in" the sensor. To do this, we’ll plug it into a 5V power supply and leave it running for at least 24 hours.
You see, these sensors have a heating element and a sensing material, typically made of tin oxide. Over time, impurities and moisture can build up on the sensing material, affecting its performance.
By leaving it powered on for an extended period, the heating element warms up the sensing material, helping to burn off any impurities and moisture.
It’s also a good idea to place the sensor in a well-ventilated area during this time to ensure good airflow and help clean the sensing material.
Making the Head
For making Gus’s head, I used foam board. First, I marked a 5 cm by 5 and a half cm rectangle on a small piece of 5mm thick foam board—this will be his face.
Then, I cut out more rectangular pieces to build the full head, giving it a cuboid shape.
Next, I cut a section out of the face for the OLED display, making sure the cut is slightly larger than the display itself.
Now, glue all the pieces together and trim off any excess with a craft knife.
Once everything is glued, it should start to take shape.
Rest of the Body
For the body, I made a smaller cube using the same method, making sure it's big enough to fit the Xiao board we just soldered.
I also added a slight slant to the cube, so the head will be able to look upwards when it's glued on.
For the legs, I created L-shaped sections from 5mm thick foam board. You’ll need three of these for each leg to make them thick enough.
Eye Section
Now, for the eye section, I cut a piece of plexiglass to match the size of the cutout on the face.
Next, apply a rectangular piece of masking tape on one side of the plexiglass, making sure it's the exact same size as the OLED display.
Once that’s done, we can paint the entire thing with black acrylic paint. Just be sure the masking tape is securely pressed down and doesn’t shift while you paint!
While that’s drying, paint the edge of the eye section, as well as the inside of the head black. This will help prevent any reflections when the eyes light up.
I also painted the entire body white to cover up any seams and leftover pencil markings.
Now, we can leave all this to dry overnight.
Test the Air Quality Sensor
After letting it sit for 24 hours to burn in, we can connect female jumper wires to the VCC, GND, and analog out pins of the air quality sensor.
And then connect the corresponding wires to the Xiao. Before uploading the code, we need to calibrate the sensor.
Use the below code to read the R0 values. Now once you got the R0 values, Go to Documents > Arduino > libraries > MQ135-master folder and open the MQ135.h file and change the RLOAD & RZERO values. RLOAD will be 20.
Once calibrated, upload the MQ135_get_ppm.ino code to get the air quality index in PPM.
The corrected PPM value is what we’re looking for. As you see in the last image, the air quality is pretty bad where I live :(
Test DHT22
Next, we repeat the steps to test the humidity and temperature sensor. This one doesn’t require any calibration.
Just upload the code, and the humidity and temperature values should start displaying right away.
Downloads
Assemble
Great! Now that all the sensors are tested, it’s time to assemble everything.
I started by sticking the OLED display right behind the cutout on the face using double-sided tape. The screw hole was sticking out, so I carefully trimmed it off with pliers.
Peel off the masking tape from the painted plexiglass and stick it in front of the cutout with glue. I also made two foam board discs for his ears.
Next, I attached the Xiao board inside the small body using more double-sided tape. I earlier made a cutout to let the USB-C cable in. For the head, I made a back plate from the same 5mm thick foam board and created cutouts for the sensors. I placed the sensors in their spots, and then connected all the wires.
I then used electrical tape to secure the connections and prevent any shorts. Finally, I glued all the body parts together.
Upload the Code
Now, connect a USB-C cable to the Xiao and upload the main code.
The Code reads the values from the DHT22 sensor. Then it reads the air quality sensor values, and uses the DHT22 sensor readings to get the corrected AQI in PPM. It has a function to blink the eyelids once every 3 to 5 minutes (Selected at random). It calculates a "comfort score" based on how good the readings from the sensors are. And it maps the eyelid height to the comfort score. The worse the score, the lower the eyelid goes.
Sometimes, you might get an error while uploading the code to the Xiao. To fix this, press and hold the boot button on the Xiao before plugging it into the PC. Keep holding the button while you plug it in, and once the upload window says “connecting,” release the button. The code should upload successfully. You might want to do this before sticking the Xiao inside the body.
Downloads
Take Care of Gus, Take Care of Yourself :)
As soon as the code is uploaded, the eyes should light up on the display. Gus looks absolutely amazing with those animated eyes randomly blinking. And now, thanks to the sensors, his eyes will reflect his mood based on the surrounding conditions.
Honestly, I think the foam board body looks a bit unfinished, and I’d prefer a 3D-printed body instead. I’m also planning to upgrade Gus with more features, like a touch sensor on his head. You’ll be able to touch his head to show the sensor values in place of his eyes when you want to know more. Also, a light sensor can be added so Gus can get gloomy on cloudy dark days.
Let me know your thoughts in the comments!