The last time I've been on holiday in an apartment for rent I found really annoying the need to pay on a daily basis the usage of the air conditioner. On the other side I understand the costs for the apartment owner, especially if some distracted guests keep the air conditioning on the whole day even if they are out, harming environment too with some totally useless energy usage.
So, like many other things we are accustomed to pay-per-use, why can't air conditioning be billed in such a way from apartment hosts? Problems arise from the difficulties to monitor the real AC usage, the need to transact money with apartment guests that have already paid on web platforms like Airbnb, and so on...
But seems IOTA can be very handy in such an use case!
That's why I built this prototype of an Air Conditioning controller that let people use the AC only by pre-paying some credit (sending some IOTAs to the device), then that credit is used to pay a small fee every minute of usage of the air conditioning unit. If the controller runs out of money AC gets simply turned off until guests will recharge the desired amount of IOTAs.
What are the features that such a system will provide to the house guests? After a couple of revisions of the initial idea, here are the two must-have for my project:
1) No need for complicated instructions. The deposit of IOTAs must be effortless and the usage of the unit as simple as possible.
2) Users should be able to manage the AC even when outside, like turning it on when leaving from the beach to reach a comfortable cooled apartment.
To accomplish these features the overall design of the system will have:
a) A screen that shows a QR code with the deposit address together with base status info of the system.
b) Just a single button to interact with, that switches on and off the air conditioning.
c) A web interface with a public URL to control the system remotely.
I realized the system to set up the proof of concept of my idea in my apartment, where I have installed a pretty modern Daikin air conditioning unit, that is connected to the LAN and is controllable over HTTP via its API for turning ON and OFF and to get the temperature of the room.
The system is modular, so can be easily extended to operate any kind of older infrared controlled unit with a couple of additional components, and that will be a goal for a future release.
I decided to adopt a Raspberry Pi 3 and to develop with Node.JS as programming language. For the physical interface I looked for an e-ink screen, the perfect technology to show information without any light emission from the screen that may be annoying in a small apartment. I found a nice HAT for the Raspberry that also already has my desired physical button, resulting in a perfect match for the specifications.
Last but not least I was wondering on how to avoid all the hassle of deploying, monitoring, configuring and set up the networking that is necessary when you want to expose a public webserver from your house (port forwarding, DynamicDNS configuration,...). I decided to try a pretty interesting service that comes for free: BalenaCloud. Long story short: you need to flash a downloaded custom image of BalenaOS on your Raspberry and turn the board on. The magic happens and you see the status of your board online, you can deploy new version of your software over the air and you have a custom URL to communicate with your device over HTTP.
IOTAIR in action:
1) A person approaches the controller and there is no credit on it, so any attempts to turn on the air conditioning with the ON/OFF button will fail:
2) Through any kind of wallet the user deposits some iotas to the address displayed with the QR. The device is always listening for transactions so it will react when money arrives and update the available balance:
3) Now an attempt to turn on the air will succeed, and every minute a small fee is paid from the balance:
4) User can turn off the air conditioning, and stop the billing, by pressing the ON/OFF button:
5) Or the unit will stop automatically if no more credits are available to pay the fee:
6) All the operations can be done through the Internet with the web interface:
Here is a brief description of the overall architecture of the system to help you bootstrap the project code that's public available here.
I have intentionally pushed in the repository my development configuration settings, so all you have to do to run your own instance of IOTAIR is to clone the repositorty and run
To customize your instance just change what needed in file
config/default.yml. The available settings are:
- iota.nodeUri: URI for the IRI node.
- iota.nodeZmqUri: URI for subscribing to the ZMQ port of the IRI node to listen for transactions.
- iota.seed: the super-secret seed that will be used to generate addresses where user will top-up their credit. Really better for you to generate your and keep it secret when not playing on the IOTA devnet.
- airconditioner.enabled: if set to false the controller won't call the real HTTP endpoint of the air conditioner, for development purpose.
- airconditioner.baseUrl: HTTP endpoint for the Daikin air conditioner.
- airconditioner.tickDuration: the minimum unit of time that is billed (in milliseconds).
- airconditioner.tickCost: the cost for a single unit of time (in iota).
- server.port: the port for the web interface.
- server.user: username to authenticate user to the web interface
- server.password: password to authenticate user to the web interface.
The whole system is made of five modules:
- Payment Manager: handles the IOTA wallet of the devices and the routines for the automated payment (file
- Thermometer: software module that polls the room temperature. In my setup the AC unit exposes the temperature on a HTTP API, so you will find the HTTP implementation of that module (file
src/thermometer.js). If nedeed it can be easily substituted with a class with the same signature that polls an hardware temperature sensor (like a TMP36, or DS18D20) on the free GPIO pins of the Raspberry.
- Remote Controller: software module that is responsible for sending commands to the air conditioner. In my setup commands are sent to the AC unit via HTTP, so you will find the HTTP implementation of that module (file
src/airConditionerRemoteController.js). To control many other types of unit it can be extended with an IR receiver and an IR LED to let a generic air conditioner to be controlled by copying the ON and OFF commands from its infrared remote controller.
- Physical Interface: this module reacts when a user press the ON/OFF switch that turns air conditioning on and off, and renders all the information on the e-ink screen. (file
- Web Interface: the web server module exposes a public web page, protected with configurable username and password, that replicates all the information and the ON/OFF command that are on the physical interface (file
To get all of the features up&running on your Raspberry with Balena Cloud follow this simple steps:
1) Subscribe for a free account at https://dashboard.balena-cloud.com/signup
2) Login to the dashboard and create your application, name it "Iotair".
3) Add a device to your application: set your WIFI details here and download the OS for your device.
4) Flash the downloaded OS on your SD Card, put the card in your Raspberry and turn it on.
5) After some seconds your device will appear in your dashboard, enable its "PUBLIC DEVICE URL" in the detail page.
6) Install the Balena CLI utils from https://github.com/balena-io/balena-cli on the device where you cloned the project source files.
7) Login your shell to your Balena.cloud account running
8) Deploy your application over-the-air to your Raspberry with
balena push Iotair
Done! You application should start soon, see your Raspberry logs in your device detail page on Balena Cloud and access the web interface of the air conditioner at the PUBLIC URL you enabled at step 5.