Installing and configuring the IoT Gateway

The IoT gateway for each room is a Pine64 singleboard computer that runs Armbian OS. It also acts as wifi accesspoint and router/gateway for the IoT devices in the room. This wifi is meant exclusively for the devices in the room though, and not for users.

To install it, you need to take the following steps (elaborated below):

  1. Flash the sd-card with our own Armbian imageate
  2. Configure a static IP address in the dhcp server on the smart-classroom production server for each gateway device
  3. Do the first-run stuff to setup ssh
  4. Run ansible for the smart classroom production server
  5. update the group_vars and hosts file for the smart_classroom_gateway devices in ansible
  6. run ansible for the smart-classroom-gateways

Setting a static IP in the dhcp server

  1. After flashing the SD cards, boot the devices with an ethernet cable plugged into a switch that is connected to the smart-classroom vlan.
  2. SSH to smart-classroom.foundationu.com and run
    less /var/lib/dhcpd/dhcpd.leases
    . This should show all the dynamic ip addresses. Including the ones for the Pine64's.  Get the hardware-ethernet addresses for them.
  3. logout
  4. go to your ansible folder. Edit group_vars/smartclassroom_prod
  5. In the dhcpd_static_hosts list, add an entry at the bottom for each Pine64. Set an ipaddress (just continue counting from the last one), it's ethernet address and name. Don't worry yet about which physical device corresponds to which name in here.
  6. Run
    ansible-playbook -i hosts smart_classroom.yml --limit=prod
    to update the production server with the new config.
  7. Power cycle the Pine64's. They should now get the new IP addresses.

First run

  1. After assigining a static ip address, you can login to the devices through ssh. The user is root and the default password is 1234.  The first time you log-in you need to change the root password. Just change it to 12345678 as  ansible will change it later anyway.
  2. After you changed the root password, it asks to create a new user. Exit out of this with ctrl-c. You get kicked out now, which is fine.
  3. Login back through ssh. Now make a folder ~/.ssh (with mkdir) and edit ~/.ssh/authorized_keys (using nano).
  4. In the file, add your public ssh key
  5. Log out again.

Updating and applying the smart_classroom_gateway config

  1. In the ansible folder: open the hosts file. Create an entry for each new device in the form of (without the < and >)
    [<hostname>]
    <ip.ad.dr.es>
  2. Make sure the hostname is the same as the hostname you set in the dhcp server config and the IP adress matches as well.
  3. Create a group for the new devices with [<groupname>:children] for instance like [sc_dorm_4thfloor:children]
  4. Add all the device names to that group
  5. Add the group itself to another group, that eventually leads up to smart_classroom_gateway_prod.
  6. Save and close the hosts file
  7. Make a file in group_vars for each device, by copying an existing SC_DORM_ file.
  8. Edit each file with ansible-vault edit <filename>  (password is in keepass)
  9. Change the wifi ssid and room name to the correct room name and wifi name in there. The room name must match the name it is called in the webapplication (case sensitive).
  10. run ansible with
    ansible-playbook -i hosts smart_classroom_gateway.yml --ask-vault-pass --limit=<groupname>

    where <groupname> should be replaced with the name of the group you created in the hosts file.
  11. After this ni

 

Relevant Specialties

This page is subject to our Disclaimer.