Week 7 – Display model – Josh Milkins & Richard Channing

This week our aim was to get our prototype to a point where it could be displayed while showing off its functionality.

We wanted to keep it simple so that it could display the different types of lighting found in the Warwick arms. We purchased a simple desk lamp and some smaller LED lights representing the ceiling lights and ambient wall lighting respectively.

PROTOYPE 3

No lights on

Main & Wall On

Main and wall lights on

Main On

Main light on, wall lights off

Wall On

Main light off, wall lights on

 

Only 2 of the relays are in use for the model, representing section one, but the code will still work for sections two, three and four but the only visual feedback is an audible click and an illuminated LED from the respective relay.

The first relay switches the main light with the command “alexa, turn on section one main lights”

The second relay switches the wall lights with the command “alexa, turn on section one main lights.

The remaining relays can be activated using the command “alexa, turn on section (2, 3 or 4) (main/wall) lights”

 

The Node MCU, Relay module and amazon echo are positioned to the side of the model to show how it works as well as enabling the user to see the relays actuate when commands are given.

Week 6 – Alexa Skill – Josh Milkins & Richard Channing

In order to enable more advanced functions and voice commands other than “alexa, turn (on/off) (device_name)” We need to create a custom alexa skill.

This is done by saying a command to alexa which then gets processed by the amazon alexa cloud service through the wifi router. A request is then sent to a heroku app over http (internet), this app then forwards the request from a windows websocket server to a windows socket client on the Node MCU. When the  Node MCU recieves this  request, it will set the requested relay high.

diagram.png

The hardware and circuit diagrams are exactly the same as blog post 5

First I had to setup a heroku app, this gave me a URL that i could paste into the arduino code in order for the app to send requests to the Node MCU.

Picture1.png

Here is the code;

https://create.arduino.cc/editor/JoshMilkins/d2b349d2-9157-470c-a866-3293225cc322/preview

I then needed to build an alexa skill,

first i gave the skill a name and invocation name (lightservice)

The invocation name is what will be said to alexa before asking it a command. For example “alexa, ask lightservice to turn on section one main lights” this is so alexa knows which skill it needs to use to request the command.

Picture6.png

I then need to make an intent which is essentially a command and under the intent i need to type in some sample utterances which is what a person would say to alexa in order to request an action. Mine were “turn on all main lights” and “turn section one main lights on”

Picture7.png

Because there are quite a number of possible commands that could be said to alexa, (6 sections, 2 states & 2 types of light) instead of listing all of these utterances, i can use slots to handle more than one option, they are parameters that get filled in automatically, when a command is given, it will look for the values of the slots and replace the variable words in the utterance’s.

The first slot is the different sections, the options are ‘one’ through to ‘six’  and ‘all’.

The second slot is the state, this is  either ‘on’ or ‘off’.

The third slot is the type of light, this will determine whether it’s a ‘main’ light or ‘wall’ light for that particular section.

By double clicking on a word in the utterance it’ll give you the option to change it to a slot. In this case i changed the word ‘one’ to ‘list_section’ the word ‘main’ to ‘list_type’ and the word ‘on’ to ‘list_state’

Picture2.png

I then need to set an endpoint for the alexa skill. This is HTTPS and uses the heroku URL used in the arduino code.

Picture8.png

The alexa skill is now finished, i just have to save and build it.

The next step is to test the skill using the Alexa skills kit built in alexa simulator. You just type of speak a command through a microphone and it’ll act just as a physical echo would, giving verbal and written feedback as well as the JSON code being input into the echo and output from the echo.

This however is where it failed giving me a ‘I am unable to reach the requested skill’ response and I did not find out how to fix this.

Picture9.png

Week 5 – Controlling Multiple Devices – Josh Milkins & Richard Channing

Continuing the use the emulated WeMo device we used an 8 channel relay module in order to control the multiple lights that would need controlling in a pub/bar environment.

We were having some trouble with the NodeMcu Lua V3 as mentioned in the previous post so we bought a more expensive MCU which had a different breakout board but the same ESP8266 wifi module (pictured below). This proved to be much more reliable.

29680514_10210881381981487_994460861_o

 

Home Automation Alexa NodeMCU_bb

IMG_20180326_142652

 

https://create.arduino.cc/editor/JoshMilkins/df1682a9-8f6f-4741-b7ed-db8385978dfa/preview?embed

 

 

Because the MCU took a 5v USB power source and regulated it to 3.3v on board, we couldn’t use the VCC pin to power the relay module which required 5v. In order to continue with the above experiment we had to use a laptop to power the MCU and an external 5v power supply to power the relay module.

Later we discovered we can use a bi-directional logic level converter which is a small device that safely steps down 5V signals to 3.3V and also steps up 3.3V to 5V at the same time.

We bought the sparkfun module where each level converter has the capability of converting 4 pins on the high side to 4 pins on the low side with two inputs and two outputs provided for each side. The board needs to be powered from the two voltages sources (high voltage and low voltage) that the circuit is using. High voltage (5V for example) to the ‘HV’ pin, low voltage (3.3V for example) to ‘LV’, and ground from the circuit to the ‘GND’ pin.

 

The Fritzing diagram now looks like this;

30441222_10213767984128484_1726037813121515520_o

Week 3 – Integrating Alexa – Josh Milkins & Richard Channing

The Brains

The WIFI enabled MCU in question is the NodeMcu Lua V3 – pictured below

IMG_20180326_143523

