Java9+ and NodeJS are required to run the application. Gradle is also required but handled by Gradle wrapper and so will install automatically. This application also needs to be running on the Matrix Creator device.
If you are starting fresh on a new Raspberry Pi, you need to be sure to setup your Matrix Creator device and install the code required for Matrix Lite
- First, walk through the Matrix Creator Device Setup page available from Matrix.one
- Next you will need install Matrix HAL on your Pi. This is required for Matrix Lite which is what we will be using for our data bridge into Swim.
- Now you can install Matrix Lite. Be sure to install the JavaScript version since we will be using NodeJS in this example.
We need java 9 or higher for swim. On Raspian Stretch we also need to add a new source in order to be able to install the correct version of Java. Follow the instructions below to add the new source.
Add deb source url to source list
echo "deb http://deb.debian.org/debian stretch-backports main" | sudo tee /etc/apt/sources.list.d/debian.list
sudo apt update
sudo apt install dirmngr
switch to root and add key for deb.debian.org
sudo su -
gpg --keyserver keys.gnupg.net --recv-keys 7638D0442B90D010 8B48AD6246925553
gpg --armor --export 7638D0442B90D010 | apt-key add -
gpg --armor --export 8B48AD6246925553 | apt-key add -
exit
- git clone https://github.com/swimos/matrixOne.git
- cd matrixOne
- chmod +x *.sh
- ./setup.sh
- chmod +x server/gradlew
- ./runSwim.sh
- wait for app to start then hit ctrl-c
- ./runBridge.sh
- ./stopall.sh - this will kill both java and node
- Log files are written to project base directory.
- /bridge - code for data bridge from Matrix Lite to Swim
- /server - Swim Java Application codebase
- /ui - codebase for web based UI
- Main entry point is /src/main/java/swim/matrixone/MatrixOnePlane.java
- WebAgents live in /src/main/java/swim/matrixone/agents
- /agents/SensorAgent.java is the main WebAgent in the app. Each sensor on the Creator will have its own WebAgent (digital twin) in the Swim Application.
- This demo uses NodeJS to bridge sensor data from Matrix Lite into Swim. Data is passed to each sensor WebAgant inside Swim using Swim Commands. Any processing done on sensor data is handled inside the Sensor WebAgent in Swim.
- The bridge also handles updating the LED color by opening a link to the /settings/color WebAgent in Swim. When the UI sends new colors into swim, this downlink will automatically get those updates and pass it back to Matrix Lite to change the LED color
- Lastly the bridge sets up the LED animation inside updateLedAnim()
- by Default the application runs at http://[device ip]:9001
- Demo Pages can be found at:
- Color Picker: http://[device ip]:9001/colorPicker.html
- Sensor Data Gauges: http://[device ip]:9001/sensors.html
- WebGL Demo: http://[device ip]:9001/index.html
- Demo Pages can be found at:
- The Web UI can also be served by NodeJS instead of Swim, however we use Swim in this example to keep things simple.
- The Swim Javascript Library and UI Components are all vanilla JS with no 3rd party requirements. This makes it easy to integrate into existing code bases and use in the way that works best for your project or environment.