How We Built a Truly Smart Office System Based on Raspberry Pi

Kamil Górski

iot-office-1

Last year, when Monterail decided to change their office to be a bigger and better-designed place , they decided that it should also be smarter. I was introduced to the team as a person who could make this happen. I collaborated with Monterail during the renovation of their new home and then finally joined the team.

The Smart part

Such a huge project cannot start without a good, long workshop about our needs and requirements. After a thorough workshop we decided to have the following features:

  • light control,
  • conference and call room occupancy signalization,
  • individual access codes for the main doors for each team member in a centralized database,
  • audio system with a wireless music streaming option,
  • separate, manageable audio experience in the restroom,
  • five TVs with the ability to manage the content displayed on them,
  • kitchen LED lamp color management,
  • ability to control everything via a web application (desktop, mobile, phone and panels mounted on the walls).

After that, the automation system project was done and the whole office concept was ready to be implemented in real life. The entire hardware side of the smart office had taken place during the construction work done by the renovation crew. Of course, there were some small complications during whole venture, but everything ultimately ended up as we wanted.

Thinking of an IoT development?

Work with JavaScript experts who will push hard to understand your business and meet certain deadlines.

See what we can build together

 

Technical decisions and reliability risks

Most automation systems we found were built based on PLCs – due to their reliability and strict manufacturing restrictions.

“Let’s do something new, something that we haven’t seen on the Internet before.”

After some consideration we put our bet on Raspberry Pi. We debated about reliability as we couldn’t find a project based on RaspberryPi that big. We wanted to find out if it’s possible. And we did.

Heart of the system

There is one master Raspberry Pi which controls all of the low-level hardware. To accomplish this we had to create two kinds of custom devices:

  • The first one we called the “distribution board”: distribute power and provide connectors that connects all peripherals: the RPi itself, movement sensors, door lock, etc.

photo of the power distribution board

  • The second device is a relay driver board. Relay is like a wall switch but instead of turning it on and off by hand you put voltage onto it. There is one relay for each light group which makes over 30 pieces to handle the entire Monterail office.

photo of a relay driver board

The main unit also runs a web server with a Web Application that allows to control all of the features.

Occupancy signalization

This function is achieved by a regular movement sensor mounted in each room. Signals are gathered in the device described above.

TV panels management

There are five additional Raspberry Pis connected to separate TVs. They are all independent showing mostly funny memes or websites with meaningful information.

This was achieved by simply running Chrome in kiosk mode on each device. Chrome Debugging Protocol is used control it from the web (that is the main Raspberry Pi).

On some occasions (e.g. keynotes during events available to the public) we knew we needed an image from the projector to be shown on the TVs. Instead of rewiring the whole system, we made a simple hack: a bunch of HDMI switches and splitters connected together created the ability to change the TV source from Raspberry Pis. We can now use the Web Application to control if we display the projector on each TV independently.

photo of the TVs showing an image from the projectorphoto of TV screens

Audio office system

We ended up having high quality speakers all around the office mounted in the ceiling. The owner of the building gave us them for free as our office space used be shopping area before we took all the walls down.

We divided them in multiple sections and connected to a broadcasting amplifier. Two of the Raspberry Pis are connected to the amplifier and run DLNA and AirPlay servers. Thanks to this, everyone connected to our WiFi can stream music wirelessly to a specific audio section. It works great after-hours.

Additionally, we have external speakers with a separate RPi in the restroom. It has an Internet radio player installed and a simple API exposed which allows to control it with our smart office Web Application. A nice touch to walk into a restroom and hear radio playing. The choice of Internet radio played in restroom is meticulously managed by people on #music Slack channel.

photo of a radio

Manageable door access

When someone joins Monterail it is required that they have a separate access card to office doors. Adding a new card by hand would be annoying, but since there is a possibility to connect a card reader to an external device…

We hooked it up with our main Raspberry Pi and set up a database with every employee matched with their card number and access code. This setup allows us to add new cards simply by inserting it into the database.

Kitchen LED lamp

We have a custom-made RGB LED lamp in the kitchen formed in shape of the Monterail logo. It came with an IR remote to control it the colour palette.

Remote? We use Raspberry Pi to precisely control the colour it via our Web App, too. Connecting wires directly into an IR socket and emulating the remote with ready-to-go libraries was easier that you might think.

photo of red lamp photo of a lampphoto of the Monterail logo-shaped lamp

Context-Based Tablets

Controlling whole office from a computer or mobile phone is very handy, but what if we don’t have any of these devices with us? Lights can be controlled in an analog way, but we wanted to have the whole system within reach.

