Thursday, November 5, 2015

IoHeating Part 1


Recently I had a few days off from work and decided to solve one of the problems that had been bothering me throughout winter. Namely a cheap heater which had a temperature dial that was:
  1. Completely unlabeled
  2. Driven by a large loud low accuracy thermostat.
Instead of solving these problems by getting a new heater or off the shelf controller I decided to make things a little more interesting. That meant it was parts shopping time. 

If you are switching mains power you have two options relays and triacs. Triacs are a sextuple layer silicon switch similar to the better known transistor but compatible with alternating current. They are great because you can switch them many millions of time with no wear and because they are completely silent in operation. Relays are simply electronically operated physical switches. A triac would clearly be optimal here. A quick Google later and it turns out that the majority of parts for the hobbyist market are based around relays. I wanted to utilize one of these readily available parts because:
  1. When I have time off work I'm trying to be as lazy as possible
  2. Relays and triacs often need a drive transistor which I would have to solder on veroboard (eww)
  3. Isolation.
In New Zealand we use 240V AC in every country the AC transmission voltage is dangerous, here especially so. Isolating the low voltage electronics especially the controller (more on that soon) is important for safety and longevity. Fortunately electrocuting kids is very bad press so most of the hobbyist relay boards include a drive transistor AND an optoisolator. If you haven't come across these before I'm about to make your day.

Optoisolators are essentially a transistor where the gate is not electrically connected but optically connected. So on on side of the package you have an LED and on the other a transistor with a gate that is excited by photons not those dirty old electrons. This whole thing is packaged up in a nice black box that puts the input side far enough away from the output side that everything is electrically isolated and safe enough to lick (do not lick). We are actually using the same power supply for driving the relay and the controller so this doesn't actually make us all that much safer but it is still good to isolate our delicate IO lines from nasty physical things like relay coils.

Something like this.
So we have a switch that we can control. Now we need to know when to turn the heater on and off. The clunky old thermostat relied on a bimetallic strip to sense the temperature of the room. This sensor if you want to call it that is large and has an inherent hysteresis. We can do better. How precise does our temperature need to be half a degree you say? Perfect we'll use the DS18B20. This is one of the first digital parts I ever utilized. They are a robust, decently accurate, and voltage compensated sensor. Even better you only need a single IO line to talk to them due to the exceedingly well named "1-wire protocol". 

Finally time for the controller! Particle (previously known as Spark) are a group who have developed a seriously amazing little bit of kit. The Photon dev board. To boil it down. ARM microcontroller, WIFI 802.11n, Cloud API and development platform, ludicrously simple code and integrations, $20. Go and buy one right now.

So with our shopping list complete let's build our thing. Just so you know a couple of additional components will probably come in handy, those are.
  1. A heater with some space in it
  2. A power supply for your controller
  3. A high temperature insulation. Don't use heat shrink this is a heater. Instead use Sugru

With that the beautiful build is revealed! From top to bottom we have. A USB power supply from a hapless phone and behind it the Photon board. Below that we have the original heater switches and the thermostat. At the bottom you'll see the relay board and the actual heating elements. The relay board has been tapped into the AC power such that it can break the circuit to the heater whilst leaving the Photon board powered (clever huh). It is also wired in such a way that all the heater's original safeties are in place. The original thermostat (turned up to full), a thermal fuse (in between two of the elements you might spot it) and a thermal cut off at the other end of the element which isn't pictured. Also not seen the the DS18B20 as that is carefully located outside the case as to make it less susceptible to heat soak from the heater chassis. There are more pictures of the build here.




The genius of the Photon dev board is just how easy it is to step integrations between real world items like our heater and the world of data. For this project I used the build.particle.io development platform and whipped up a simple firmware that knows how to turn the heater on and off, how to measure the temperature from our temperature sensor.

There were a couple of small complications discovered whilst writing the code.
  1. I didn't read the datasheet for the DS18B20 temperature sensor quite well enough you need to use a pull up resistor to get the 1-wire communication working with the Photon. No issue that five minutes with a soldering iron can't fix.
  2. Our relay board likes to turn on but doesn't like to turn off. To deal with this one we can get away with setting the IO line to INPUT_PULLDOWN this soaks up any stray electrical potential and makes sure the relay optoisolator and thus the relay returns to the off state.
Want to have a look at how simple this was to implement or even spare yourself that effort and copy it for your project? Go right ahead and read this gist of heater code. Just remember that you'll have to use the library include system in Particle Build to add the libraries listed at the top of the source.



At this point we have a heater that can turn on and off at the whim of anything that can use a REST protocol. While using a web browser to turn a heater on and off is pretty cool that isn't going to cut the mustard in this connected world. What we need is apps! lots of apps. Well maybe just one. Next post I will tell you about the application below.


Friday, July 17, 2015

It lives!


OK after two false starts I present Wear GBC, play games from your favorite mid nineties portable game console on your Android Wear device. Try out QBert (free and legal) http://www.1000klub.com/Qbert/

https://play.google.com/store/apps/details?id=org.bostwickenator.android.weargbc

Thursday, July 16, 2015

Google Play Rejections

Google Play now has a team of actual living humans checking through every app submission. Unfortunately this can lead to exchanges like the one I just concluded today. As with all email chains start reading at the bottom.


From: Alexander Gee <bostwickenator@gmail.com>
Date: Fri, 17 Jul 2015 at 11:50
Subject: Re: [5-6184000007874] Your appeal for reinstatement
To: <googleplay-developer-support@google.com>

This is a very frustrating process. I hope that it is reviewed and augmented soon. Communication via this mechanism is clearly very constrained by regulations against you providing advice. This saddens me.

I will resubmit the app under a different name without the button. Thanks for trying to help me as much as you can within your constraints.

