Library Chair

From ESE205 Wiki
Revision as of 22:11, 11 December 2017 by Nb275 (talk | contribs) (→‎Results)
Jump to navigation Jump to search


It's a Wednesday night. You're sitting in your room watching Netflix, putting off studying for your exam next week. You're cozy in bed, and it's cold and dark outside, plus your suite-mate just said he's ordering Domino's and there might be a slice or two left over for you. Every fiber of your being is willing you to stay home, eat, and watch TV, but that nagging voice in the back of your head tells you that you're a Wash U student damnit, and you'd better take this exam seriously! So you muster up some energy and get the kid on your floor who is in the class with you to walk to the library and study for a bit. When you guys get there, though, you see that every seat in the library is taken! ARGH!!

Few things are more annoying than when you decide to actually go study but then can't because there isn't an open spot for you in the library. Enter the Library Chair. In simple terms the Library Chair system consists of an interactive chair and a web interface. The chair can detect when someone is sitting in it, and this information is then relayed (via a few arduinos and a raspberry pi) to a website which displays a map of all the chairs in the library and which ones are occupied. You can check this website from the safety and comfort of your own room; no more cold walks to the library that end up being futile!

For more specific information on how the system operates, please look at the "Design and Solutions" section of this wiki.

Library Chair Log

Team Members

Nick Blenko
Tom Howe
Josh Zucker
Our wonderful TA, Mo Wu
And our adviser, Professor Morley


Our group's main objective is to create an interface that library goers can use to see which seats in the library are available, and which are occupied. This interface is dependent on voltage data obtained from a circuit hooked up to an arduino and affixed to the bottom of a library chair. When a human body moves close to the circuit, i.e when someone sits down in the chair, the output voltage changes and chair occupancy can thus be determined. This circuit will then communicate occupancy and location data to another arduino connected to a raspberry pi. The raspberry pi will in turn communicate this data to a web server. We are aiming for the circuit/arduino device to be accurate, low energy, and completely powered by solar panels.

As individuals we are simultaneously working on a few different smaller goals. These include: finalizing the circuit that will detect when someone is sitting in the chair, figuring out how to communicate effectively between the arduinos and how to generate the wave function necessary for the circuit to operate from an arduino, integrating a solar power source into the circuit, communicating data from the raspberry pi to a web server, and designing and implementing an aesthetically pleasing web interface.


  • Learning how to use the TI microcontrollers. This proved to be too difficult, so we adapted and used arduinos instead.
  • Rebuilding the circuit after someone burned it in the lab
  • Getting accurate current and voltage readings from solar panels/batteries
  • Needing to find a new ADC solution after realizing the built in arduino ADC was not powerful enough

Gantt Chart

An outline for the breakdown of duties and the timeline of the library chair project.


  • Chair: Cost Varies - (donated by Professor Morley)
  • Raspberry Pi: $35.00

  • Solar cells: $8.69

  • Resistors/Capacitors/Diodes: (provided by school)
  • Wire: (provided by school)
  • Web Server: $12/Year

  • Bluehost Account $3.99/Month

  • RF Link Receiver (433 MHz) $4.95

  • RF Link Transmitter (433 MHz) $3.95

  • 2x Arduino Uno - one provided by school, one bought at link below for $27.95

  • External 16 bit ADC converter 14.95

  • Rechargeable Batteries $19.98

Total: $139.44 (Total assumes 1 year subscription to web server and 3 month subscription to bluehost account)

Group Presentation

Link to the presentation

Design and Solutions

Module #1: Detect whether someone is in the chair

1.1 Construct RC circuit that outputs variable voltage depending on total capacitance

We first have a regular RC circuit with one metal plate acting as a parallel plate capacitor, where the other plate is effectively the rest of the universe. When a human body comes close to the circuit, its electric field increases the capacitance of this plate. This increased capacitance increases the time constant of the RC circuit, which means that in the same interval of time this altered circuit does not output a voltage as close to its peak voltage as it did before. In other words, when a human body is close to the circuit, it outputs a lower voltage.

Figure 1.1 - The circuit used to detect occupancy based on peak voltage in the circuit.

Figure 1.1 - The circuit used to detect occupancy based on peak voltage in the circuit.

1.2 Manage voltage flow going into circuit

