Prototyping a GUI for the HUG

On this page I will document the process of creating a GUI for the HUG made by Xiomara. I ordered a bunch of hardware to get started, always a joy when new nerdy hardware arrives! šŸ™‚

I ordered a Raspberry Pi with a LCD touchscreen (and some spare Arduino’s and ESP8266s ) to get started. After some software juggling I was happy to have the LCD up and running.

Next step is my first attempt in showing a fullscreen example based on an example from [educ8s]. This means I can now start on the actual interface front and back-end.

Before I start figuring out how to make kick-ass graphics appear on the screen I will start writing some code that allows me to interface with the available timers for the HUG and see how I can control them through some simple buttons and sliders. Which makes me think I need to figure out how to code a slider that outputs values between 0 and 254 for example. Let’s take a look…

Don’t you love google? I found that the python tkinter package has a neat little Scale widget that does exactly what I need!

Now let’s wait on those timers to see how to interface with them.

Meanwhile I have attached a USB serial to TTL adapter so I can transmit the values of the sliders to external devices. In this case I used a Arduino Pro Mini with a MicroView OLED attached to display the values.

I don’t know what format the timers expect the data to be in, but the current setup will be a good vantage point.

Update 29th of August 2016

Last week I received the box of timers and other switching & control electronics from Xiomara to sort through. I will describe each component based on what is written in the manuals (if present) and based on what I find out by means of testing.

After some quick tests I have been able to distinguish the components as follows (click on the component name to jump to the detailed test description):

  1. Xiomara 1502 – A generic timer & control panel that can be used to switch an IR lamp and a fain & cabin light.
    1. Interface – push buttons and a 4-digit 7 segment LED display
  2. A bluetooth control unit LDCB-B01 – To provide variable power to one output channel.
    1. Interface
      1. One push button to switch between 0%, 33%, 66% and 100% power
      2. An IR remote control with the following buttons: on, off, up, down and max power.
      3. An app (IOS and Android) to control power setting (continuously adjustable using a slider with 1/100th increments) and time untill the device turns off.
    2. Maximum power – 3000W
  3. A W325 Smart Control unit with an alpha wellness sensations interface – Elaborate unit to control up to 6 heaters and 3 auxillary devices (fans, lights, vaporizers, etc), multi-color light strip and music. The unit also has a temperature and humidity sensor.
    1. Interface
      1. Color LCD display with several push buttons to control all the parameters
      2. An admin app and a user app to control the parameters
  4. A timer designed by an engineer firm – Should be able to variably control two output channels.
    1. Interface
      1. One control panel with a start and stop button.
      2. One touch control panel used to control power and time

After some quick tests with all the components I have the following remarks for each component:

  1. Xiomara control unit 1502 – It’s a very basic and easy to use unit to simply switch any kind of mains powered device on and off, based on time and temperature.
    1. Pro’s:
      1. Basic & simple
      2. Temperature based control
      3. Additional output for fan & light (one channel)
    2. Con’s:
      1. No variable power control
      2. Not designed to be controlled externally
  2. Bluetooth control unit LDCB-B01 – A solid control unit with variable power output control which can be interfaced with using bluetooth, push button or IR remote control
    1. Pro’s:
      1. Solid and relatively small
      2. Variable power output (resolution of 1/100)
      3. IF the bluetooth commands can be reverse engineerd, the unit can be controlled by a custom app or other bluetooth enabled device
    2. Con’s:
      1. Only one power output
      2. No graphical user interface on the control unit itself (except for a bluetooth status light)
  3. W325 Smart Control unit – A very elaborate and big control unit, able to control up to 6 IR lamps, 3 external devices, music and ambient lighting. The unit can be controlled using an external graphical user interface and via an app.
    1. Pro’s:
      1. Variable power control
      2. 6 variable power outputs (for IR lamps) and 3 on/off outputs (for fans, vaporizers, lights, etc)
    2. Con’s:
      1. The number of available options and settings is not user friendly
      2. Ugly, sluggish user interface
      3. Huge unit
      4. The complexity of the unit makes it difficult to connect it to a custom built interface
  4. The engineer firmĀ timer – A lot of beeps and flashing lights and not a clue how to control it. Pushing the touch buttons seems to have no effect.Ā Sometimes it stops beeping and the unit seems to respond to my fingers from a distance of 3cm. It seems like the capacitative touch buttons are calibrated with too low of a threshold. Or maybe another front panel needs to be in place. But even if I keep my distance, the unit behaves very erratic.

All things considered I believe that the Bluetooth control box is a unit to continue with. It is both simple and versatile. The bluetooth functionality combined with the ability to continuously adjust the power provides the option to control an IR lamp with both an app and with an interface that can communicate using Bluetooth.

If I want to control the Bluetooth control box using a custom built app or via another bluetooth device I need to find out what communication protocol is used. I believe I can obtain this information using two methods:

  1. Sniff the bluetooth commands between the device and the phone using a bluetooth sniffer or HCI logger
  2. Decompile the APK that is used to control the device and search for the specific bluetooth commands used.

Update 22ndĀ of September 2016

This seems to be more difficult than I initially thought. The logs of the bluetooth commands are hard to interpret and the decompiled APK has been decompiled so hard that it became unreadable. In parallel I tried to connect my BLE enabled Raspberry Pi 3 to the Bluetooth control unit, but I have not (yet) succeeded in talking to it. At this moment I am seriously doubting if I will be able to have a custom program talk to this unit via Bluetooth. It might be easier to buy or create a variable power circuit that can be controlled externally, so I can control it via the Raspberry Pi.

Update 10th of October 2016

I’ve decided that the bluetooth track is a very hard and unpleasant one to follow. So now I am focussing on interfacing with the custom built timer. It seems that this timer is able to variably control power as well, so this might be a good choice after all. I will start with sniffing the TTL serial connection and the I2C bus to learn how the touch interface communicates with the timer board. It seems that

Each 840ms a burst of data is send from the controller to the interface.

Total length of the burst is around 2.9 ms (=2900ms)

The duration of one bit is 8.8us. Ā 2900/8.8 = 329 bits. Guessing each byte contains a stop and startbit and no parity bit, the data burst contains around 32 bytes.

10 11001010 (64+16+2+1 = 83)

10 0100 1100(32+16+2=50)