An Open Source “Smart Lamp” for the Optimization of Plant Systems and Thermal Comfort of Offices

The article describes the design phase, development and practical application of a smart object integrated in a desk lamp and called “Smart Lamp”, useful to optimize the indoor thermal comfort and energy savings that are two important workplace issues where the comfort of the workers and the consumption of the building strongly affect the economic balance of a company. The Smart Lamp was built using a microcontroller, an integrated temperature and relative humidity sensor, some other modules and a 3D printer. This smart device is similar to the desk lamps that are usually found in offices but it allows one to adjust the indoor thermal comfort, by interacting directly with the air conditioner. After the construction phase, the Smart Lamp was installed in an office normally occupied by four workers to evaluate the indoor thermal comfort and the cooling consumption in summer. The results showed how the application of the Smart Lamp effectively reduced the energy consumption, optimizing the thermal comfort. The use of DIY approach combined with read-write functionality of websites, blog and social platforms, also allowed to customize, improve, share, reproduce and interconnect technologies so that anybody could use them in any occupied environment.


Introduction
Over the past years several shared projects and low-cost alternative technologies have appeared and developed, bringing end users closer to electronics in a simple and fast way [1][2][3]. In particular, through the Do-It-Yourself (DIY) approach, the user becomes also the maker of these technologies, removing structural, technological and economical obstacles [4]. The spread of this movement has led to the proliferation of devices always connected to a communicating-actuating network, i.e., a web of objects connected to the network and interconnected to each other, named Internet of Things (IoT) [5] starting a technological revolution. After the agricultural and the industrial revolutions, the information age, the so called Third Wave [6], draws upon the read/write functionality of the Internet and digitally-driven design/manufacture, to enable ordinary people to invent, design, make and, sometimes, sell goods and services [7]. Anybody at any location could carry out the principles of the DIY philosophy [8][9][10] through enabling technologies, for example Arduino [11] or Genuino [12].
Today, websites like OpenMaterials [13], Instructables [14], Make Magazine [15], Adafruit [16], Sparkfun [17], Cubify [18], Thingiverse [19] allow the quick sharing of smart, low cost and DIY approach-based solutions among makers or enthusiasts. The several licenses provided by Creative Commons [20] allow protection of the knowledge and creativity of the projects' authors. In this paper the DIY approach has been applied to a smart system integrated into a desk lamp similar to those used ‚ Bluetooth module (optional) [44].
Sensors 2016, 16,338 3  LED IR [42];  24 LEDs panel board [43];  Bluetooth module (optional) [44]. The choice of the Arduino MEGA PCB based on the ATmega2560 microcontroller is due to the possibilities offered by this device for managing the large amount of data necessary to send infrared signals to the HVAC unit. The board has 54 input/outputs (I/O) (14 of which can be used as Pulse-Width Modulation (PWM) outputs), 16 analog inputs, four Universal Asynchronous Receiver-Transmitter (UART), 16 MHz quartz, USB connection, power jack, programming header for In-Circuit Serial Programming (ICSP) and reset button.
The Wireless SD shield allows one to save the data into the Micro SD card placed in the on-board slot. It allows an Arduino board to communicate wirelessly using a wireless module too. It's considered this shield instead of Wi-Fi ones because one future upgrade regards the possibility to connect this device to a coordinator through radio frequency module (XBee S2 type) in a Wireless Sensor Network (WSN) with some others device. The open source approach of this project gives to everyone the possibility to consider a Wi-Fi shield in substitution of this one.
The DHT22 sensor is small in size and operates with a supply voltage between 3.3 and 6 V. It communicates both data (temperature and relative humidity) through a single pin. It is able to measure temperatures with a range between −40 and 80 °C, with an accuracy of less than ±0.5 °C, and to detect the relative humidity between 0% and 100%, with an accuracy of ±2%. The sensor provides fully digital calibrated outputs for the two measurements. The protocol must be implemented in the firmware of the microcontroller and it is not compatible with the 1-Wire ® protocol.
The RTC module was developed around the DS1307 Integrated Circuit (IC) by Maxim. The DS1307 IC is a Binary-Coded Decimal (BCD) low consumption clock/calendar with 56 bytes of RAM powered by a back-up battery. Addresses and data are transmitted serially via the bidirectional I2C bus. The clock/calendar provides information on seconds, minutes, hours, day, month and year. The end of the month is automatically adjusted for months with less than 31 d, including the correction The choice of the Arduino MEGA PCB based on the ATmega2560 microcontroller is due to the possibilities offered by this device for managing the large amount of data necessary to send infrared signals to the HVAC unit. The board has 54 input/outputs (I/O) (14 of which can be used as Pulse-Width Modulation (PWM) outputs), 16 analog inputs, four Universal Asynchronous Receiver-Transmitter (UART), 16 MHz quartz, USB connection, power jack, programming header for In-Circuit Serial Programming (ICSP) and reset button.
The Wireless SD shield allows one to save the data into the Micro SD card placed in the on-board slot. It allows an Arduino board to communicate wirelessly using a wireless module too. It's considered this shield instead of Wi-Fi ones because one future upgrade regards the possibility to connect this device to a coordinator through radio frequency module (XBee S2 type) in a Wireless Sensor Network (WSN) with some others device. The open source approach of this project gives to everyone the possibility to consider a Wi-Fi shield in substitution of this one.
The DHT22 sensor is small in size and operates with a supply voltage between 3.3 and 6 V. It communicates both data (temperature and relative humidity) through a single pin. It is able to measure temperatures with a range between´40 and 80˝C, with an accuracy of less than˘0.5˝C, and to detect the relative humidity between 0% and 100%, with an accuracy of˘2%. The sensor provides fully digital calibrated outputs for the two measurements. The protocol must be implemented in the firmware of the microcontroller and it is not compatible with the 1-Wire ® protocol.
The RTC module was developed around the DS1307 Integrated Circuit (IC) by Maxim. The DS1307 IC is a Binary-Coded Decimal (BCD) low consumption clock/calendar with 56 bytes of RAM powered by a back-up battery. Addresses and data are transmitted serially via the bidirectional I2C bus. The clock/calendar provides information on seconds, minutes, hours, day, month and year. The end of the month is automatically adjusted for months with less than 31 d, including the correction for leap years. The clock can work in 24 and 12 h format with AM/PM indication. The DS1307 has a power-sense integrated circuit that detects the power failure and automatically enables the power supply through the backup battery.
The LED is IR-type, with a diameter of 5 mm and it is characterized by a peak wavelength, λp, equal to 940 nm.
The BlueSMiRF Gold Bluetooth module allows one to easily transmit the signal over distances of less than 100 meters. It has a low power consumption of less than 25 mA with operating voltage between 3.3 and 6 V. The operating frequency is 2.402˜2.480 GHz. It uses the RN-41 chip for the connection. It has a default BAUD rate of 115,200.
The electronic architecture has been integrated in the lamp base. This choice prevents the lamp from tipping over and allows to exploit the interior space for the housing of the components. The lighting element is a "cold light" LED board in place of the original halogen bulb, in order to minimize the energy consumption of the lamp.
The construction of the Smart Lamp has required a series of adjustments and the manufacturing of two distinct cases: the housing for the installation of the LED panel and the infrared emitter and a new base in which the elements described above are integrated. Both cases are designed in 3D CAD format and printed with a 3D printer with PLA. The new lamp housing ( Figure 2) has the same shape as the original one and provides the fixing of the LED panel with screws on the back. for leap years. The clock can work in 24 and 12 h format with AM/PM indication. The DS1307 has a power-sense integrated circuit that detects the power failure and automatically enables the power supply through the backup battery.
The LED is IR-type, with a diameter of 5 mm and it is characterized by a peak wavelength, λp, equal to 940 nm.
The BlueSMiRF Gold Bluetooth module allows one to easily transmit the signal over distances of less than 100 meters. It has a low power consumption of less than 25 mA with operating voltage between 3.3 and 6 V. The operating frequency is 2.402 ÷ 2.480 GHz. It uses the RN-41 chip for the connection. It has a default BAUD rate of 115,200.
The electronic architecture has been integrated in the lamp base. This choice prevents the lamp from tipping over and allows to exploit the interior space for the housing of the components. The lighting element is a "cold light" LED board in place of the original halogen bulb, in order to minimize the energy consumption of the lamp.
The construction of the Smart Lamp has required a series of adjustments and the manufacturing of two distinct cases: the housing for the installation of the LED panel and the infrared emitter and a new base in which the elements described above are integrated. Both cases are designed in 3D CAD format and printed with a 3D printer with PLA. The new lamp housing ( Figure 2) has the same shape as the original one and provides the fixing of the LED panel with screws on the back.    for leap years. The clock can work in 24 and 12 h format with AM/PM indication. The DS1307 has a power-sense integrated circuit that detects the power failure and automatically enables the power supply through the backup battery.
The LED is IR-type, with a diameter of 5 mm and it is characterized by a peak wavelength, λp, equal to 940 nm.
The BlueSMiRF Gold Bluetooth module allows one to easily transmit the signal over distances of less than 100 meters. It has a low power consumption of less than 25 mA with operating voltage between 3.3 and 6 V. The operating frequency is 2.402 ÷ 2.480 GHz. It uses the RN-41 chip for the connection. It has a default BAUD rate of 115,200.
The electronic architecture has been integrated in the lamp base. This choice prevents the lamp from tipping over and allows to exploit the interior space for the housing of the components. The lighting element is a "cold light" LED board in place of the original halogen bulb, in order to minimize the energy consumption of the lamp.
The construction of the Smart Lamp has required a series of adjustments and the manufacturing of two distinct cases: the housing for the installation of the LED panel and the infrared emitter and a new base in which the elements described above are integrated. Both cases are designed in 3D CAD format and printed with a 3D printer with PLA. The new lamp housing ( Figure 2) has the same shape as the original one and provides the fixing of the LED panel with screws on the back.   The electronic components (Arduino MEGA Arduino Wireless Shield, RTC module and sensor DHT22) are placed inside this base (Figure 3), except for the optional Bluetooth module which is placed in a separate compartment (No. 2 in Figure 3). Arduino MEGA, Arduino Shield ("sandwich" connected) and RTC are fixed to the drawer. The sensitive component of the DHT22 sensor is outward-facing to detect the environmental variables. Furthermore, a series of small compartments intended to contain the counterweights for balancing the lamp are provided.
An app for Android devices was created with the aid of MIT App Inventor, a visual programming blocks language for Android OS [45]. The wireless shield mounted on the Arduino MEGA allows to record the data on a micro-SD card. The Bluetooth module allows to send the data to an app (Figure 4) to visualize the temperature and the relative humidity data and to verify the operating status of the HVAC system. It is used a Serial Port Profile (SPP): the Bluetooth module work as a serial transmission connector. All serial printed data are streamed to the smartphone. All data can be stored in a cloud server using the Wi-Fi or the data connection of the smartphones. The electronic components (Arduino MEGA Arduino Wireless Shield, RTC module and sensor DHT22) are placed inside this base (Figure 3), except for the optional Bluetooth module which is placed in a separate compartment (No. 2 in Figure 3). Arduino MEGA, Arduino Shield ("sandwich" connected) and RTC are fixed to the drawer. The sensitive component of the DHT22 sensor is outward-facing to detect the environmental variables. Furthermore, a series of small compartments intended to contain the counterweights for balancing the lamp are provided.
An app for Android devices was created with the aid of MIT App Inventor, a visual programming blocks language for Android OS [45]. The wireless shield mounted on the Arduino MEGA allows to record the data on a micro-SD card. The Bluetooth module allows to send the data to an app (Figure 4) to visualize the temperature and the relative humidity data and to verify the operating status of the HVAC system. It is used a Serial Port Profile (SPP): the Bluetooth module work as a serial transmission connector. All serial printed data are streamed to the smartphone. All data can be stored in a cloud server using the Wi-Fi or the data connection of the smartphones. Although there are other applications that allow you to view and interact with smart devices, the use of a "drag-and-drop" visual programme language like app inventor allows to an inexperienced novice to easily create this app and modify to suit specific needs.