After prototyping on the NI Elvis, we determined that the best form of input voltage to the circuit would be a 5V square wave with a frequency of around 800kHz and a duty cycle of 50%. (For help prototyping on an NI Elvis board see our tutorial Since a square wave is always either ‘on’ or ‘off’, this input means that the capacitor is always either charging or discharging, which lets us get more consistent output voltage readings from the circuit. We determined the optimal frequency through trial and error and striking a balance between signal magnitude and signal noise: using a higher input frequency led to a noisier output voltage signal, but using a lower frequency led to less of a change in voltage.

800kHz is an extremely high frequency, though, considering that the arduino uno cpu has a clock speed of 16MHz, so we searched for a library that could be of use and found this: . However, we struggled to implement it correctly, and further testing showed that we would only need a frequency of around 50-70 kHz.

We used pulse width modulation on the arduino's digital pin number 6 (as seen in figure 1.1) to supply this square wave. The default frequency for pulse width modulation on digital pin 6 is 976.56 Hz, and the default voltage is 5V. In order to increase this frequency, we reduced the PWM prescaler value on the TCCR0B timer register to 1 from a default of 64, thereby increasing the frequency by a factor of 64. (For reference see:

Here is the code we used to generate the 5V 63kHz square wave input:

void setup() {
pinMode(6,OUTPUT); //initializes function generator pin
TCCR0B = TCCR0B & B11111000 | B00000001; // sets timer 0 divisor to 1, freq=62.5kHz

void loop() {
analogWrite(6,128); //sets up square with with duty=50%

1.3 Measure voltage flow exiting circuit, and analyze to determine occupancy

We initially tried to use the arduino's built in 10-bit analog-to-digital converter. Using the minimum reference voltage of 1.1V and 1023 'steps' of specificity (2^10 = 1024), gave us a step size of ~1mV. Since we were dealing with changes in voltage (voltage when chair is occupied vs voltage when chair is vacant) on the order of microvolts, we needed another solution. We found a compatible 16-bit external ADC converter ( and wired it up as shown in figure 1.2. This converter has about 65,000 'steps' of specificity (2^16~65000), enabling detection of voltage changes as small as 0.0002V. We wired in a differential connection to the external converter, which is more favorable than a single-ended connection when trying to reduce noise. In order to accurately interpret this very noisy data, we had to implement a multi-tiered rolling average filter to smooth the data. The exact voltage cutoff values signifying either occupancy or vacancy are dependent on the composition and the environment of the chair, and as such need to be tested for and updated whenever the circuit is affixed to a new chair or the chair is moved.

The code to read in voltages using the external converter and then determine vacancy/occupancy using multi-tiered filters can be found here:

Figure 1.2 - The external 16-bit analog-to-digital converter used to take voltage readings from the circuit.

Figure 1.2 - The external 16-bit analog-to-digital converter used to take voltage readings from the circuit

1.4 Integrate arduino and circuit and attach to chair

We used a solderless breadboard to connect the Arduino to the RC circuit, the external ADC converter, and an RF transmitter. We made these connections as shown in figure 1.1, figure 1.2, and figure 2.1. The circuit-arduino system is shown in figure 1.3. In order to improve the aesthetics of the system, we designed and 3D printed a case (figure 1.4) to cover up all the wires and circuitry. We then screwed this case to the underside of the chair, and stuffed the metal plate from the RC circuit inside the stuffing of the chair in order to get readings most effectively.

The circuit/arduino system

A rendering of the case for the Arduino and circuit.

Figure 1.3 The circuit/arduino system. Figure 1.4: A rendering of the case for the Arduino and circuit.

1.5 Power the Arduino/circuit with solar power and batteries

In order to get the Arduino powered our plan was to use a system of batteries and solar panels. The batteries would be the main source of power to the Arduino and the solar panels would recharge the batteries. We ended up using 6 1.2V 2400mAh batteries, wired in series, to supply the proper voltage to the circuit along with 7 680 Ohm resistors wired in parallel, to avoid overheating, to supply the proper current to the Arduino. We attached 5 4V 80mA solar panels, wired in parallel to create a 4v 400mA system, to the batteries at the junction between the batteries and Arduino. The positive end of the solar panels was wired with a diode to prevent voltage from the batteries from going into the panels. The way the panels were wired they would provide energy to either the circuit, if it needed it, or to recharging the batteries. There were two main issues with the power. The first issue was the fact that the voltage supplied from the batteries was 7.2V while the voltage supplied by either a computer or socket was 9V, although the Arduino functions fine with 7.2V the values we were getting from the peak detector were different and we did not have the time to find the new values. The second issue with the power was the fact that the solar panels that we got were not powerful enough to recharge the batteries in a timely manner. The current supplied by the panels meant that the batteries would end up draining faster than they could be recharged. In the future more powerful solar panels could prevent this from happening.

The system of batteries and Solar Panels used to power the Arduino. Figure 1.5 - The battery and solar panel system used to power the Arduino.

Module #2: Relay occupancy data to attractive web interface via raspberry pi

2.1 use RF communication to send data from one Arduino to another

In order to relay data between the arduino on the bottom of the chair and the arduino attached to the raspberry pi we purchased a pair of 433Hz transmitter/receiver modules ( and We encoded transmission and reception using the virtualWire library ( We started out using sample code from , and for our final code borrowed from as well. We wired up the modules with help from . The final code we used to transmit and receive occupancy data can be found here on page 3. We designed a protocol whereby the chair number and the occupancy data relating to that chair can be sent in 1 byte: if the chair is unoccupied we transmit the chair number, and if the chair is occupied we transmit the chair number plus 128.

The wiring of the receiver to the arduino can be seen in Figure 2.2 (and also at

Figure 2.1 - The RF Transmitter used to send data from the Arduino that detects occupancy to the Arduino connected to the Raspberry Pi.

Figure 2.1 - The RF Transmitter used to send data from the Arduino on the chair to the Arduino connected to the Raspberry Pi

Exhibit B - the wiring of the receiver module

Figure 2.2 - the wiring of the receiver module

2.2 communicate from the Arduino to the raspberry pi

Communication from the 'receiver' arduino to the raspberry pi was done through a serial connection using code from .

2.3 use data input into the raspberry pi to create a handsome web interface displaying which seats are occupied and which are not

input tom's python code and procedural steps


    • insert screenshots of code and pi connections**

There were a few steps in setting up our Raspberry Pi server that would relay information from the Arduino to the website interface.

  • Downloading basic Raspberry Pi code (NOOBS) onto a microchip
  • Launching the Raspberry Pi using USB inputs of a keyboard and a monitor
  • Operating a VNC viewer to develop code for the Pi and HTML code for the interface side by side
  • Creating code on the Pi such that it automatically launches on a computer (in VNC Viewer) if connected only by Micro USB Power Source
  • Building code on the Pi server that would be able to automatically rewrite HTML code based on input
  • Writing code in the server that would allow for communication with the Arduino

Initial Launch of the Pi

Necessary Materials

  • Raspberry Pi 3
  • Micro USB (power source)
  • Micro SD card
  • Monitor
  • Mouse
  • HDMI Cable

To initially launch the server, we must first download the necessary preliminary coding found on the official Raspberry Pi website. We do so by using our Micro SD card and plugging it into a USB port on a computer with internet access. We then make sure the Micro SD is clear of all information (if reusing a Micro SD card, be sure to clear using formatting protocol explained on website **insert instructions/reference**). We then download the code off of the website, move the downloaded files to USB input, and wait for the information to copy. We then safely eject the Micro SD card and remove it from the USB. NOOBS is now loaded onto the Micro SD Card.

We then connect the Raspberry Pi to its power source by connecting the Micro USB to the Pi and a Computer (any power source would suffice). We connect a keyboard and a mouse to the Raspberry Pi through USB, and connect the Pi to a monitor using an HDMI cord so we can operate the pi. Now that NOOBS is downloaded and the Pi is fully plugged in, we may code on the Pi as if it were a computer.

VNC Viewer and Automatic Launch of the Pi


  • Downloading VNC Viewer
  • Identifying Raspberry Pi IP address
  • Enabling VNC viewer on the Pi
  • Editing the Pi start code to include connecting to the VNC Viewer

Building Pi Code to Automatically Rewrite HTML Code

  • Connecting the Pi to Wifi
  • Using Beautiful Soup function
  • Plugging in location of output in corresponding Pi and HTML code

Communicating with Arduino


  • Setting up wired connection between Arduino and Pi
  • Writing program in Pi **attach code** that allows for Arduino connection


To create the interface, we first bought the domain We then got a third party account at BlueHost, where we could manage our domain. In order to upload code to the domain, it involves creating an FTP account, using Filezilla to upload to that FTP account, using Atom to write code in html so it is compatible with the FTP account, and being able to grab the data from the RaspberryPi server.

Our steps:

  • Generate functional HTML code in Atom
  • Save the HTML code in index form to be compatible with Firezilla
  • Set up the connection between the Firezilla account and the online server's account and IP address
  • Upload the FTP file to Bluehost


By the demo the chair worked. Although there was a lag of 15-30 seconds between the occupancy status of the chair changing and that change being registered on the website that was due to the Low-Pass filter on the Arduino to filter out the noise of the circuit and the time it took for the voltage in the peak detector to change. The lag is not an issue given that someone looking on the website to see if there are any open chairs in the library will take more than 30 seconds to get to the library in the first place.

The first goal that our group failed to accomplish was the use of solar power/batteries to power the circuit. We got the solar panels and batteries hooked up and were able to run the Arduino on the power from the batteries and panels but the values that we were getting from the proximity detector circuit were different as the voltage feeding into the Arduino was different than when it was plugged in. Given more time we would have been able to find the correct range of voltages for the Arduino to be run off of battery power, but as we could not have the Arduino connected to the computer to give us a display of the voltage values while being powered off of the batteries it would have taken a long time to find the correct window.

The other goal that we were not able to accomplish was using the TI board provided by Professor Morley.

Other than the lag and power source there were no issues with the chair, and other than the power source and TI board we met all of our goals. The circuit consistently was able to detect proximity, the Arduino was consistently able to tell what voltages represented occupation and non-occupation and transmit that to the Arduino connected to the Raspberry Pi, the Pi was consistently able to update the server which in turn was constantly able to update the website. Although there were a lot of independent parts in the project, they all came together and worked to produce a consistent working chair.

Link to our poster displayed at the demo (click on the PDF icon)

Figure 2.1 - The RF Transmitter used to send data from the Arduino that detects occupancy to the Arduino connected to the Raspberry Pi.