Users Guide » History » Revision 57
« Previous |
Revision 57/67
(diff)
| Next »
Hammel, 03 Oct 2019 18:19
Ironman Users Guide¶
This document is under development and is likely not accurate at this time. |
- Table of contents
- Ironman Users Guide
In this document the term host system refers to a Linux desktop or laptop that will be used to download and install software onto an SD card.
Overview¶
Ironman is a home automation project based on the PiBox build system. It supports a Nest-like monitor for controlling Arduino based sensors, cameras and remote voice control.
Design Intent of the Ironman Project |
Mark I release is in progress. Mark II and Mark III are future development plans. |
Ironman consists of the following components.
Monitor | The Nest-like control hub based on a Raspberry Pi 2/3 and the official 7" touchscreen display |
Sensors | Arduino based devices, such as door alarms and cameras, running code based on a sensor and camera templates for pairing and secure communication with the Monitor |
Jarvis | A Java application that supports voice control of Monitor managed devices |
Controllers | Network enabled control of Monitor managed devices |
Security¶
Ironman supports AES encrypted communication with IoT sensors and Jarvis interfaces.
What it is¶
Ironman is a do-it-yourself system, where you buy the parts and assemble them as described, modifying the provided code to suit your needs and handling flashing and maintenence. Ironman is designed to allow you to build your own home automation system where you specify the devices you want to control and how you want to control them.
What it is not¶
Ironman is not a product. It is not intended for anyone other than Makers (aka DIY'ers) who like to tinker and see not just how to assemble things but why they actually work.
While the Users Guide is intended to bring up a currently working version of Ironman with limited sensor and camera support, if you aren't prepared to deal with writing code or flashing devices and dealing with electrical circuits then Ironman is not for you.
The Ironman Monitor¶
The Ironman Monitor runs on a Raspberry Pi 2 or 3 and provides a central hub for management of home automation devices. It uses a 7" touch screen display and a mechanical switch to manage pairing with IoT devices and Jarvis interfaces.
Installation Prerequisites¶
- A Raspberry Pi 2 or 3
- The official Raspberry Pi 7inch touchscreen display
- The Pi 2/3 requires a V / 2A power supply. For best results, use a power supply rated to at least 5.25V to avoid under voltage conditions. For ease of use the power supply cable should include an on/off switch.
- A keyboard is required for initial installation. A wireless keyboard should work as will a wired keyboard. The keyboard will not be needed for normal operation but can be helpful in debugging.
- The Pi 2/3 requires a microSD card that is at least 4GB. A mechanism for using the SD card on your host system is needed, such as an SD card USB adapter or an SD port on your laptop.
- A mechanical switch, such as a SPDT, should be connected to the Pi GPIOs to allow for pairing the Monitor with IoT Sensors and Jarvis interfaces. The ASCII diagram below describes the setup. The LED is off in normal mode, lit in Config Mode, and off in Pair Mode until something tries to pair with the Pi which then turns on the LED for 3 seconds. Config and Pair mode operations ared discussed in later sections. A Fritzing Diagram (IronmanMonitorSwitch.fzz) is available for this hardware component.
___ Config/Pair Mode |---| Normal Mode --------- | | --------- connector pins --> | | | | | ------ Not connected | | | ----330 Ohm R----- | | | | | +-----LED------ | | | RPi pin 7 9 13 RPi GPIO 4 G 27
- You will need to have sudo access for your Linux user id.
Generating the SD Card for the Pi¶
- Download the RPi 2 Development Platform
- wget <url>
- Unpack the archive to a directory called image.
- Download the Ironman Package Collection
- wget <url>
- Unpack the archive to a directory called package.
- In a terminal window run: dmesg -w
- Insert the microSD card and note the device name displayed for the newly added card as displayed in the dmesg -w terminal window. It should be something like /dev/sdb or /dev/sde.
- Kill the dmesg -w command with Ctrl-C.
- Format the SD card
- sudo ./mksd.sh -d <device name>
- where <device name> is the name you noted from the output of dmesg -w.
- Mount the boot partition from the sd card:
- sudo mkdir -p /mnt/boot
- sudo mount <device name>1 /mnt/boot
- where <device name> is the name you noted from the output of dmesg -w.
- Install the Development Platform to the SD card
- sudo ./mkinstall.sh -b /mnt/boot -d <device name>2
- where <device name> is the name you noted from the output of dmesg -w.
- Mount the root partition from the sd card:
- sudo mkdir -p /mnt/root
- sudo mount <device name>1 /mnt/root
- Copy the Ironman Package Collection files to /root of the root partition on the SD card
- sudo cp *.opk /mnt/root/root
- sync;sync;sync
- sudo umount /mnt/boot
- sudo umount /mnt/root
Remove the SD card from the host system and insert it into the Raspberry Pi 2.
First time boot¶
Power on the Monitor and wait for it to complete installation. During this time the display may be upside down. Once initial installation is complete the display will be right side up.
Once the display shows two xterm windows it is ready to complete installation. Type the following command to install the Ironman package collection.
opkg install *.opk
Wait for this command to complete, then reboot the system either by power it off and back on or by typing the command
reboot
The Monitor is now fully installed and ready for use. At this point the keyboard can be removed though you may want to leave it connected for debugging purposes.
First time configuration¶
Turn the power off and set the Mode switch to Config/Pair, then power the Monitor back on. The LED should light indicating the Monitor is ready to be configured.
Use a smartphone or laptop with wifi to connect to the "ironman" SSID. The default password is ironman1. Then use a browser to connect to the Ironman web UI at
http://192.168.36.1:1337
The display should be as shown in the adjacent photo. There are two network domains to configure, as described in the following table.
Domain | Description |
---|---|
Internet Connection | This is how the Monitor will connect to your home network. |
Sensors Network | This is how the Monitor will communicate with your IoT devices. |
After both networks are configured, power off the Monitor and set the Mode switch to Normal, then power the Monitor on. The Monitor is now ready to use with IoT sensors, Jarvis and controllers.
Network configuration¶
The Monitor's hardware supports WiFi B/G/N networks. However, in order to use the Monitor as both a WiFi client on the local
network and as an Access Point for IoT devices, only G networks are supported by the Ironman software.
Internet Connection¶
The Internet Connection domain configures the Monitor to connect to your local network.
Field | Description |
---|---|
Location | Unique name for this monitor, such as Bedroom or Office. This name is used to identify monitors by name via commands from Jarvis or other remote controllers |
SSID | Network name configured on your router for your local WiFi network. |
Security | Type of security used on your router. Only WPA2 Personal and WPA2 Enterprise are currently supported. |
Password | Your router's password, specifically for the SSID entered previously. |
The Show Password button will display the password typed in the Password field. By default this button is not enabled, causing the Password field to be hidden using asterisks for each character.
Sensor Network¶
The Sensor Network domain is used to configure the Monitor's private network used with IoT devices. Data on this network is not routed to the Internet Connection and data from the Internet Connection domain are not routed to the Sensor Network.
Field | Description |
---|---|
SSID | Network name for this private WiFi network. This name will be hidden on Wifi scans. |
Channel | Channel to use. Select a channel that has low use in your neighborhood. Only a subset of channels on G networks are available. This will be addressed in future releases. |
Password | Password IoT devices should use to gain access to the specified SSID. |
Static IP | An IP address to give the Monitor as it acts as an Access Point. This should be a Class C subnet for the network, which limits the number of IoT devices that can be managed by a single Monitor to 254. |
The Show Password button will display the password typed in the Password field. By default this button is not enabled, causing the Password field to be hidden using asterisks for each character.
IoT Sensor¶
Sensor Types¶
There is currently only one sensor type: imlightsw (light switch).
The sensor template GIT repository, which is the imlightsw repo, is intended to be used to design additional sensor types, such as door and window alarms, window shade controllers, environment sensors and so forth.
Light Switch
¶
This prototype light switch (imlightsw-with-relay-2.fzz) uses a relay to power an LED on and off. The breadboard power supply can be replaced with an HLK-PM01 and an LM3671 5V to 3.3v buck converter to power the board from mains (110v).
The FTDI connection is used to connect and FTDI Basic board so that a the output from the ESP-01 can be viewed in a terminal program.
The ESP-01 has a Blue LED that is used to provide visual information using blink patterns.
Config Button¶
This button has multiple uses, depending on where it is used.
AP Config Mode
AP Config Mode means the device is running as an WiFi Access Point, allowing you to connect to it via a web browser to configure the device for use on a Monitor's Sensor network.
- AP Config mode is disabled by default, that is, when the Config Button is in the off position.
- If Config Button is ON at boot, imlightsw enters AP config mode. In this mode the LED will blink twice and then stop. Once the device is connected to a Monitor's Sensor network it will blink 4 times.
- After configuration is complete, button must be set OFF and device power cycled.
Pair Mode
Pair Mode is used to pair the imlightsw device with an Ironman Monitor. Pairing involves the exchange of secret keys that will be used to encrypt messages between the Monitor and the imlightsw device.
- The Config Button is OFF at boot.
- Later the Config Button is turned on and imlightsw enters PAIR mode. In this mode the blue LED stays on.
- After the device has paired with a Monitor the blue LED blinks.
- The Config Button must be turned off for normal operation.
Blue LED Blink Patterns¶
A blink implies the LED turns on and then off.
LED State | Blink Speed | Blink Count | Device Mode |
---|---|---|---|
Blink | 1/sec | 2 | Entered AP Config Mode |
Blink | 1/sec | 4 | Device is connected to monitor |
Blink | 1/.125 sec | 5 | Device failed to connect to monitor |
Solid On | N/A | N/A | Entered Pair Mode |
Blink | 2/.150 sec then 1/.200 sec | continuous | Waiting to Pair with Monitor |
Blink | 1/.100 sec | 3 | Not currently paired with Monitor |
Reset Button¶
The Reset Button is used to return the imlightsw to it's initial state, prior to configuration and pairing. If the device is reset it will need to be configured to use the network again as well as paired with an Ironman Monitor before it can be managed.
- The Reset Button is ON at boot.
- The device removes all configuration from itself.
- The Reset Button must be turned off, then the device can be rebooted and reconfigured.
The Reset Button is not connected in code currently due to the limit on GPIO pins in the ESP-01. To fully reset the ESP-01 you must compile the code with RESET=1, flash and run the code, then recompile with RESET=0 (or not specified on the command line) and flash again. |
Setting up to use the code¶
Prerequisites¶
- ESP-01 connected to your serial port using an FTDI board
- Try the one from SparkFun
- You have proper power to the ESP-01
- Other parts you might want
- ESP-01 breadboard adapter
- Logic Level Converter
- 5V 1-Channel Relay board
Arduino Setup¶
This build doesn't use the Arduino UI. It makes use of GNU Make to build the code without the UI. However, it still requires components provided via the Arduino UI distribution, along with extra libraries.
- Make a directory to hold required repository clones - call it repos.
- Change to repos
- Clone the esp8266/Arduino repository
- git clone https://github.com/esp8266/Arduino.git
- cd Arduino
- git checkout tags/2.1.0
- cd ..
- Clone the makeEspArduino repo
- git clone https://github.com/plerup/makeEspArduino.git
- cd makeEspArduino
- If ESP_ROOT points to a symlink but doesn't use a trailing slash: git checkout d13cf13602f2acc9be3baa3315911a4c037dc62d
- Otherwise: git checkout tags/4.13.0
- cd ..
- Install libraries
- cd Arduino/libraries
- clone extra libraries (see Required Libraries below)
- If your USB/FTDI connector shows up as something other than /dev/USBFTDI then set SERIALDEV
- export SERIALDEV=/dev/_your device_
- aJson has a [bug with flush()](https://github.com/interactive-matter/aJson/issues/89) that prevents compilation. Apply the patch found in the lightsw repository's patch directory.
Required Arduino libraries | URL |
---|---|
AES | https://github.com/spaniakos/AES/ |
Timer | https://github.com/JChristensen/Timer.git |
WiFiManager | https://github.com/tzapu/WiFiManager.git tag: 0.12 commit: 04d47882a7d662b46bb1b1dbecfe786e5bc9efa4 |
aJson | https://github.com/interactive-matter/aJson.git Requires patch in patch/ directory. |
aREST | https://github.com/marcoschwartz/aREST.git |
arduino-base64 | https://github.com/adamvr/arduino-base64 Requires patch in patch/ directory. |
- cd esp8266/libraries, then clone the extra libraries there
- AES library: Remove the examples or the build will probably fail.
The imlightsw Code¶
The code is required to do flash updates to the ESP-01. Before starting, be sure to install cdtools.
- Clone the software: git clone https://gitlab.com/xarduino/lightsw.git
- Copy lightsw/docs/arduino.sh to your cdtools directory (~/bin/env) and edit as appropriate.
- Be sure to set ESPTOP as described in arduino.sh.
- Setup your environment for the build:
- . cdtools
- ard lightsw
- cd? (to see what you can do with cdtools in this repository)
- Change to this repos directory: cdx
Flashing the firmware
¶
This prototype light switch flasher (imlightsw-flasher.fzz) is used to program the ESP-01. A separate flasher circuit like this is required due to the limited number of GPIO pins on the ESP-01.
The FTDI Basic board is required to connect the ESP-01 to a computer over a USB port. On Linux, the port will show up as /dev/ttyUSB0 or similar.
The code must be built before it can be flashed to the ESP-01.
- make
- Binary is in ../bld/*.bin
- make RESET=1
- This causes stored data in the ESP-01 to be erased on power up. After that, you need to reflash without this flag.
- make SERIAL=1
- This causes the code to use the TX line for serial output for debugging purposes. If this is not set then the blue LED is used instead and there is not serial console output.
Finally, to flash the updated image to the ESP-01 use the upload target.
- make upload
- upload target is in makeEspArduino.mk, not in local Makefile.
Power On¶
An IoT sensors must be configured to operate on the same network as the Monitor's Sensor Network. Once this has been done the IoT sensor and the Monitor can be paired. An IoT device can only be paired with a single Monitor.
Configuring an IoT Device to the Sensor Network¶
The IoT device has it's own WiFi Access Point at 192.168.4.1 with no password. This is used to configure the device to connect to the Monitor's Sensor Network.
- Set the Mode button to Config.
- Power on the IoT device.
- Connect a laptop or smartphone to the imiot SSID. An IP will be assigned automatically to the laptop or smartphone.
- If connecting to the imiot SSID does not automatically open a browser page to the IoT device's WiFi configuration page, then manually open a browser to http://192.168.4.1.
The configuration page looks like the image to the right. This page has multiple options. Only the first is needed to configure to the Sensor Network.
- Click on ...tbd...
- A scan of local WiFi access points will be shown.
- Choose the SSID configured for the Monitor's Sensor Network.
- Type in the password configured for the Monitor's Sensor Network.
- Click on ...tbd...
At this point the device will attempt to connect to the Monitor and retrieve an IP address. Wait about 1 minute for this to complete.
- Turn the IoT device off.
- Turn the Mode button to Normal.
- Power on the IoT device.
The device is now ready for pairing with the Monitor.
Pairing with a Monitor¶
- With the Monitor running, set the Monitor Mode switch to Pair.
- Power on the IoT Sensor and wait for it to pair with the Monitor. When it's done, the LED will light for 3 seconds.
- Disable the Mode switch on the Monitor.
WARNING! |
Leaving the Mode switch turned to Pair will allow random devices to attempt to pair with the Monitor. This is a security risk. The Mode switch should only be set to Pair long enough to pair with an IoT device. |
Jarvis¶
Prerequisites¶
Pairing with a Monitor¶
- With the Monitor running, set the Monitor Mode switch to Pair.
- TBD
Supported Commands¶
Addendums¶
Ironman Packages¶
Package | Repository | Contents | Description |
---|---|---|---|
imcore | monitor | Package that updates a PiBox Development Platform for use with Ironman. Includes network configuration updates and other config files. | |
imwww | www | Contains two web servers | |
imwww | Provides network configuration interface for Monitor | ||
imrest | Provides IoT/Jarvis REST API. Updates /etc/ironman directories with registrations. | ||
imgpio | gpio | Command line tool for querying GPIO pins using syfs interface. | |
launcher | launcher | Ironman specific launcher that adds clock interface to front panel. | |
pisensor | pisensor | Provides UI for managing sensors. Uses inotify to watch for changes to /etc/ironman/iot directory. | |
picam | picam | Generic console camera interface (same as PiBox media systems) | |
Misc | appmgr, piboxd, omxplayer, pmsui, psplash, mjpg-streamer | Same packages as in PiBox media system, unmodified |
Source Code Repositories¶
- PiBox
- Ironman
- Arduino
Fritzing Models¶
- ESP-01 Flasher: imlightsw-flasher.fzz
- Light Switch: imlightsw-with-relay-2.fzz
- Monitor Switch: IronmanMonitorSwitch.fzz
Networking Internals¶
wlan0 * This interface is used for configuration of the Monitor. * Configured on the 192.168.36.0 subnet. ** See /etc/network/dhcpd.conf.aponly uap0 * This interface is used as an access point for IoT devices. * Configured on the 192.168.3.0 subnet. ** See /etc/network/dhcpd.conf.uap and dhcpd.conf.uap.tmpl ** The template is used to change the base subnet through the web interface. ** The SSID is _ironman_.
Pair Button Usage¶
Pair/Config button is GPIO 4 (RPi pin 7) Pair/Config LED is GPIO 7 (RPi pin 13) LED should only be lit on boot if button is enabled (in Config mode). In this case, we're in Config Mode to configure the networks. The web server (imwww) is on SSID _ironman_ at 192.168.36.1:1337. LED is off on boot if button is disabled (in Pair Mode). If in Pair Mode Start hostapd for aponly Start dhcpd for aponly on wlan0 Start imrest web service on port 8165 for IoT devices and Jarvis interfaces. If in Config Mode Start wpa_supplicant on wlan0 Create uap0 device as virtual device on wlan0 Start dhcpd on uap0 Start hostapd on uap0 Start imwww for network configuration of the Monitor.
Monitor IoT Directories¶
/etc/ironman/iot Registration directory for IoT devices /etc/ironman/jarvis Registration directgory for Jarvis interfaces
Privileged Apps¶
Some applications must be privileged in order to perform their functions, such as the camera. The terminal application is not privileged by default. It can be made privileged with the following steps.
- Power down the Monitor.
- Remove the SD card and mount it into your laptop or desktop computer.
- Edit this file on the SD card: /etc/appmgr.priv
- Add this line: /usr/bin/xterm
- Save the file and unmount the SD card.
- Remove the SD card from the laptop or desktop.
- Replace the SD card in the Monitor.
- Power up the Monitor.
The terminal application will now have privileged access on the monitor.
File Attachments¶
Updated by Hammel about 5 years ago · 57 revisions