Introduction: Ci40 Relay Webapp
Creator Ci40 is the new IoT plaform developed by Imagination Technologies for a successful Kickstarter campaign.
Ci40 uses a dual core 550Mhz MIPS processor, 2 Gb of RAM and runs OpenWRT as operating system. In terms of connectivity the board provides: WiFi, Ethernet, Bluetooth and 6LoWPAN. In this project we will remotely control a desk lamp, using a relay.
Step 1: Requirements
Step 2: Connect the Relay
The relay works as a switch, allowing to control higher voltage circuits by low voltage circuits.
In this project we will control a USB desk lamp using the Ci40 and a relay. The relay can be used also to control another devices for example: a motor, a 230V lamp, etc. (Attention, always take safety measures when working with high voltage!!)
1. Connect the relay click to the Ci40
2. Cut one wire from the desk lamp and connect to the relay
3. Connect the desk lamp to power
Step 3: Setup the Working Environment
In this step we connect the Ci40 and access it via serial connection. In order to access the web interface to control the relay, the Ci40 should be connected to the same network.
1. Connect the Ethernet cable between the Ci40 and the network router. Plug the USB cable between the computer and the Ci40. Finally connect the power cable to the board.
2. Establish a serial connection between the computer and the Ci40. You can use putty or Linux console: $ sudo miniterm.py /dev/ttyUSB0 -b 115200
3. Install git (optional): $ opkg install git
4. Install node.js: $ opkg install node
5. Confirm the installation of node.js and npm(package manager):
$ nodejs --version
$ npm --version
Step 4: Download the Code and Test the Relay
If you installed git, just clone the repository from github: $ git clone https://github.com/hugo-santos-imgtec/ci40_relay_webapp . As an alternative you can download the ZIP file, transfer and unpack onto the Ci40.
The relay is controlled by a C code (main.c), using a library - LetMeCreate, developed specifically for the Ci40.Then you need to compile the code. This step is done automatically.
On the the project's main folder:
After compile the code, the next step is test the relay. We can connect and disconnect the relay passing the arguments - "ON" or "OFF" in the command line:
ON: $ ./main on
OFF: $ ./main off
Step 5: Build and Run the Web App
Finally to run the web app we need to install all the dependencies first.
On project's main folder, run:
1. $ npm install
2. $ npm start
Now that we have the web app up and running we can use another device, for example a tablet, to access the web interface to control the Ci40. First we need to discover the Ci40's IP address, you can use the android App Fing. Then using a browser, open the web interface (http://Ci40_IP_Addr:3000). Check the final result in the video :)