Author Topic: Oak Electricity Consumption Shield  (Read 13864 times)

djflix

  • Newbie
  • *
  • Posts: 24
Oak Electricity Consumption Shield
« on: February 03, 2016, 08:12:09 am »
Because since recently I'm in charge of my own energy bill I was curious about my electricity consumption throughout the day. I have an old fashioned disc-type meter and I've read some guides and pages on measuring current consumption with an Arduino. I've always found Arduino WiFi to be expensive and relatively unpractical. But now I have two Oaks!

I'm creating a shield (or should I say 'motherboard'?) for the Oak which allows me to measure my power consumption, and periodically report these measurements using the WiFi connectivity. In the future it might send me notifications if I forget to turn off a device (power consumption is above a set threshold for example), or profile the changes in consumption and correlate these to usage patterns of the fridge, for example.

Today I've designed a board, and I've put it online on github and ordered 3 pcs on oshpark. The code is also included in the repository and, of course, anyone who would like to add something to the project is very welcome :).

The board has the following features:
- Socket for an SSD1306 (I2C) OLED Screen
- 4 Buttons so I can create a user menu for 'off-line' usage and calibration/status display (buttons will probably be '-', '+', 'OK', 'Cancel', or something like that)

Any ideas or feedback? I'm all ears!
« Last Edit: February 04, 2016, 12:46:05 pm by djflix »

DeuxVis

  • Full Member
  • ***
  • Posts: 107
Re: Oak Electricity Consumption Shield
« Reply #1 on: February 04, 2016, 02:01:15 am »
Just being curious, why are the oak connecting holes slightly misaligned on your pcb ?
It could work if you intend to put headers there and bend their legs a bit, but it's intriguing.

djflix

  • Newbie
  • *
  • Posts: 24
Re: Oak Electricity Consumption Shield
« Reply #2 on: February 04, 2016, 02:29:54 am »
It's to keep the headers in place while soldering. With regular holes the headers tend to wiggle a little bit and sometimes this results in headers not pointing exactly straight up. This is probably due to me not having the right tools to keep them in place, but I really like the way I'm able to populate all the headers, flip the board over, and then solder them all in one go without having to use a breadboard or something to keep the headers in place.

DeuxVis

  • Full Member
  • ***
  • Posts: 107
Re: Oak Electricity Consumption Shield
« Reply #3 on: February 04, 2016, 02:34:08 am »
Oh right, that makes sense. Nice tip.

djflix

  • Newbie
  • *
  • Posts: 24
Re: Oak Electricity Consumption Shield
« Reply #4 on: February 04, 2016, 12:44:42 pm »
Today I made some progress in creating a basic sketch. Thanks to the efforts of squix78 on his esp8266-oled-ssd1306 project I'm able to make a flying start on the display part! I also added a basic calculation for getting the current power consumption based on the interval between pulses from the power meter. Still need to verify that the calculations are okay, a few simple tests seemed to confirm this.


djflix

  • Newbie
  • *
  • Posts: 24
Re: Oak Electricity Consumption Shield
« Reply #5 on: February 09, 2016, 10:58:27 am »
I've just pushed some changes to the code. I believe that it is in usable state for a proof of concept! Unfortunately I'll have to wait a few weeks until my boards arrive. For now I've been able to do the following:

- Change pulse/button reading to interrupts attached to the relevant pins.
- Use DEFINES for pin numbers for buttons and input
- Fixed some bugs in the power consumption calculation
- Increased the time between screens
- Allow the user to switch between screens (forward and backwards) by pressing buttons
- Lower drawing CPU tax by not drawing bitmaps in overlays

Of course the list of stuff I want to add is long, and my code is far from pretty. But my extra order of Oaks has been dispatched, so I'm a happy camper anyway! Yay!

djflix

  • Newbie
  • *
  • Posts: 24
Re: Oak Electricity Consumption Shield
« Reply #6 on: February 16, 2016, 12:42:56 pm »
Today I've received the Oak Boards! They look awesome! Unfortunately I've got my soldering iron at work, so I won't be able to test them till tomorrow. I also pushed some updates because the 0.9.3 firmware for the Oak came out, and this means I'm now able to use delay() properly. I also added some extra yield()'s to the code, it looks like the code is interrupted less for wifi-work during the display loop.