We came up with the idea of Android-driven tablets on the walls near strategic rooms. Each is running the same app that you’d find on the desktops. They can also display a room occupancy calendar so everyone can see the nearest availability of the room.

photo of a tablet on the wall near a conference room

Closing notes

  • The light control set up is fail-safe. If something with the RPi goes terribly wrong, we could still operate the lights in the “classic” analog way.
  • The entire hardware setup had taken place during the construction work. I worked side by side the renovation crew and it was fun. Of course there were some small complications during whole venture but everything ultimately ended up as we wanted.

Conclusion: We ♥️ RPi

People would think that using Raspberry Pi in a system of that scale is crazy. They are too many things that may go wrong.

Now, after a year from launching our smart office system based on 7 Raspberry Pis we know there is nothing to be afraid of!

This system is, for sure, not ready to be mass-produced and implemented. Modules will need to be standardized and the RPi should be used in a “Computed Module” version. But it proves a point. An RPi can be used for much more complicated tasks than blinking LEDs or streaming video. It can manage your entire office!

Do you have similar experiences with Raspberry Pi or other systems? Or do you have bad ones? Feel free to ping me in the comments!

Technical addon

Many of you requested for some technicalities in the comments, so we present some details about our smart office system.

Light control

We have about 27 light zones in the whole office. Each zone is controlled independently by separate circuit. Cabling from every light set and every light switch is brought to the main automation cabinet.

Inside cabinet, every light zone is connected in a multiway switching configuration with Finder relay module. This configuration was chosen as a failsafe solution for the future as it is experimental, custom installation. I'm pretty convinced that it won't be used in near time.

configuration of a Finder relay module

For relays, it is required to have some IO expansion interface to handle them with required currents. As I couldn't find any appropriate module we created a custom one, specifically to our smart office. For addition we needed to have a feedback from the lamp, as it can be switched independently from the wall switch. To achieve that goal I used ISP814 AC optical isolator with some RC filter at the output transistor. The working principle of this configuration is pretty simple. In a normal state, when there is no voltage at optoisolator input, the output pin is in constant HIGH state. When you apply an input voltage the output transistor is conducting for a small amount of time in a 50Hz period as AC wave crosses the zero level. The RC values are selected to maintain around 0.1V level at the output, which implicates to be designated as LOW logic level.

custom module

The whole module is driven by popular MCP23017 which is handling both relay outputs and light detection inputs. The module is connected through I2C interface to the Raspberry Pi. We thought about industrial Modbus interface, but for the purpose of this installation, it was omitted.

The module connected through I2C interface to the Raspberry Pi

Occupancy signalization

We created raspberry pi conference rooms by placing movement sensors in each conference room. The sensors have simple, shorting outputs. They are connected through optoisolators to the Raspberry Pi input header.

LED lamp

It was a pretty nice hack as DMX driver delivered by the external contractor was without any network interface. It had an IR input terminals, though. The simplest solution was to directly connect the terminals to RPi, and emulate IR codes through lirc.

Doors

Main door RFID receiver is configured as read-only device and connected through Wiegand interface to Raspberry Pi. It reads all input codes and after validation enables the electromagnet in main doors through a relay.

Audio and video

Each screen is connected through an HDMI cable directly to RPi. Each RPi has auto-booting Chromium with debugger mode enabled, so it can receive external commands. Two of them also has audio servers installed and each one of them is connected to the main amplifier through the audio cable.

HDMI switching from the web is achieved by connecting a bunch of HDMI switches and splitters together. HDMI switches were custom modded to interface them to the main Raspberry Pi.

model shows connections of HDMI switches and splitters together

Software

Basically, software is divided into 4 parts. 3 lower levels are written in python, the web application is written in Angular JS.

the 4 parts of software written in Angular JS and python

Backend HAL and logic code.

HAL interfaces all hardware and gives an access to it into higher logic code. Basically, it uses pigpio and some libraries for MCP23017.

Logic part is divided into classes, each one supervising particular part of the system (ex. relays). In each class, there is implemented a control interface along with collision detection system. Each class exists as a singleton in the main application. It was required to implement some protection for forbidden states of the system.

Backend API code.

There are two kinds of APIs for controlling the system. REST API is used for user actions (ex. turning the lights on/off). It was built with Bottle Python framework. All callbacks (ex. light state change, movement sensor detection) is interfaced through WebSockets with geventwebsocket module.

Frontend Angular.js SPA.

I wrote a quick proof-of-concept app to make the whole system usable. Monterail is currently developing a new version of the office managing software with a team dedicated to it.

proof-of-concept app for office management

Could our smart office be smarter?

What do you think about our smart office system? What would you change? What could have been done better? Feel free to share your ideas in the comment section below.

Kamil Górski avatar
Kamil Górski