This is not an arduino board, nor does it use the same ATMega328 chip that arduino uno’s use. But it can be flashed (programmed) via the arduino IDE using the same version of Javascript. much like arduino, it has a built in serial FTDI interface to program the MCU. It has 9 GPIO (general purpose input/output) which are the pins that can be programmed via the arduino IDE. It runs at 3.3v as opposed to 5v and has built in esp8266 WIFI chip.

 

Alexa & The Internet of Things

In this project we are also using Alexaan intelligent personal assistant developed by Amazon Lab126 (amazon’s research and development department), made popular by the Amazon Echo and Echo-Dot.

Alexa is capable of voice interaction, music playback, making to-do lists, setting alarms, streaming podcasts, playing audiobooks, and providing weather, traffic, and other real time information. Alexa can also control several smart devices using itself as a home automation hub. We will use on this project, the Echo-Dot that allows users to activate the device using a wake-word such as “Alexa”.

In the home automation environment, Alexa can interact with several different devices such as Philips Hue, Belkin Wemo, SmartThings among a few more. In our case, we will emulate the WeMo.

What is WeMo?

WeMo is a series of products from Belkin International Inc. that enables users to control home electronics from anywhere. The product range includes a switch, motion sensor, Insight Switch, light switch, camera and app. The WeMo Switch can be plugged into any home outlet, which can then be controlled from an IOS or Android smartphone running the WeMo App, via home wifi or mobile phone network. We will be emulating the smart switch and will control it over wifi via alexa.

 

How the Emulation Works

Okay so this isn’t the most interesting of topics but it’s necessary to understand exactly how alexa talks to the arduino.

The WeMo devices use UPnP to perform certain functions over the network. The device detection function starts out with the Echo or Dot searching for WeMo devices using UPnP. The device then responds to the Dot with the device’s URL using HTTP over UDP. The Dot then requests the device’s description using that HTTP URL. The description is then returned as an HTTP response. The actual “on/off” functionality of the WeMo devices is simpler since the Dot already knows about the device. The Dot simply connects to the WeMo over the HTTP interface and issues a “SetBinaryState” command. The WeMo then obliges and returns a confirmation via HTTP. See the Echo/Dot Communication diagram below.

Glossary of terms;

UPnP – Universal Plug and Play is a set of networking protocols that permits networked devices to seamlessly discover each other’s presence on the network and establish functional network services for data sharing and communications.

URL – A Uniform Resource Locator is a reference to a web resource that specifies it’s location on a network and a mechanism for retrieving it.

HTTP – The Hypertext Transfer Protocol is the foundation of data communication for the World Wide Web.

UDP – With User Datagram Protocol, computer applications can send messages to other hosts on an Internet Protocol (IP) network.

FEETRN8J0IEE08M.LARGE

 

Week 4 – Controlling a Single Device – Josh Milkins & Richard Channing

During this week we use the NodeMcu Lua V3 wifi enabled micro controller unit which was discussed in the week 2 blog post and integrate an Amazon Alexa to turn on and off an LED. We wanted to do this as we believe it is the first step into being able to control lighting through the IOT.

Below is a fritzing of the circuit:

First fritz

Using this we then went and wired it up. Here is a picture and video of the result:

IMG_20180326_142744

We powered Alexa using the USB power supply from our laptop while the wifi module and Led were powered from a separate computer. Below is a link to the code for this set up:

https://create.arduino.cc/editor/RJChanning/23de7abd-b1c7-436d-afc1-2dfc7131655e

An issue we did face was that the NodeMcu Lua V3 wifi module board proved somewhat unreliable however we feel like this is due to the breakout board as the Esp8266 module itself is the industry standard for wifi enabled MCU’s.

 

 

Week 1 – Research – Josh Milkins & Richard Channing

The Our Idea

Our idea is to decrease energy usage in a pub/bar environment. We intend on doing this by using an interactive service to turn off lighting in unoccupied areas of the pub/bar.

In order to make the service interactive we would use an amazon alexa to communicate with a wifi enable MCU (micro controller unit)

Testing Out the Context

We visited the Warwick Arms, Clutton to test out how our idea would translate into a real word application. We looked at the user interaction (UI) and user experience (UX) to establish whether this would persuade people to conserve energy by turning off lights that aren’t needed. We also looked at how much energy this would save and what benefit this would have.

Different sections withing the pub:

30714483_10211015358250810_6289283674261159936_n

Section 1 – Snug Room

Number of ceiling lights: 13

Number of wall lights: 4

30708696_10211015357970803_2072226676988706816_n

Section 2 – Breakfast Area

Number of ceiling lights: 13

Number of wall lights: 5

30713551_10211015358530817_5639071190954803200_n

Section 3 – Main dining area

Number of ceiling lights:20

Number of wall lights:4

30729750_10211015357850800_4083841164883525632_n

Section 4 – Bar seating area

Number of ceiling lights:9

Number of wall lights:7

30713826_10211015358410814_2821528380845850624_n

Section 5 – Main Foyer & drinking area

Number of ceiling lights:12

Number of wall lights:9

30726876_10211015357730797_8874550710222454784_n

Section 6 – Pool room

Number of ceiling lights:4

Number of wall lights:7

Floor Plan;

Floor plan.png

All of these lights are on from open until close which uses quite a large amount of energy. In total there are:

Ceiling – 71 light

Wall  – 36

Below shows the current energy consumption:

Current Energy use chillwortharms

As you can see there is quite a large amount of energy being used each day, even without considering the cost of using this much energy it isn’t sustainable. Going forward we shall be aiming to make this much more cost and environmentally friendly.

Below is a video showing the user interaction of the concept and how it would work in reality.