Posts

AI Tips

AI tips have finally made their way onto our test site, after having spent some time coding the hub to process the received data each second (using Python) and read from the files produced by this process when the tips dialog box is opened. The adjusted Python code for the hub is as follows: import os, pause from datetime import datetime def updateTips(): messages = ["outlet,message\n"] bad_usage = [] amazing_usage = [] rising_usage = [] lowering_usage = [] for file in os.listdir(os.fsencode("rates/daily")): outlet = os.fsdecode(file).replace(".csv", "") now = datetime.datetime.now() with open("totals/daily.csv", 'r') as file: data = file.readlines() line_number = [index for index, item in enumerate(data) if (outlet + ",") in item] daily_value = float(data[line_number[0]]) with open("totals/weekly.csv", 'r'

Hub & Outlet Housing

Image
We recently mocked-up the housings for both the hub & outlets - feast your eyes! Hub: Outlets: These housings will be fully waterproof. To preview how the site would look in your home, please see our demo site ; all of our code is available open-source on GitHub .

Website

Image
I've finished coding the website! I used the Material Design Lite Dashboard  template ( https://getmdl.io ), and made significant theme and content changes (including creating a dark theme, based on the two main colours in our logo - #1A1A1A & 006DCC). The dashboard now looks like this: It depends on the following resources: Material Design (material.min.js, material-theme.min.css) Material Icons (material-icons.css) jQuery (jquery.min.js) Morris JS (morris.min.js, morris.css) Raphaël (raphael.min.js) Palette JS (palette.js) jQuery CSV is used to retrieve the data from CSV files on the local server, and Morris JS (which depends on Raphaël) is for the charts that are created from the CSV data, and Palette JS is used to create an array of colours forming a rainbow for each doughnut chart. The charts are configured to update every second; the code is all available open-source  on GitHub . We are yet to implement the AI tips service, and are in the process of org

CSV Reading/Writing

We have recently finished coding the Python (used for writing to the CSV files) and jQuery (used to read them), and the code is available on GitHub . However, I include it here for convenience: Outlets: import socket import sys message = raw_input("Enter your message:") # Read message to be sent # Create a UDP socket sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) server_address = ('192.168.0.18', 6401) # Server's IP Adress and Port Number for Communication. try: # Send data print (sys.stderr, 'sending "%s"' % message) # Print the message to be sent. sent = sock.sendto(message.encode('utf-8'), server_address) # Send the message # Receive response print (sys.stderr, 'waiting to receive') # Listen for acknowlegement of file receival data, server = sock.recvfrom(4096) # Receive acknowledgement data print (sys.stderr, 'received "%s"' % data) #Print acknowledgement data fi

Move From XML To CSV

Recently, we were discussing our file structure and realised that XML files are unnecessarily complex - we were using the following structure: <livehousewaterusage> <appliance> <appname>sink</appname> <room>kitchen</room> <rate>55</rate> </appliance> <appliance> <appname>sink</appname> <room>bathroom</room> <rate>75</rate> </appliance> <appliance> <appname>toilet</appname> <room>bathroom</room> <rate>85</rate> </appliance> <appliance> <appname>bath</appname> <room>bathroom</room> <rate>80</rate> </appliance> <appliance> <appname>shower</appname> <room>bathroom</room> <rate>100</rate> </appliance> <appliance> <appname>shower</appname> <room>bathroom</room> <rate>

Radios

Image
We have decided to use XBee Wireless Shields, as they are cheap and seem to have adequate documentation for use with Arduinos. Thus, we set about finding how we would implement them. We found this webpage , which gave us an introduction to using the XBees, and it didn't take long for the radio to start transmitting. The code for the outlets is as follows: import socket import sys import time # read message to be sent message = raw_input("Enter your message:") # create a UDP socket with server's IP & port number server_address = ('172.18.0.10', 6001) while True: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) try: # Send data print (sys.stderr, 'sending "%s"' % message) # Print the message to be sent. sent = sock.sendto(message.encode('utf-8'), server_address) #Send the message # Receive response print (sys.stderr, 'waiting to receive') #Listen for acknowl

Flow Meter

We have got the flow meter working! With some simple code, we have managed to get the flow meter reading data, which we will eventually configure to be sent to the hub. The first hurdle in our project has been cleared! Next, we plan to code & test the radios... The code can be found on GitHub . To preview how the local site would look in your home, please see our demo site ; all of our code is available open-source on GitHub .