Skip to content

Improve energy conservation for buildings

Modern office spaces try to use the latest technology for more efficient use of resources and compliance with relevant regulations. Is using the newest tech enough to achieve efficiency? No, but with proper configuration, it can.

Is it possible to save more?

LED bulbs are much more efficient than incandescent lighting – more than 75% less energy use. On average, they last 25 times longer and save considerable amounts of energy over time. It is no wonder why modern office spaces use LED lighting anywhere possible.(US Department of Energy, 2023)

From an ergonomics perspective, the next logical step on the path to energy efficiency is to not use lights! When no one needs it. Just imagine that it’s possible to save an additional 50-60% of the power used in conference room lighting without any change to employee comfort.

Evolving technology, paired with the appropriate application, will have the greatest impact. What can pair better with an LED lighting system than standard motion sensors? A fairly simple rule–if no motion is detected for X minutes – turn off the lights.

In an office space with abundant conference rooms, enabling better timing rules for the motion sensors connected to the lights is a great investment, as we shall see in a moment.

I noticed that the default timeout is programmed to 30 minutes and asked myself, is that an optimal number? Let’s get straight to the practice and find out together.

Real Data

For this experiment, we need some data:

  • When the light is ON or OFF in a room
  • Room occupancy

To know when the light is on or off, it’s easy to use a light sensor that produces numbers in a range of 0-1000 depending on the intensity of the light. The PIR sensor is a great choice for room occupancy - it will signal when a motion is detected.

The next step is to send this data to the cloud. We’ll use LoRaWAN because of its long-range and low battery consumption, so we can run a test for several days.

In the next picture, you can see two devices, a LoRaWAN-enabled light sensor and an occupancy sensor based on Arduino Leonardo. The light sensor performs readings every 10 seconds, and the motion sensor sends an event immediately if motion is detected and every 30 seconds when not occupied.

Mounted device on the conference room wall Mounted device behind the TV to monitor light

Two devices mounted to monitor room occupancy and the light state. One device mounted behind the TV for light monitoring. Another device with the PIR sensor mounted on the room wall pointing inside the room.

Data is gathered. What’s next? Let’s analyze it!

Data Analysis

The resulting data is a series of light and motion sensor readings with a timestamp. First, sum up the total time of the light being ON regardless of the motion. To prevent false readings, there is 30 second settle time window to consider the light being on or off (e.g., the light has to be 30 seconds in the same state to consider the state being changed)

Using data from the motion sensor, we can calculate a possible time when the lights would turn off if the timer was set to 5 or 10 minutes without any motion detected. This can be done using the time of the last motion and the light state ON.

Scenario Total time the lights are on Percentage of savings
(compared to normal state)
Normal state 38h 59m 16 sec -
With 10 minutes shutdown timer 18h 22m 0 52.89 %
With 5 minutes shutdown timer 15h 28m 0 sec 60.32 %

Graph showing light status and possible improvement.

Graph of the light states over one day. Comparing the actual data and what would be if the shutoff timer was 5 minutes.

Wow! That’s a huge saving! But...

How did we lend on these numbers?

First, we’re going to combine the data in a single timeline and order by the time key

combined = []
light_readings = []

# combine time series data into one list
with open("data/light.csv", "r") as f:
    csv_reader = csv.reader(f, delimiter=',')
    for row in csv_reader:
        combined.append({"time": row[0], "value": row[1], "event": "2"})
        light_readings.append(row[1])

with open("data/pir.csv", "r") as f:
    csv_reader = csv.reader(f, delimiter=',')
    for row in csv_reader:
        combined.append({"time": row[0], "value": row[1], "event": "0"})

# order a list in chronological order and use time as the key
ordered = sorted(combined,
                  key=lambda k: datetime.strptime(k["time"], '%Y-%m-%d %H:%M:%S.%f'))

Then, using the K-means clustering algorithm, we will build clusters to understand what light reading states for ON or OFF.

1
2
3
4
5
# cluster light readings to determine if light is on or off
clusters = KMeans(n_clusters=2).fit(np.array(light_readings).reshape(-1, 1))

# find an index of the cluster where the light is ON
on_index = list(clusters.cluster_centers_).index(max(clusters.cluster_centers_))

Let’s define a method that will determine if the light reading considered ON or OFF based on the KMeans model.

1
2
3
4
def light_state_on(reading):
    if clusters.predict(np.array(reading).reshape(-1, 1)) == on_index:
        return True
    return False

For easier interaction with the data and because we know and understand the mighty OOP principle, we build a light model. It will a state, last time it was one and the total number of seconds of being in the ON state. Also, the model has methods to add state ON or OFF, check if the light is ON and save the timeline of the light states into a JSON file.

class LightModel:
    # class to keep track of the light model

    def __init__(self):
        self.last_on = datetime(1970, 1, 1)
        self.total_on = 0
        self.light_states = []
        self.state = False

    def add_on(self, date, offset):
        # add a record when the light was ON
        self.light_states.append({
            'x': (date - timedelta(seconds=offset)).strftime("%Y-%m-%d %H:%M:%S"),
            'y': 0})
        self.light_states.append({'x': date.strftime("%Y-%m-%d %H:%M:%S"), 'y': 1})
        self.state = True
        self.last_on = curr_date

    def add_off(self, date, offset):
        self.light_states.append({
            'x': (date - timedelta(seconds=offset)).strftime("%Y-%m-%d %H:%M:%S"),
            'y': 1})
        # add a record when the time was OFF
        self.light_states.append({'x': date.strftime("%Y-%m-%d %H:%M:%S"), 'y': 0})
        # calculate how much time the light was ON
        self.total_on += (date - self.last_on).seconds
        self.state = False

    def is_on(self):
        return self.state

    def save_to_json(self, name):
        with (open(name, 'w')) as f:
            json.dump(self.light_states, f)

Now we’re going to loop through every record in our timeline and based on the event type (0 – PIR sensor reading, 2 – light sensor reading) determine the normal light states and improved light states. The normal light states are the same as the data suggests, but the improved states feature the PIR sensor readings. If there was no motion detected for the IMPROVED_TIMER seconds – add the OFF state to the improved light states model.

In the end, we’ll print the total amount of time and percentage of the savings.

And finally, let's see what we can get after running the full code.

percent_saved=(normal_light.total_on-improved_light.total_on)*100/normal_light.total_on
print("Improvement with {} min timer: {}%".format(IMPROVED_TIMER/60,percent_saved))
>>> Improvement with 5.0 min timer: 60.32944797514891%

Conclusion

We just proved together that a simple shut off timer setting on the lights motion sensor can make up to 60% improvement to the efficiency of the lights (and save you money too)

There are many other ways how to save energy in the buildings, other than using LED lights and motion sensors:

  • Smart HVAC system
  • Energy-efficient appliances
  • Proper insulation
  • Smart power strips

Remember, just using technology isn't always enough, you need to use it right. The small investment you make today will surprise you in the long run.

I'm grateful for your time and interest. If you enjoyed this blog post, please like it and share it! Also, leave your comments below and let me know what other great ways you know to conserve energy in your buildings?

Relevant info:

https://github.com/OlegZv/lights-motion-analysis - git repo with full code and data example https://www.darksky.org/light-pollution/ - learn more about light pollution and how you can help

Comments