This tutorial will help you build a Web Application for measure UV-index using the MATRIX Creator and the Raspberry Pi.
The UV-index is an international standard measurement of the strength of ultraviolet (UV) radiation at a particular place and time.
MATRIX Creator componentsMATRIX Creator has a VEML6070 UV Light Sensor.
To use your MATRIX Creator you’ll need to set it up. First, you need to have Raspbian installed on your Raspberry Pi. If you don’t have it, you can download it and follow the instructions.
Then you need to install the software that will allow you to program the MATRIX Creator. To do it, you need to configure APT in the MATRIX Creator. The following steps should do it:
echo "deb http://packages.matrix.one/matrix-creator/ ./" | sudo tee --append /etc/apt/sources.list
Now update the package list.
sudo apt-get update
Then you can install the required packages.
sudo apt-get install matrix-creator-init matrix-creator-malos cmake g++ git
Now reboot the Raspberry Pi. After rebooting the FPGA and the SAM3 MCU will be programmed for you automatically. That is, after every reboot the FPGA will be programmed for you with the default firmware.
In order to use Hardware abstraction layer for MATRIX Creator (MALOS), it is usable via 0MQ with nodeJS, it's necessary to install ZeroMQ dependencies.
sudo apt install libzmq3-dev
Installation of nodeJS.You can use NodeJS from another computer (not the Raspberry) or from the raspberry itself. Check for the most recent version of Node.js, but today it is: https://nodejs.org/dist/v4.5.0/node-v4.5.0-linux-armv7l.tar.xz
You can download it, uncompress it and then change the default PATH.
For instance (in the Raspberry):
mkdir nodejs && cd nodejs
wget -c https://nodejs.org/dist/v4.5.0/node-v4.5.0-linux-armv7l.tar.xz
xz -d node-v4.5.0-linux-armv7l.tar.xz
tar xvf node-v4.5.0-linux-armv7l.tar
Now we are export nodeJS binaries into the $PATH
export PATH=/home/pi/nodejs/node-v4.5.0-linux-armv7l/bin:$PATH
In this version the binary is called node and not nodejs. The IPs used in the examples are 127.0.0.1
. Remember to edit them if you're accessing the Creator from another host and not from the Raspberry itself.
Make sure you have added Node.js directory in $PATH:, to clone source files and set up, run:
git clone https://github.com/matrix-io/matrix-creator-uv-demo
cd matrix-creator-uv-demo
npm install
Running MALOS serviceRun MALOS service with:
malos &
MALOS starting
**************
You can query specific driver info using port 20012.
Registered driver IMU with port 20013.
Registered driver Humidity with port 20017.
Registered driver Everloop with port 20021.
Registered driver Pressure with port 20025.
Registered driver UV with port 20029.
Running Web ApplicationWith MALOS service running , run web application with:
node index.js
Invalid configuration for UV driver.
Invalid configuration for UV driver.
New delay between updates for UV is 1000 ms.
New timeout after last ping for UV 6000 ms.
Sending pings every 5 secondslistening on *:5000
Message received: UV error: 0, Invalid configuration for UV driver.
Message received: UV error: 0, Invalid configuration for UV driver.
{ uv_index: 0.08567603677511215, oms_risk: 'Low' }
{ uv_index: 0.08567603677511215, oms_risk: 'Low' }
{ uv_index: 0.08567603677511215, oms_risk: 'Low' }
Now WEB Application are running on Raspberry Pi in its local host. Load it in you web browser in 5000 port. It means that you need to know the IP address. Run:
ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:af:3b:c9
inet addr:192.168.1.147 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::ba27:ebff:feaf:3bc9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:52613 errors:0 dropped:0 overruns:0 frame:0
TX packets:31663 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6581228 (6.2 MiB) TX bytes:5151704 (4.9 MiB)
Keep in mind this information. In your web browser write in the address bar IP_ADRRESS
:5000
MATRIX Creator Team
Comments