Building a Beta Sensor

Hardware Required

3D Printable Case

Build Process

Assemble Hardware

The first step in getting to a working Measure the Future sensor is to assemble the hardware needed. Begin with the Raspberry Pi, the SD Card, the PiRTC unit, and the Coin Cell Battery.

  1.  Insert the Coin Cell into the PiRTC Unit, with the + side (the flat side) facing up. (photo)
  2.  Slide the PiRTC into place on the Raspberry Pi unit. (photo)

Install Software

Install Raspian onto the micro SD card.

  1. Download the March 2017 version of Raspian
  2. Flash Raspian to the SD card using a computer. I recommend using Etcher. This will take some time.
  3. Create an empty file named “ssh” (or download this one) and copy it to the drive named “boot” on the SD card (you should see this drive after Raspian finishes installing). You want the file to be named just “ssh”, with no extension. This enables you to connect to the RPi over the network via SSH.
  4. Eject the SD Card from your computer

Prepare Raspian for Measuring the Future

  1. Insert the card into the bottom of the Raspberry Pi.
  2. Plug the RPi into your network, and then plug it into a power source.
  3. Wait for your RPi to boot, then locate its IP address on your network.
  4. Once you know the IP address, you should be able to connect with ssh pi@IP_ADDRESS, for example ssh pi@192.168.0.42
  5. The default pwd for the Raspberry Pi is raspberry…we will change that in a future step. 🙂
  6. Once you are into the system, the first thing we need to do is make sure the RTC module is identified, change the user password, and make sure the file system is expanded. To do this, you need to enter the RPi setup utility via sudo raspi-config and then:
    • Scroll to Change the Password
    • Select that option, and change the password for the pi account. DO NOT FORGET THIS PASSWORD.
    • Apply
    • Open config again via  sudo raspi-config
    • Scroll to Advanced Options
    • Select, then choose
    • Apply…it may ask you to reboot at this point. If so, do so, then log back in and return to raspi-config
    • Scroll to Interfacing Options
    • Select, then choose Enable/Disable automatic loading of I2C kernel module
    • Select that option, apply it, and finally….
    • Reboot if prompted, and then log back in using your new password.
  7. Next we ensure that Raspian knows which updates it has….
    1. Run sudo apt-get update and wait for the process to finish.

Install Measure the Future!

    1. Run wget https://raw.githubusercontent.com/MeasureTheFuture/installer/master/mtf-pi-install.sh
    2. Run chmod +x mtf-pi-install.sh to make the just-downloaded file executable.
    3. Run sudo ./mtf-pi-install.sh to install Measure the Future.
    4. There will be three prompts at the end of the install process. One for a database password, one for a Wifi name, and one for a Wifi password. Fill these in as you wish, but _do not forget them_.

Enable the Real Time Clock module

This next section requires editing a couple of text files on the RPi. I’m sorry..will do my best to get a process in place ASAP that makes this bit easier.

  1. Run sudo apt-get install python-smbus i2c-tools
  2. Then run sudo i2cdetect -y 1 and you should see ID #68 show up in the resulting screen. If you do, the RTC is physically in the right place on the board.
  3. Run sudo nano /boot/config.txt
  4. Scroll to the bottom of the file and add a new line that is: dtoverlay=i2c-rtc,pcf8523
  5. Save file (Control-O) and exit (Control-X)
  6. Reboot the system via sudo reboot, and give it a few seconds, then log back in via SSH and your new password.
  7. Run sudo i2cdetect -y 1 and you should now see UU where the 68 used to be
  8. Run sudo apt-get -y remove fake-hwclock
  9. Run sudo update-rc.d -f fake-hwclock remove
  10. Now one last edit of a file: sudo nano /lib/udev/hwclock-set
  11. The lines near the beginning of the file that read

    if [ -e /run/systemd/system ] ; then
    exit 0
    fi

    need to be commented out…add a # to the beginning of each of those lines so they look like this:

    #if [ -e /run/systemd/system ] ; then
    #exit 0
    #fi
  12. Once more, save (Control-O) and exit nano (Control-X)
  13. Run date and verify that the time/date is correct
  14. Run sudo hwclock -w to push that time/date to the RTC unit

That’s the end of software setup!

Optional Configuration

In some instances, you may wish to have the SSID of the sensor hidden, to prevent patron confusion and questions if they attempt to connect their devices to the wifi signal. This is easily done, but does make it more difficult to see if the sensor is “on” because you cannot see the SSID and must attempt to connect if you wish to see the sensor. If you wish to hide the SSID:

  1. Run sudo nano /etc/hostapd/hostapd.conf
  2. Scroll to the bottom of the file, and add the line: ignore_broadcast_ssid=1 to the bottom of the file.
  3. Save (Command-O) and exit nano (Command-X)

Now, when you reboot your sensor, the SSID will not be visible to users. In order to connect, you’ll have to tell our computer to look for that SSID manually.

Final Steps

Plug the USB Webcam into your Raspberry Pi. If you’ve printed a Measure the Future Case, the final result will look something like this:

You can now move on to Configuring the sensor to measure activity and attention in your space.