Arduino Smart Desk - SHProject 2
by DeviceCtrl in Circuits > Arduino
1203 Views, 11 Favorites, 0 Comments
Arduino Smart Desk - SHProject 2
This project will add some automation and environmental monitoring. The desk has low voltage lighting above it and a motorized curtain. This will allow me to control the curtain or lights from my phone or PC. In Addition, a closet very close by has gas water heater. So, I thought it wise to monitor the CO levels in the room as well as the temperature and humidity.
During the renovation of my house, I wired each room with Cat6 Ethernet cable and low voltage wiring. This really makes interconnecting my Arduino projects easy.
Downloads
Supplies
Arduino Mega
Arduino Ethernet Shield
DHT11 Temperature and Humidity sensor
Mq-7 Carbon Monoxide Gas Sensor for Arduino
4 Channel 5V Relay Module with Opto-coupler
3 Magnetic Switches - Wired & Recessed
Project box
Arduino Schematic
I like to begin my Arduino projects by mocking up the wiring using bread boards and jumper wires. Adding each component one by one, ensuring that I have hooked them up correctly and they are giving the expected results. So follow the above diagram to construct the device.
Mq-7 Carbon Monoxide Gas Sensor
The Arduino MQ7 library makes adding the sensor easy.
DHT11 Temp and Humidity Sensor
The DHT11 temperature and Humidity sensor is rather easy to get working. The one consideration is that it needs to be protected from hostile aliens or monsters (like cats, dogs or inquisitive children). In the image above, I took some PVC pipe and fittings to create simple housing with air holes drilled in the PVC cap.
This also serves to separate the sensor from conditions inside project box where the Arduino, power supply and other electronics reside.
Curtain Controller
This motorized curtain was purchased more that 10 years ago. It came with a remote controller. It worked well for almost 2 years then failed. The manufacture replaced the electronics and it worked for another 6 months and then failed. They kindly replaced the electronics a 2nd time and it worked for another 5 months before it failed again. Despite the manufacture's good will, I decided that enough is enough. I ripped out the electronics leaving just a very nice DC motor.
Since we want the motor to always run at full speed, there is no need for a sophisticated motor controller. You can just use 2 simple relays to flip the voltage polarity and run the motor clockwise or counter-clockwise.
The other 2 relays are used to turn the overhead lights on or off.
Curtain Control Continued
Now that we can raise or lower the curtain, we need some way to prevent the motor from over-rotating the curtain. To do this I mounted 3 magnetic reed switches at the Top, Bottom and Middle. Then I sewed a magnet at the hem of the curtain (see photo)
This is the biggest reason to use an Arduino Mega. The Uno only has 2 interrupts and we dont want to keep polling the status of the pins. Instead we use the attachInterrupt method to fire and forget when moving the curtain. Meaning that we turn the motor via the 2 relays. Then when a switch closes it interrupts processing to turn the motor off. So the Arduino can be in the middle of any procedure (ie getting the temperature, measuring the CO levels or answering a query) and it will pause, turn the motor off and return to its current task.
Lighting
Setting up relays for the low voltage light is a snap when using the existing low voltage wiring. It can be easily adapted to AC voltage as these relays are rated for 120/240 VAC. Be careful handling any voltage AC or DC. If your not sure, get a professional or someone very experienced.
Project Box
Once you have attached all the sensors and bench tested them working individually and together, its time to mount all the components in a project box. I also use thru panel connectors (called: cable gland) to maintain the box's integrity when cables are connected.
Arduino Ethernet Shield
While preparing and mounting all the components, don't forget to first mount the Ethernet shield to the Arduino Uno. During the renovation of my home, I had the foresight to install Cat6 Ethernet cable and low-voltage wiring everywhere. If an Ethernet cable is not available, Arduino makes a WiFi shield for the Uno.
Polling and Commanding the Unit
Since this unit needs to be installed low to the ground (because of the CO sensor), it's not practical to connect a display. Instead, I have my PC poll the Curtain controller every minute and store the readings in a SQL database. This gives me both up-to-date environment data and disposition of the lights and curtain
I decided to use UDP protocol instead of TCP. Arduino's Ethernet/WIFI library include software to communicate using UDP. Every minute my PC sends a timestamp in the form of r2406131422054 - this translate to 2024-06-13 14:22:05 4=Thursday (ie day of the week)
Sending a timestamp to my Arduino devices is very handy. It allows the device to know the date and time (within a second) without any additional code, NTC sync or RTC device.
If the device receives this string, it immediately responds with a tab delimited string of the current sensor readings. like: 795\t67\t4\t106\t00
This is made up of Temperatures, humidity, curtain position, CO ppm and light relays