On Fri, 17 Jul 2015 at 11:38 <googleplay-developer-support@google.com> wrote:
Hello,
Unfortunately, the violation on the application was still present after conditionally reinstating the application.  Previous email states, "Please remove any violations prior to resubmitting your application."  We will not be reinstating your applications because the conditions were not met.  
If you do choose to re-publish a new, policy-compliant version of your app, please make sure to review the Content Policy and visit the Policy Help Center for additional guidance to ensure your next app is compliant with the policy.You will need to upload a new apk as a new app with a different package name, that is an updated version of the app you are trying to publish to the Google Play Store.
If we can assist you further, please let us know.

Regards,
Arya
The Google Play Team
On 07/16/15 15:11:43 bostwickenator@gmail.com wrote:
Ok I'll remove the button. I did previously comment on the mis-identification of those softwares as protected works (they are explicitly offered as free by the owners). Since my appeal was approved directly after this I assumed that meant after further review you were in agreement with my statement. A misinterpretation on my part. If it will make this process simpler I'm happy to remove the button. Sorry for the further complication this has caused.

On Fri, 17 Jul 2015 at 09:13 <googleplay-developer-support@google.com> wrote:
Hello,
Thanks for contacting the Google Play team.

After further review, your app will not be reinstated because it violates the intellectual property and impersonation or deceptive behavior provision of the Content Policy:

- Our policy states: 

  • Your app and/or elements of its listing on Google Play, including title, description, logo(s), or promotional screenshots must not include unauthorized usage of protected works belonging to a third party.
  • Your app icon and promotional screenshots must not contain images that appear confusingly similar to existing products.
  • Protected work could typically include product names, brands, images, logos, music, and similar works.
- As an example, your app contains: Currently, your application lets users download copyrighted content via the "Get Roms" button within your application.  The violation was not removed in the latest submission and the violation STILL exists.


If you publish a new version of your app, please make sure it’s in compliance with our policies. You may want to review these resources for additional guidance:

Content Policy:
https://play.google.com/about/developer-content-policy.html

Google Play Developer Help Center:
https://support.google.com/googleplay/android-developer/answer/113474
Regards,
Arya
The Google Play Team
On 07/15/15 18:12:09 bostwickenator@gmail.com wrote:
Arya, I resubmitted it and it got kicked again. WHAT DO I DO?
On Thu, 16 Jul 2015 at 11:02 <googleplay-developer-support@google.com> wrote:
Hello,
Thanks for contacting the Google Play Team.

We’ve conditionally accepted your appeal and your app has been reinstated. Please remove any violations prior to resubmitting your application. For the app to appear in the Play Store, you’ll need to sign into your Developer Console and submit your app again.

Please let us know if you have any other questions or concerns.

Thanks for supporting Google Play!
Regards,
Arya
The Google Play Team

On 07/14/15 19:44:49 bostwickenator@gmail.com wrote:
Hi Arya,
That link directs people to a site devoted to homebrew games. Files that are written for demonstration purposes or fun and released freely and publicly. It is there explicitly to discourage users from downloading content protected by copyright.
If you wish I can remove it and resubmit. Would it at that point meet your criteria?
Your advice here would be appreciated,
Alex

On Wed, 15 Jul 2015 2:27 pm  <googleplay-developer-support@google.com> wrote:
Hello,
Thanks for contacting the Google Play team.

After further review, your app will not be reinstated because it violates the intellectual property and impersonation or deceptive behavior provision of the Content Policy:

- Our policy states: 

  • Your app and/or elements of its listing on Google Play, including title, description, logo(s), or promotional screenshots must not include unauthorized usage of protected works belonging to a third party.
  • Your app icon and promotional screenshots must not contain images that appear confusingly similar to existing products.
  • Protected work could typically include product names, brands, images, logos, music, and similar works.
- As an example, your app contains: Currently, your application lets users download copyrighted content via the "Get Roms" button within your application.

If you publish a new version of your app, please make sure it’s in compliance with our policies. You may want to review these resources for additional guidance:

Content Policy:
https://play.google.com/about/developer-content-policy.html

Google Play Developer Help Center:
https://support.google.com/googleplay/android-developer/answer/113474

If I can be of further assistance, please let me know.
Regards,
Arya
The Google Play Team

On 07/14/15 01:58:28 bostwickenator@gmail.com wrote:
first_name: Alexander
last_name: Gee
registered_email_address: bostwickenator@gmail.com
abuse_type: ip
package_name: org.bostwickenator.weargbc
appeal_reason: There are no trademarks for Wear or GBC. There are various
apps on the Play Store using both of these terms in their name. All works
were produced by me or credited correctly: one image under CC:A v3 from
(http://cyrilmottier.com/2014/07/31/android-wear-flat-device-frame/),
several packages under GPL (https://code.google.com/p/kiddgbc/) and LGPL
(https://github.com/spacecowboy/NoNonsense-FilePicker/blob/master/LICENSE).
Thank you for your reconsideration.
subject_hidden: Your appeal for reinstatement


:---- Automatically added fields ----:
Language: en-GB
IIILanguage: en-GB
auto-helpcenter-id: 203
auto-helpcenter-name: googleplay/android-developer
auto-internal-helpcenter-name: androidmarket
auto-full-url:
https://support.google.com/googleplay/android-developer/contact/appappeals
auto-user-logged-in: true
auto-user-was-internal: false
IssueType: appappeals
form-id: appappeals
form: appappeals
subject-line-field-id: subject_hidden
body-text-field-id:
AutoDetectedBrowser: Chrome 43.0.2357.132
AutoDetectedOS: Windows Windows NT 6.3
MendelExperiments: 10800005,10800027 

Starting

It occurs to me that I have never had a blog devoted to software development. Quite strange considering how much of my life I spend working on that. This blog will rectify that.