Management Algorithm of the HVAC System
The code of Arduino MEGA board implements the logic control shown in Figure 5. The HVAC system is connected to an electrical device which automatically switches off the thermal plant from 7.00 pm to 7.00 am, from Friday to Monday. Users can then use the HVAC system during the working hours changing the operating settings manually. The Smart Lamp allows one to manage the system from 7.00 am to 6.00 pm for the best thermal comfort conditions, recording the indoor temperature, the relative humidity and the setup of the HVAC system every minute on a microSD memory. Every 15 min, the control system checks the indoor environmental values and performs an actuation in terms of activation/deactivation of the HVAC system, if the setting values are different from what expected. The other controls prevent the Smart Lamp from sending the same command after 15 min if the environmental conditions are not changed, through an Electrically Erasable Programmable Read-Only Memory (EEPROM). So for example, if the ambient temperature is lower than 21 °C, the microcontroller reads the value (Eeprom.read) stored in the cell 1 of the EEPROM. If this value is equal to that corresponding to the "heating ON, 24 °C", the microcontroller merely write via serial (Serial.print) and on the memory support (myFile.print) the data relating to the date, time, air temperature, relative humidity and HVAC setting; otherwise, the microcontroller also provides to send the infrared appropriate code (Send IRsignal) to the air conditioner (in this case, Although there are other applications that allow you to view and interact with smart devices, the use of a "drag-and-drop" visual programme language like app inventor allows to an inexperienced novice to easily create this app and modify to suit specific needs.

Management Algorithm of the HVAC System
The code of Arduino MEGA board implements the logic control shown in Figure 5. The HVAC system is connected to an electrical device which automatically switches off the thermal plant from 7.00 pm to 7.00 am, from Friday to Monday. Users can then use the HVAC system during the working hours changing the operating settings manually. The Smart Lamp allows one to manage the system from 7.00 am to 6.00 pm for the best thermal comfort conditions, recording the indoor temperature, the relative humidity and the setup of the HVAC system every minute on a microSD memory. Every 15 min, the control system checks the indoor environmental values and performs an actuation in terms of activation/deactivation of the HVAC system, if the setting values are different from what expected. The other controls prevent the Smart Lamp from sending the same command after 15 min if the environmental conditions are not changed, through an Electrically Erasable Programmable Read-Only Memory (EEPROM). So for example, if the ambient temperature is lower than 21˝C, the microcontroller reads the value (Eeprom.read) stored in the cell 1 of the EEPROM. If this value is equal to that corresponding to the "heating ON, 24˝C", the microcontroller merely write via serial (Serial.print) and on the memory support (myFile.print) the data relating to the date, time, air temperature, relative humidity and HVAC setting; otherwise, the microcontroller also provides to send the infrared appropriate code (Send IRsignal) to the air conditioner (in this case, heating ON, 24˝C) so as to change the setting, and to update the value (Eeprom.update) stored in the cell 1 of the EEPROM.

Smart Lamp Installation
The Smart Lamp was installed in an office located on the first and top floor of about 42 m 2 (7.81 mˆ5.37 m) normally occupied by four users. The office ( Figure 6) is equipped with a HVAC system. Three integrated air temperature and relative humidity sensors (RHT), equally distributed along the 7.81 m long side, a globe thermometer (G) and an energy counter (C) ABB OD 1365 were installed, all connected to a data logger (D): the environmental variables were detected every 10 s and averaged every minute. All data are stored on mass storage device.

Smart Lamp Installation
The Smart Lamp was installed in an office located on the first and top floor of about 42 m 2 (7.81 × 5.37 m) normally occupied by four users. The office ( Figure 6) is equipped with a HVAC system. Three integrated air temperature and relative humidity sensors (RHT), equally distributed along the 7.81 m long side, a globe thermometer (G) and an energy counter (C) ABB OD 1365 were installed, all connected to a data logger (D): the environmental variables were detected every 10 s and averaged every minute. All data are stored on mass storage device. A reverse engineering process allowed to acquire the codes that the remote control sends to the HVAC system, through few hardware elements ( Figure 7) and one software:
A TSOP31238 infrared receiver that works in the range of 840 and 960 nm was connected to Arduino UNO r3 PCB. It is sensitive to long-distance transmission and it has a carrier frequency comprised between 30 and 56 KHz. The acquisition frequency of the HVAC system is 38 kHz. The infrared signals picked up by the hardware system described above were recorded and analysed using the software for Windows PCs, AnalysIR [48]. Though  These signals were embedded within the code described above. A reverse engineering process allowed to acquire the codes that the remote control sends to the HVAC system, through few hardware elements ( Figure 7) and one software:

Experimentation: Results and Discussion
The levels of indoor thermal comfort and the associated energy consumption for the considered office were assessed. A total of 14 summer working days were analysed, divided into two periods: the former between 30 June and 8 July 2015, with HVAC manual control and the latter between 9 July and 17 July 2015 with automatic control provided by the Smart Lamp. A TSOP31238 infrared receiver that works in the range of 840 and 960 nm was connected to Arduino UNO r3 PCB. It is sensitive to long-distance transmission and it has a carrier frequency comprised between 30 and 56 KHz. The acquisition frequency of the HVAC system is 38 kHz. The infrared signals picked up by the hardware system described above were recorded and analysed using the software for Windows PCs, AnalysIR [48]. Though  ‚ A/C system OFF.
These signals were embedded within the code described above.

Experimentation: Results and Discussion
The levels of indoor thermal comfort and the associated energy consumption for the considered office were assessed. A total of 14 summer working days were analysed, divided into two periods: the former between 30 June and 8 July 2015, with HVAC manual control and the latter between 9 July and 17 July 2015 with automatic control provided by the Smart Lamp.

Thermo-Hygrometric Comfort
The thermo-hygrometric comfort was assessed following the methodology of the ASHRAE 55-2013 [49]. This standard describes a graphical method for the assessment of the indoor thermal comfort by identifying in a psychometric chart two comfort areas for different clothing levels (defined as an index of clothing; typical values are 1 clo, in winter, and 0.5 clo, in summer). The summer comfort zone is considered to be equal to 0.5 clo.
Data recorded from 9.00 am to 6.00 pm for the two periods are represented in a graph where the x-axis shows the internal air temperature (T) and the y-axis the relative humidity (RH). The comfort zone delimiting the set of points that ensure a good level of comfort in summer conditions (0.5 clo), is marked as a black line in Figure 8. It can be noted how the red points, referred to the manual control of the HVAC system (Figure 8a), is more dispersed and cover a large area: only 35% of the values falls within the comfort zone. Some points outside the polygon are away from the boundary line with a value even higher than 32˝C. The blue points related to automatic control provided by the Smart Lamp (Figure 8b) are placed and concentrated within the comfort zone-about 65% fall within the comfort zone. It can also be noted that the remaining points outside the polygon are not very far from the boundary line but densely concentrated just along the dividing line with the maximum recorded value of just over 28.5˝C.

Electrical Consumption
The analysis of the data related to the electrical consumption recorded by the energy meter connected to the data logger allows to verify the most efficient control ( Figure 9) as a function of the daily average external temperature variation.

Electrical Consumption
The analysis of the data related to the electrical consumption recorded by the energy meter connected to the data logger allows to verify the most efficient control ( Figure 9) as a function of the daily average external temperature variation.

Electrical Consumption
The analysis of the data related to the electrical consumption recorded by the energy meter connected to the data logger allows to verify the most efficient control ( Figure 9) as a function of the daily average external temperature variation.  The daily average consumption related to the automatic control is equal to 13.96 kWh with an average external temperature equal to 29.91˝C (standard deviation of 0.87 kWh and 1.69˝C, respectively). With manual control, the daily average consumption is equal to 14.97 kWh with an average external temperature equal to 30.30˝C (standard deviation of 2.2 kWh and 1.64˝C, respectively). The area of the spheres of Figure 9 represents the percentage variation of the daily cumulative consumption compared to the mean value of the period. The overall saving provided by the automatic control is slightly higher than 7%. In this case, the linear dependence of the daily cumulated consumption from the average value of external temperature is confirmed by a correlation value (R 2 ) equal to 0.91: energy consumption increases with the increasing of the average outdoor air temperature as would be expected in summer conditions [50][51][52]. Instead, in the first case the R 2 index is equal to 0.1, which is symptomatic of a non-linear dispersion.

Conclusions
The system, implemented following the DIY philosophy and the use of open hardware and low-cost sensors, allows the indoor thermal comfort to be independently managed. This automatic DIY HVAC control system is an extremely flexible solution. The analysis conducted so far demonstrates how it is possible to optimally manage the indoor thermal comfort and energy consumption because the Smart Lamp, manufactured using a desk lamp, some electronics components and two 3D printed cases, interacts directly with the HVAC system wireless through the IR LED. The hardware and software architecture based on Arduino board and the information for the 3D printer are available for download through website so it is easy to replicate and to customize this solution to specific needs.
The Smart Lamp project is implemented in the field of the Internet of Things for the built environment. The potential of this basic device is confirmed by tests in real working conditions. The characteristics so far described and analysed allow a wide field of application aimed at improving users' satisfaction and energy consumption of buildings. Current researches are focus on the interaction between the thermal comfort quality and the personal control of users, showing how the micro-climatic conditions play a fundamental role in users' satisfaction [53,54]. Thanks to the easy reproducibility and application the Smart Lamp could be applied to manage the punctual micro-climatic conditions of a single workplace improving the indoor quality.