Because I was having some issues with Arduino 1.6.7 I reverted to 1.6.5, and unfortunately subdirectories seem to be incompatible with 1.6.5, so the fonts I use are now back in the root directory of the project.

Also: the code now publishes to Particle Cloud variables, so the current power consumption as well as the total counter can now potentially be read from an REST API :)

djflix

  • Newbie
  • *
  • Posts: 24
Re: Oak Electricity Consumption Shield
« Reply #7 on: March 13, 2016, 09:14:46 am »
It's been a while since my last update, so here's my work from the past few weeks:

- Created a web service that provides the current unix-timestamp-format time (check it out here: http://tiwtieapp.azurewebsites.net/now?format=json Yeah, it's that simple :)).
- Added web server to the project (using ESP8266WebServer.h)
- Created a page that can be bootstrapped from a CDN. As the Oak is connected to the internet anyway I didn't see a reason why I couldn't use a minimal HTML page to load external content.
- The OakPowerBoard can now be controlled by a (simplistic) API that is implemented on the bootstrapped web page. I attached a screenshot of the Oak config page in it's current state (simple!).
- Overall stability improved by fixing some small bugs (mostly related to negative delays and stuff...)
- Improvements in project structure (moving pieces of code from the main .ino to separate files)
- Temporarily removed the code that detects pulses as it's based on using a digital input, and the sensor actually is analog. Need to fix that soon
- To help in fixing the above point, I added a "calibration" screen where you can see the highest, lowest and current measurement of the sensor.

So now I just have to fix the sensor detection and then I can continue adding features :).

Also: I've received the v2.0 boards (without the hardware issue) and they look GREAT! They even seem a little more stable on the measurements (which probably has nothing to do with the dirty hack I had to pull to be able to use the v1.0 boards ::). I've also ordered some more premium headers for the SSD1306 display, so some of the issues (flickering, loss of display) have been fixed now :).
« Last Edit: March 13, 2016, 09:16:52 am by djflix »

Z69

  • Newbie
  • *
  • Posts: 28
Re: Oak Electricity Consumption Shield
« Reply #8 on: March 22, 2016, 05:32:30 am »
Hi djflix

Love to project.
What is the chance of adding SH1106 display support?

djflix

  • Newbie
  • *
  • Posts: 24
Re: Oak Electricity Consumption Shield
« Reply #9 on: March 22, 2016, 12:13:18 pm »
Hi djflix

Love to project.
What is the chance of adding SH1106 display support?

Thanks! I've not considered the SH1106 yet (didn't know of it's existence until right now). It's currently not supported by the library I use ( https://github.com/squix78/esp8266-oled-ssd1306 ) but as soon as I get all the "base" functionality working with the SSD1306 I might consider adding support for that (and maybe other displays). If time allows I'm looking to use u8glib, but as esp8266-oled-ssd1306 actually works 'out of the box' on the Oak I decided to go with that for now :).

Z69

  • Newbie
  • *
  • Posts: 28
Re: Oak Electricity Consumption Shield
« Reply #10 on: March 22, 2016, 11:07:46 pm »
Hi djflix

Yes, I am based in South Africa and thinking of using your unit to monitor Power and Water, we don't have gas available to our homes  :(, we have to buy in cylinders.

Z69

  • Newbie
  • *
  • Posts: 28
Re: Oak Electricity Consumption Shield
« Reply #11 on: March 25, 2016, 08:30:48 am »
Hi djflix

I managed to find a 0.69: SSD1306 oled and got it to work on your code.
Not to figure out how to use it...

djflix

  • Newbie
  • *
  • Posts: 24
Re: Oak Electricity Consumption Shield
« Reply #12 on: March 25, 2016, 09:53:04 am »
Hi djflix

I managed to find a 0.69: SSD1306 oled and got it to work on your code.
Not to figure out how to use it...

You know that the code isn't finished yet, right? ;)

Z69

  • Newbie
  • *
  • Posts: 28
Re: Oak Electricity Consumption Shield
« Reply #13 on: March 28, 2016, 04:05:39 am »
Hi djflix

Yes, i saw that it is still WIP, but as i am more a hardware man, this will help with the firmware that i would like to get going to monitor "Water and Lights"