Welcome to ned Productions

by . Last updated .

Welcome to ned Productions (non-commercial personal website, for commercial company see ned Productions Limited). Please choose an item you are interested in on the left hand side, or continue down for Niall’s virtual diary.

Niall’s virtual diary:

Started all the way back in 1998 when there was no word “blog” yet, hence “virtual diary”.

Original content has undergone multiple conversions Microsoft FrontPage => Microsoft Expression Web, legacy HTML tag soup => XHTML, XHTML => Markdown, and with a ‘various codepages’ => UTF-8 conversion for good measure. Some content, especially the older stuff, may not have entirely survived intact.

You can find the posts here replicated onto Diaspora, if you prefer to subscribe there instead.

Latest entries: Feed icon

Sunday 19 September 2021: 22:54. Last weekend in my series on my future house build, I looked at the physical board of the keenly priced industrial grade scriptable PIC32-based Devantech dS3484 ethernet relay and input board, and I got a demonstration LED being PWM dimmed using a small program written in its proprietary dScript programming language. This weekend my goal was to get an actual solution to automating my prototype cove lighting up and working, including user selectable PWM dimming and automatic on-off based on outdoor brightness and whether there is someone in the room.

Firstly let’s look at how I have wired up the board:

The Devantech dS3484 board controlling a 24v AC power supply and MOSFET to PWM dim the LED strip

My LED strip is 24v, so that AC power supply is a 24v model (the box taped to the top is a 24v to 12v buck converter for 12v LED strips to be added later). Both its live and neutral have been wired into the first two 16A relays of the Devantech board. Hanging between the 24v power supply and the board and the LED strip is a cheap chinese clone of an IRF520 MOSFET costing barely one euro which is claimed to be able to handle up to 5A, but as a clone I’d not trust it with more than 3A (and indeed my 24v LED strip can draw an absolute max of 3A, which is not a coincidence). You’ll note that I added inline 5A car fuses for both the 12v buck converter and the supply to the IRF520 clone, just in case, and since that photo was taken I have added a heatsink to the MOSFET, because those IRF520 clones do run hot even on half their claimed amperage.

The IRF520 clone will switch at around 3v, so I wired the 5v output from one of the analogue inputs on the Devantech board to power the MOSFET, and using a 470 Ohm resistor I routed the same 5v supply via a digital i/o and in parallel to the MOSFET. This is because the Devantech digital i/o are NPN rather than the PNP typical in Arduino/RaspPi type boards, so when on they connect their input to ground, and when off they do not connect their input to ground (i.e. they don’t source, they sink). So, after the resistor, when off there is approximately 3.3v @ 10 mA remaining from the 5v input to switch the MOSFET on; when on that 3.3v gets drained to ground, switching the MOSFET off.

(Incidentally, due to doing all this stuff at ~2am after a full workday having risen at 7am, I foolishly shorted the resistor which delivered the full 5v to the digital i/o. The board, being i/o buffered and industrial grade, blew a small fuse on the individual digital i/o rather than blowing the board. That digital i/o no longer works, but it proves the quality of the board – had that been a Raspberry Pi, I’d have blown the chip)

Along the analogue inputs, I have connected a cheap TEMT6000 photoresistor which runs on 5v, outputting a 0-3.3v signal depending on how much visible light it sees (and I taped it to the room’s window). Next is a potentiometer, to simulate a wall rotary dimming dial which are just potentiometers wired into a triac (if you snip the internal connection and wire in a DC cable to the potentiometer, you can use an ordinary wall dimming dial switch very nicely). Finally, I wired a cheap HC-SR501 PIR sensor into analogue, despite it being a digital i/o, because the Devantech board’s digitial inputs are volt free, meaning you can connect up any voltage you like within spec (I assume <= 12v?), and the input will sense a 0-2v difference from ground as a zero and anything more as a one. Volt free is great for most uses cases e.g. just connect a physical switch, no power needed, the input ‘just works’. But when the input is a TTL device, the problem is when the signal is zero it isn’t connected to ground in a way the volt free input can detect (it basically needs a small current to flow, and none does), so the Devantech digital input can’t work with TTL inputs without additional circuitry. Whereas the analogue input ‘just works’ here, albeit you’ll need to poll it for new values. Luckily, this particular PIR sensor holds its digital signal high for three seconds per detection, so if you poll the analogue input every second or so, you’ll definitely catch it.

Last night I wrote this somewhat more complex than the last time dScript program to run it all:

digitalport LED_STRIP_PSU_RELAY1 1 ; relay 1
digitalport LED_STRIP_PSU_RELAY2 2 ; relay 2
digitalport LED_STRIP_PWM_DIMMING_IO 47  ; i/o 7
analogport LED_STRIP_PWN_DIMMING_SELECT_IO 4  ; analogue 4
analogport PIR_SENSOR_IO 1  ; analogue 1
analogport WINDOW_LIGHT_SENSOR_IO 3  ; analogue 3
const TICKS_BETWEEN_DIMMING_LEVELS 500
const TICKS_BETWEEN_PIR_SENSOR 300000


; Increments monotonically at 1000Hz
int32 monotonic_count

; The current LED strip dimming. 0 = off, 8 = 100%
int8 led_strip_dimming_level_actual
; The desired LED strip dimming
int8 led_strip_dimming_level_wanted
int32 led_strip_dimming_level_wanted_ticks_remaining
; The last time we saw PIR movement
int32 last_pir_movement_monotonic_count

function set_led_strip_dimming_level(int8 newlevel)
  if newlevel != led_strip_dimming_level_wanted then
    if led_strip_dimming_level_wanted == 0 and led_strip_dimming_level_actual == 0 and newlevel >= 4 then
      ; fast start straight to 50%, spool up from there
      led_strip_dimming_level_wanted = 4
      led_strip_dimming_level_actual = 4
      software_pwm_dimmer_impl()
      threadsleep 250
      if newlevel == 8 then
        led_strip_dimming_level_wanted = 8
        led_strip_dimming_level_actual = 8
        software_pwm_dimmer_impl()
      endif
    endif
    led_strip_dimming_level_wanted = newlevel
    if newlevel != led_strip_dimming_level_actual
      led_strip_dimming_level_wanted_ticks_remaining = TICKS_BETWEEN_DIMMING_LEVELS
    endif
  endif
endfunction

int32 last_pir_movement_delta_returned
function int32 last_pir_movement_delta()
  int32 ret
  ret = monotonic_count - last_pir_movement_monotonic_count
  if ret < 0 then
    ret+= 2147483647
  endif
  last_pir_movement_delta_returned = ret
  return ret
endfunction

; Implements LED strip PWM dimming
; The i/o when on turns the lights off, so this is inverted
function software_pwm_dimmer_impl()
  int32 todo
  ; In case you're wondering why not compare the masked value to something to
  ; set todo as a boolean, dScript doesn't support comparison operations in
  ; variable expressions. No that makes no sense at all :(
  select led_strip_dimming_level_actual
    case 0 ; 0%
      todo = 1
    case 1 ; 12.5%, 125Hz
      todo = (monotonic_count & 7)
    case 2 ; 25%, 250Hz
      todo = (monotonic_count & 3)
    case 3 ; 37.5%, 125Hz
      todo = (monotonic_count & 7) - 2
    case 4 ; 50%, 500Hz
      todo = (monotonic_count & 1)
    case 5 ; 62.5%, 125Hz
      todo = (monotonic_count & 7) - 4
    case 6 ; 75%, 250Hz
      todo = (monotonic_count & 3) - 2
    case 7 ; 87.5%, 125Hz
      todo = (monotonic_count & 7) - 6
    case 8 ; 100%
      todo = 0
   endselect    
   if todo > 0 then
      LED_STRIP_PWM_DIMMING_IO = on
   else
      LED_STRIP_PWM_DIMMING_IO = off
   endif     
endfunction

; Turns the LED strip on
function turn_on_led_strip()
  if LED_STRIP_PSU_RELAY1 == 0 then
    ; Set the MOSFET off
    led_strip_dimming_level_actual = 0
    led_strip_dimming_level_wanted = 0
    software_pwm_dimmer_impl()
    ; Set relay 1 and then relay 2 on, wait for the PSU to initialise
    LED_STRIP_PSU_RELAY1 = on
    threadsleep 20
    LED_STRIP_PSU_RELAY2 = on
    threadsleep 105
  endif
endfunction

; Turns the LED strip off
function turn_off_led_strip()
  if LED_STRIP_PSU_RELAY1 == 1 then
    set_led_strip_dimming_level(0)
    do until led_strip_dimming_level_actual == 0
      threadsleep TICKS_BETWEEN_DIMMING_LEVELS
    loop
    ; Set relay 2 and then relay 1 off
    LED_STRIP_PSU_RELAY2 = off
    threadsleep 20
    LED_STRIP_PSU_RELAY1 = off
    threadsleep 20
  endif
endfunction

thread software_pwm_dimmer_tick(1)
  monotonic_count += 1
  if monotonic_count == 2147483647 then
    monotonic_count = 0
  endif
  if led_strip_dimming_level_actual != led_strip_dimming_level_wanted then
    led_strip_dimming_level_wanted_ticks_remaining -= 1
    if led_strip_dimming_level_wanted_ticks_remaining == 0 then
      if led_strip_dimming_level_wanted > led_strip_dimming_level_actual then
        led_strip_dimming_level_actual += 1
      else
        led_strip_dimming_level_actual -= 1
      endif
      if led_strip_dimming_level_actual != led_strip_dimming_level_wanted then
        led_strip_dimming_level_wanted_ticks_remaining = TICKS_BETWEEN_DIMMING_LEVELS
      endif
    endif
  endif
  software_pwm_dimmer_impl()
endthread


; This coroutine samples the analogue inputs, so we run it at 0.1Hz
int32 outside_brightness
;int32 board_temperature
thread pir_control_tick1(10000)
  outside_brightness = WINDOW_LIGHT_SENSOR_IO
  ;board_temperature = TS1
endthread

; This coroutine samples the analogue inputs, so we run it at 5Hz
int32 chosen_dimming
thread pir_control_tick2(200)
  int16 pir_movement
  pir_movement = PIR_SENSOR_IO
  if pir_movement >= 512 then
    last_pir_movement_monotonic_count = monotonic_count
  endif
  int32 delta
  delta = last_pir_movement_delta()
  ; If it is bright outside, or no movement at all for an hour, turn off the LED strip and we are done
  if outside_brightness >= 600 or delta > 1800000 then
    turn_off_led_strip()
    threadsuspend ; we are done
  endif
  ; If the whole unit is off, and it's dark outside, only switch on
  ; if there has been movement recently
  if LED_STRIP_PSU_RELAY1 == 0 then
    if outside_brightness <= 500 and delta < TICKS_BETWEEN_PIR_SENSOR then
      turn_on_led_strip()
      set_led_strip_dimming_level(8)
    else
      threadsuspend ; we are done
    endif
  endif
  ; Unit is on, decide what brightness it needs to be
  if delta < TICKS_BETWEEN_PIR_SENSOR then
    ; Set to whatever the potentiometer says
    chosen_dimming = LED_STRIP_PWN_DIMMING_SELECT_IO
    set_led_strip_dimming_level(1 + (chosen_dimming / 128))
    threadsuspend
  elseif delta < TICKS_BETWEEN_PIR_SENSOR + 10000 then
    set_led_strip_dimming_level(1)
    threadsuspend
  else
    set_led_strip_dimming_level(0)
    threadsuspend
  endif
endthread

thread main(const)
  ; upon boot, turn on LED strip immediately, but dim
  turn_on_led_strip()
  set_led_strip_dimming_level(1)
  threadstart software_pwm_dimmer_tick
  threadsleep 3000
  threadstart pir_control_tick1
  threadstart pir_control_tick2
endthread

Hopefully the above is fairly self explanatory with the comments explaining anything weird looking – basically we physically disconnect the 24v AC adapter whenever possible, but we keep it running for 30 minutes after nobody being in the room so lights can be quickly started within 100 ms if somebody enters. I took especial care to never do too much at a time in a coroutine to keep the software PWM smooth and thus the flicker as least obvious as possible – you will probably also note the hard coded eight possible PWM dimming level choices, which is probably the most practically possible with a 1Khz clock. Here’s a video of me cycling the dimming down and back up again using the potentiometer:

The 500Hz 50% dim seems to not flicker on the phone camera’s sensor, but the 250Hz and especially 125Hz levels do. As mentioned in previous posts, this isn’t the Devantech board’s forte – the hardware PWM of the PIC32MX chip isn’t available to dScript, and I think given this is an interpreted bytecode running on a 80Mhz CPU even achieving smooth 1Khz software PWM is pretty impressive. Speaking personally, I am rather flicker sensitive, and I can easily see flicker at 500Hz. I find it quite offputting, though it is a lot less worse than the 250Hz and 125Hz PWM – that latter looks to me like a light pulsing on and off. Meanwhile my wife couldn’t detect any flicker at all except a little at 125Hz PWM.

Finally, as I mentioned last post, these Devantech boards have the unique feature that they can serve a HTML page of your design with AJAX updating fields pulled from global variables in your dScript program. I didn’t go nuts here, I made a simple HTML table and had it fill in various values to make a simple status dashboard:

All in all apart from the occasional head scratch all this work went smoothly, albeit that the low resolution software PWM dimming isn’t really good enough for my house build, so I’ll need something better. I didn’t get around this weekend to integrating this with Home Assistant, so next weekend that’s exactly what I’ll be doing: I’ll probably write a very simple local push integration for Home Assistant that lets this dScript push status changes to Home Assistant. I may also allow Home Assistant to override the board’s default logic e.g. put lights to 100%, or turn everything off.

Something else I’ll need to make a start on is researching alternatives for home automation. Something rather noticeable in this prototype is basically all the analogue inputs are full already, and given each of these boards costs at least €75 inc VAT, that’s rather too much money to be expending per room in the house. I need something much cheaper which can also do high resolution hardware PWM dimming and isn’t a pain to wire up and/or configure. I’m also minded that I have a bunch of sensors I want to test for my house build which require I2C, and the Devantech board doesn’t expose that.

Don’t get me wrong here, this Devantech board is absolutely great for automating high current stuff such as immersions, pumps, home heating water valves, that sort of thing – anything involving 12v DC or 230v AC and lots of current. The volt free inputs are perfect for wall switches etc. but not suited for wiring in Arduino/RaspPi focused sensors. This implies that my sought after cheaper alternative probably is going to be an Arduino or Raspberry Pi, exactly because the whole breakout board sensor ecosystem is designed around them, but also because they have the deep software support for enthusiasts which makes the experience a whole lot less painful than is usually the case with embedded systems programming.

#house




Monday 13 September 2021: 01:25. I received my industrial quality Devantech dS3484 board which cost me €75 inc VAT, a fraction of near equivalent boards from National Control Devices or National Instruments, yet provides similar functionality and uses proper 12v powered industrial grade components same as they do. As I described in the last post on the topic of my future house build, this board is capable of running a proprietary BASIC-like scripting language called dScript which lets you program it to carry out a fair bit of local automation, thus reducing how much control complexity you need to encode into a network controller such as Home Assistant. As the last post mentioned, there is a lack of detail online about the Devantech boards, and whilst the Devantech website contains a board specification, description and you can glean more detail from its dScript programming manual, there is a definitely lack of subjective user experience of these boards i.e. people who have had a go off them, and wrote up their experiences on line somewhere where search engines can find them. Let’s hope this virtual diary post is therefore useful to others!

Firstly, high resolution pictures, because there aren’t any online that I could find and without these it’s very hard to figure out how the board is routed:

The overall dS3484 board, in its optional extra case

The processor, a PIC32MX795F512L, with a 2Mb flash from Microchip to its left

Above you can see the Ethernet PHY chip, the RS485 serial chip, and the 12v buck converter to 5v.

The board has very good build quality. Soldering and traces are clean, every input and output is buffered, and a very wide range of voltages is therefore tolerated. The Hongfa 16A relays are considerably better quality than the cheap Chinese 10A claimed relays normally in tinkerer boards and I think I’d trust them with 230V AC. I tried out the relays, the digital i/o both as input and output, and the analogue inputs. Analogue inputs looked very stable when fed a potentiometer, no noise, drift nor random walk, and the full 10-bit range was clearly present with equal resolution at the extreme low and high as in the middle (unlike ESP8266 for example). Ethernet came up and worked without issue. I plugged a cheap 12v AC adapter into it, found no issue. 5v output from the board measured at 5.1v, which is fine. I haven’t tested the RS485 port nor UARTs, but I intend to do so soon. The USB socket, incidentally, appears as a serial port to your computer. I don’t think you can use it for anything other than with the dScript IDE, which seems rather unfortunate.

All in all, I think the hardware great value for €75. This board is maybe 20% more expensive than the cheapest ethernet relay boards off Aliexpress, but it’s an absolute world of difference in build quality. I’d trust this to switch an immersion, which I don’t think a good idea at all with any of the typical relay HATs for the Raspberry Pi.

Regarding the software side of things, I didn’t get too much time to play with that this weekend – you’ll need to wait until next weekend for me to have a proper go off the proprietary programming language. On the one hand, this isn’t some dumb board with no locally programmable logic blindly obeying commands hitting its Ethernet port – it is quite programmable e.g. if five conditions are satisfied, connect to another computer and write some arbitrary payload to that socket, or accumulate statistics, analyse them and email a summary every day. On the other hand, its proprietary dScript programming language is a weird mix of features and capabilities, some big fat ones like the ability to send email, yet no time keeping better than a second unless you implement your own.

However I did write this little dScript program in the dScript IDE to test the board:

const STEPS 16
const DELAY 1000

int32 on_count
int32 off_count
int32 on_max
int32 off_max

thread main(const)
  int32 N
  off_max = STEPS
  off_count = 1

  threadstart Timer1
  threadsleep DELAY
  for N = 1 to STEPS - 1
    threadsleep DELAY
    off_max = N
    on_max = STEPS - N
    if on_count == 0 and off_count == 0 then
      on_count = 1
    endif
  next
endthread

thread Timer1(1)
  if on_count > 0 then
      on_count -= 1
      if on_count == 0 then
        IO1 = off
        off_count = off_max
        threadsuspend
      endif
  endif
  if off_count > 0 then
      off_count -= 1
      if off_count == 0 then
        IO1 = on
        on_count = on_max
        threadsuspend
      endif
  endif
endthread

Which yields this on a RGB LED I hooked up to digital i/o 1 which uses PWM to reduce the brightness of the LED from 100% to 6.25% in even steps over sixteen seconds:

The video makes it look far worse than it is to the human eye, where any PWM flicker isn’t noticeable until the dimmest setting, and even then, only from the side of the eye’s focal point. The PWM flicker is due to the 16 ms duty cycle, which is only 62Hz, barely any better than a cheap diode based LED AC bulb flickering at 50Hz. But it’s the best possible on a millisecond granularity timing system, which is the finest timer granularity dScript exposes. This is unfortunate as even though dScript is an interpreted language running on an 80Mhz CPU, it should be able to pulse an i/o at 50Khz in software if the board isn’t doing much else.

In case you were wondering, yes the PIC32MX has hardware PWM. However dScript doesn’t expose that, and when I asked Devantech support if it could, I was told that the PWM capable pins are not routed to digital i/o, which seems to me a missed opportunity. Again, that weird mix of features and capabilities at work. Incidentally, I also asked how much current the 5v outputs could supply as it isn’t documented anywhere, and I was told around 500 mA. Which is very useful to know.

In any case, timers do appear to reliably fire bang on 1 millisecond – the PWM, despite the video where the phone camera’s own refresh rate is colliding with the PWM refresh rate – appears to my eye absolutely regular. No stutter, though obviously this is not a loaded system.

The proprietary language dScript seems to be a reasonable attempt at a coroutine based BASIC-like embedded systems language. What the language calls ‘threads’ are actually coroutine event handlers, so you declare what event you are interested in e.g. timer elapse, TCP/IP input, board boot, i/o state change and so on, and you write code which will be called when that event occurs. Digital i/o appear to be non-blocking (instant), but analogue input read, serial port read, TCP/IP read and so on appear to suspend the coroutine’s execution until the blocking input completes, upon which execution is resumed. Most writes go into asynchronously flushed buffers and so don’t usually block. Whilst your coroutine is suspended, other coroutines may run. The scheduler is cooperative, so if any coroutine executes for too long, it blocks the execution of other coroutines, and events for a given input after the first event may get dropped as there is no buffering, as befits a hard realtime implementation which cannot allow unbounded dynamic memory allocation.

This coroutine based fixed-at-point-of-compile approach suits well deterministic programming, though it is unavoidably a bit awkward to write code in as a result (think WinRT programming, but minus any dynamic memory allocation). As there is no preemption, there are never races on shared state, which is good because all non-local state is globally visible like say in a single translation unit of C. As all possible memory allocations are known at compile time in the dScript IDE, memory is preallocated for volatile and non-volatile RAM and program bytecode. Strings are supported, but you cannot create new ones programmatically at runtime i.e. with runtime determined length – anywhere you format numbers into a string it preallocates string space for the maximum possible formatted value. There is no floating point support, which is to be expected for such a low end CPU which would lack hardware floating point, but there is what appears to be an optimised boolean expression evaluator which I assume is expanded out into a finite state machine rather than sequences of bytecode for the logic, so if-then-that type logic can be tersely and very efficiently encoded into a constant state table.

An unexpected feature of these Devantech dScript boards is that they can serve a user defined website of your choice on HTTP and moreover, said website can call arbitrary dScript via AJAX from Javascript. This lets you build web based UIs or reporting or summary dashboards for your particular setup, which is very nice. In fact, the whole system config and setup web UI for the board is written entirely in dScript, which shows what is possible if you are willing.

Anyway, next weekend I’m going to have a go at writing an actual piece of control software for my particular project in dScript. It’ll have a summary dashboard served as HTTP, so you can always see what state it is at and why. I may or may not also have it push state changes to Home Assistant, e.g. current light brightness, and if I get the time, add remote automation by Home Assistant of the project. I’ll no doubt report on my progress here!

#house




Friday 3 September 2021: 11:57. I’ve made a start building prototypes of the Home Automation described in the first post of in the series about my future house build. This is my prototype, hand made, cove lighting:

My hand made cove lighting prototype

This is five metres of 120/m density 3000K warm white > 95 CRI (Colour Rendering Index) 2835 LED strip mounted into an alumnimum heat sink and diffuser firing along the direction of the ceiling. To shield the eye from glare and to make it look pretty, standard polystyrene coving runs underneath (glued to wooden mounts to prevent the LED heatsink melting the polystyrene), leaving a gap of about 1.0 - 1.5 cm along the top (it varies because the roof plaster varies in thickness). The heatsinking sits about 1mm from the wall, and air can flow from underneath around the back and out the top. This is 24v DC LED strip, which is unusual as most comes in 12v or especially 5v, but as a result it doesn’t draw more than 3A which makes for much less brightness fade along the strip, and less thick wiring needed – power injection every five metres is eminently doable with 24v LED strip, rather than the more usual one metre if say you had 5v LED strip. This saves an awful lot of time and hassle by reducing to one fifth the amount of wiring you need to do. The strip achieves > 95 CRI by randomly varying the colour temperature of each LED mounted on the strip such that the average comes out at 3000K, this creates a very nice light indeed, far better quality than your typical household LED bulb which may have a CRI less than 80. Indeed, this exact type of strip is more typically used for illuminating artwork in a gallery – it is total overkill for household lighting, and in practicality we probably will in the end use a cheaper LED strip as this stuff costs 60% more than say a CRI 90 strip.

In case you’re in the market for high quality LED strip, the vendor is Gree Lamps on Aliexpress run by a lady called Lucia. I was very pleasantly surprised during testing that my LED strip exactly matched her description, which is very rare for Aliexpress vendors who tend to inflate specifications. She is expensive compared to others, but what you get is spot on in terms of spec, power consumption, and quality. It’s very noticeable the difference between the light quality from this strip and our ceiling light, a Philips ‘high CRI’ LED bulb.

Having lived with the cove lighting for a good few weeks, we decided that we really like it. Much better quality of room illumination than ceiling point lighting. It’s really quite subtle the difference, and initially you don’t see it and feel underwhelmed. But after you get used to it, well, you become quite sold on this being the only possible lighting for your house.

To that end, we need to automate it, because on full this stuff consumes ~12w/metre or so, and thus my five metres here is ~60w which is the same as an incandescent bulb! Indeed, my ceiling point light only consumes ~15w, so this is consuming 4x more power and it only covers half the room! So we are going to need to dynamically dim this stuff using Pulse Width Modulation (PWM) based on proximity of humans i.e. each strip would be brighter the closer a human is sitting to it, and as you move around, the lighting automatically brightens around you as you move. This, in turn, keeps the electricity bill down, and obviously rooms without people automatically go dark. We can also have this stuff only illuminate barely in the middle of the night, so when you’re going to the toilet, it won’t blast you with so much light that it interrupts your sleep.

All that said, in order to not be anti social to human beings, the wall light switches still need to do something, so if somebody turns off a wall light switch, it ought to turn off the lights and/or change their brightness. And I want conventional light switches here, it needs to appear to not be fancy as that too would be anti-social.

Choosing your automation hardware

Home Assistant integration is an absolute hard requirement here. So most of the proprietary home automation systems are therefore out. I don’t like Wifi for anything reliable, I want everything on Ethernet, ideally PoE. I also don’t want to spend much money, but as well I don’t want to spend much of my precious little free time, which includes that I’d like to never have to maintain the thing if possible over the years to come. What I want needs to be cheap, but safe, and if one can spend a little extra to save my precious free time, I’ll spend it.

Most people in the enthusiast community would choose something like a Raspberry Pi Model B+. It has an ethernet port with add-on PoE hat, a wide range of i/o, it’s cheap enough at maybe €30 inc VAT for the Model B+ (or for the exact same money you can get instead the rather impressive Orange Pi Zero 2 which I very seriously pondered going with). However, for switching things with useful current and voltage you need to wire relays into the GPIO, and whilst those are cheap enough (maybe €1 per pair of 10A relays capable of being switched at 3.3v), you also would be wise to fit protection circuitry between the relay and the rather sensitive 3.3v TTL GPIO on the CPU, as if it ever saw more than 3.5v for even a fraction of a moment it would blow the port or maybe the whole CPU. It’s also a fair bit of hassle to wire up a relay if you want to have it powered by an independent loop – fine if you’re doing one or two, painful if you’re doing dozens. I am also not entirely trusting of cheap Chinese relays, I would view their claims of 10A with suspicion – maybe 7A is more like reality. I’m also mindful that all this stuff can catch fire if it shorts, though I’ll be fitting inline car fuses to hopefully prevent that.

Now don’t get me wrong: via RaspPi hats you can add everything I listed above in one convenient bundle. But a decent hat costs a good €45 inc VAT, so now you’re spending €75 inc VAT. And for just a little more than €75 there is a whole world of alternative options.

Why decent hats cost more than the board is because these little enthusiast boards aren’t really designed for rough environments e.g. hanging off long cable runs containing varying quality of voltages in a dusty corner. They are mostly mobile phone SoCs or cut down derivatives thereof – they were designed to be behind a decent PSU or a battery supplying a stable, regulated power and that almost all of what they deal with is the same e.g. Ethernet, a phone line, a satellite LNB, and so on, all with tightly bounded voltages and lack of EM noise. They are chalk and cheese to industrial CPUs like the ones in your car, or in factory plant where the CPU would be designed to tolerate sudden voltage droops of maybe 30% or spikes of maybe 10%, or for inputs to be 5v instead of 3.3v because a lot of industrial equipment uses 5v. What you swap with these industrial facing CPUs is clock speed, so where a 700Mhz CPU might be absolute rock bottom for those enthusiast boards, in order to tolerate voltage ripples you might expect one tenth of that in an industrial CPU. Your washing machine, for example, may well be running a 48Mhz CPU which constantly endures PF spikes from motors and switches turning on and off, but because it’s running so slowly, it don’t care. In the end, so long as your washing machine works, who cares if it runs at 48Mhz?

To that end I went looking for something more affordable than industrial boards, like say the cheapest National Instruments eight relay with Ethernet system I could find which costs a mere €1,500 inc VAT and total proprietary lock-in. A well known cheaper alternative to National Instruments is National Control Devices, a four relay system of theirs starts from €250 inc VAT onwards and a four MOSFET system of theirs starts from around €300 inc VAT onwards. But far cheaper again are boards from a small British company called Devantech, who have been making for many of the past thirty years now a bunch of Ethernet connected relay and GPIO boards out of industrial grade components for very reasonable prices if compared to NI or NCD. Despite being encumbered by Brexit, Devantech boards are very widely available all over the world via local resellers – the United States has an agent, as does Germany, as even does Iran. With a bit of searching, their local distributor can be found pretty much anywhere in the world.

Devantech provide two variants of their ethernet connected boards: (i) the traditional NI/NCD type boards which are generally fixed function and require an externally connected device to tell the board what to do or (ii) where the board has software defined function, using a custom programming language designed by Devantech called dScript, and whose programming manual can be found here.

Now this scriptability intrigued me. Obviously by now I had done an enormous amount of research, mostly involving ruling things and options out. Looking through the dScript manual I came to feel that these variants were worth the punt: 99% of the Home Automation I needed to do was totally doable on a 8Mhz ARM2 CPU which was the Acorn A3000 CPU back around 1990, so on anything similar or better, it ought to be a cinch. Morever, because this stuff is scriptable, for those 1% of situations where the local board can’t make a decision, it can explicitly do an upcall to Home Assistant and ask for direction because dScript lets you send and receive TCP or UDP messages.

The current range of Devantech dScript capable boards are these. All include USB 2.0 and 10-100 Ethernet, and they’ll accept an unregulated 12v DC input (i.e. I can use a cheap chinese PoE 12v splitter and not worry about the 12v DC quality):

ModelApprox price
(inc VAT)
16A
relays
Digital inputs
and outputs
Analogue
inputs
Serial
ports
CountersCPUFlash
storage
RAMTDP
(12v DC)
Other notes
dS1242€5924x VFC input or NPN output2x 10-bit1x TTL8x 32-bit trigger, 20 Hz input count80Mhz PIC32MX795F512H
(guessed)
512Kb128Kb6WSoC datasheet says there are five not eight counters
dS3484€7548x VFC input or NPN output4x 10-bit2x TTL, 1x RS4858x 32-bit trigger, 20 Hz input count80Mhz PIC32MX795F512L
(source)
512Kb128Kb12WSoC datasheet says there are five not eight counters
dS378€8887x software defined i/o, your choice of VFC input, NPN output or 10-bit ADC input2x TTL, 1x RS4858x 32-bit trigger, 20 Hz input count120Mhz PIC32MK0512GPK064? (guessed)512Kb?128Kb?12WHas seven ADC inputs, but datasheet for guessed SoC says 12-bit ADC. Also no Ethernet in the PIC32MK. So maybe a PIC32MZ?
dS2824€147 - €186248x software defined i/o, your choice of VFC input, NPN output or 12-bit ADC input1x TTL, 1x RS4858x 32-bit trigger, 10 Hz input count200Mhz PIC32MZ0512EFE064? (guessed)512Kb?128Kb?18WOptional integrated relay snubbers for inductive loads. Guessed SoC datasheet says there are four not eight counters
dS2832€184 - €233328x software defined i/o, your choice of VFC input, NPN output or 12-bit ADC input1x TTL, 1x RS4858x 32-bit trigger, 10 Hz input count200Mhz PIC32MZ0512EFE064? (guessed)512Kb?128Kb?24WOptional integrated relay snubbers for inductive loads. Guessed SoC datasheet says there are four not eight counters

Firstly, note that the Devantech 4-relay board is about one quarter the cost of its equivalent NCD board, and the 8-relay board is about one seventeenth the cost of its equivalent NI system. You might think that they reduced the quality of components to achieve that, and in some ways this is true: the NCD boards have 20A relays whereas the Devantech boards have 16A relays. Both are 12v industrial grade relays however, not the usually lower quality 5v relays in the RaspPi hats and cheap chinese relay boards. And in Europe, with our 230v AC versus US 115v AC, 16A relays are worth 32A relays in the US, so we here in Europe really don’t need 20A relays when almost all our AC use cases are bound by a 13A fuse in any case.

It is true that comparing the NI boards to anything else isn’t really comparative. I saw the NI boards in action during my work on the EuroFighter project back in year 2000 and there is no denying their extreme robustness. Sure, they cost a fortune, but they are built like a nuclear bunker compared to their cheaper competitors.

It is also true that from Aliexpress and other places you can obtain cheap chinese ethernet relay boards for about 20% less money than the Devantech boards. Whilst you may accept their 10A relays (likely really 7A), multiple internet forums report that they don’t play well together on the same ethernet subnet because they have a borked firmware. I have found no reports that the Devantech boards and firmware have any such issues. So if you’ll only ever use a single board, the cheap chinese alternatives might be worth a look, otherwise I’m fairly confident that the Devantech boards are about as good as you’re going to find for the price-feature benefit.

Secondly, there is a lot of guesswork in the table above, so until the board actually arrives and I can examine what’s on it, treat everything above with a pinch of salt, though note the link above that confirms that the dS3484 uses a PIC32MX795F512L. I will say that the cheapest Euro denominated reseller of Devantech kit I could find was Dutch https://www.antratek.com/, they’re a good 10% cheaper than most of the other Euro denominated resellers, and that’s from where I bought my board for prototyping.

Thirdly, the NCD board almost certainly uses a PIC32 processor just the same as the Devantech board does – maybe even a similar model. The PIC is, of course, the classic industrial CPU for many decades now. It is very hardy, accepting gladly really poor quality power supplies, and comes with oodles of relatively sophisticated i/o, like ample Analogue to Digital (ADC) inputs which you won’t find built-in on any mobile phone or PC facing CPU. However the PIC 32 CPU is not at all like the PIC chips of yore, which had a reputation of being horrible, and deservedly so in my opinion. The PIC 32 is really a MIPS chip, which is a very very good thing compared to that god awful PIC 8, which is probably the worst CPU I’ve ever seen in my career. The PIC 32, being MIPS, is quite sane and logical. No it ain’t no powerhouse, that there 80Mhz of clock speed gets you almost nothing compared to any desktop or mobile CPU, even an 80Mhz ARM Cortex A53 would run rings around it, but for my needs of ‘if this then that’ it ought to be sufficient.

The dScript manual claims that individual dScript instructions can scale between 40k per second and 400k per second, with 100k per second being a reasonable average assumption. On that basis, assuming that the built-in PWM hardware of the PIC32MX795F512L isn’t available to dScript so I’ll have to toggle outputs manually, I certainly think that 10Khz PWM is doable. This might not be quite enough to prevent flicker from the LED strips on a mobile phone camera, but once I get the board in my hands and have a go off it, I’ll see how far I can push it.

I have submitted a support request to Devantech to ask about less-than-1ms support in dScript, which from the dScript manual appears to be lacking. I’ll report back here in a subsequent post what they respond with.

#house




Monday 30 August 2021: 20:49. It occurred to me that I haven’t posted an update on my P2P earnings #mintos in about six months, so I thought I would do so now:

MonthMintos annualised return for each monthMintos non-earning capitalMoncera annualised return for each month
December 202011.29%11.4%
January 2021 10.21%11.4%
February 202112.82%11.4%
March 2021 17.57%11.4%8.54%
April 2021 10.63%17.1%8.59%
May 2021 10.46%18.8%5.97%
June 2021 12.97%22.7%9.39%
July 2021 11.70%27.4%11.53%
August 2021 10.91%27.4%11.42%

That non-earning capital, to remind readers, is the money I had invested in Polish Capital Service which is currently under a covid restructured debt repayment plan and during which it isn’t paying out. So considering that this drags down the annualised return, the returns from Mintos on the earning capital have been very healthy indeed such that the typical annualised return has barely dropped over this time last year, and that is even as I have been drawing out about half of my Mintos total investment – as evidenced by the proportion of non-earning capital more than doubling as a relative share. This is mostly because I was lucky – last post on Mintos I mentioned that I was moving away from car loan giant Mogo (since renamed to Eleving Group) into DelphinGroup and IuteCredit. Around March DelphinGroup bought back all my loans and stopped issuing new ones on Mintos, so I decided to take a punt on investing in Creditstar who https://explorep2p.com/mintos-lender-ratings/ think fourth best on Mintos, despite their 6-7 rating by Mintos. I thus locked in a bunch of loans at 14-15% APR, and to date neither IuteCredit nor Creditstar have bought back their loans, so I’ve been doing rather a lot better than the typical 9% APR on new loans in Mintos last few months. Eleving Group/Mogo began buying back my high APR loans in dribs and drabs over several months, and I think I became completely clear of them in July through doing absolutely nothing, which suits me fine as their new loans pay peanuts. On Mintos, I am now about 41% IuteCredit, 39% Creditstar and 24% ESTO (ranked 11th by explorep2p, yet rated 8 by Mintos), albeit on less than half the total investment when compared to January.

You will notice a new column up there for Moncera. This is a fairly new P2P investment site exclusively for Placet Group, who are rated the best quality P2P lender by explorep2p, but because they pay such paltry APRs on Mintos I’ve never invested with them. However the exact same loans on Moncera pay considerably better than on Mintos, and indeed were paying better than anything somewhat safe on Mintos (> 10% APR), so from March onwards I moved over half of all my investment to Moncera. Moncera appears very good if you don’t mind the fact that it’s a single loan originator and that if it did ever go bust you’d have no one to fight your battles for you, whereas Mintos have at least proved that they’ll go to bat with their own solicitors to recover at least some of your money from loan originators who try to shirk their obligations.

All in all though, all my P2P investments shall be getting wound down during 2022 as I’ll need every penny that I can lay my hand upon to build my house. The goal of all this P2P investing was simply to preserve some value from inflation on a cash pile, and I never risked more than would earn about 1% per annum on the total cash amount. That cash pile mostly just got sunk into buying a site, the remainder will be paying professional fees to reach planning permission and then maybe if there is enough left it might just about pay for site clearing and groundworks. All the remainder will come from a mortgage, and as that won’t be enough either, several upcoming years of future income which means I’ll be saving absolutely nothing. So, to put it plainly, the days of there being any cash pile to lose value upon from inflation have already begun to end.

Once the P2P investments start to make up a fifth of all my remaining cash I’ll stop their automatic reinvestment and let them cash themselves out slowly. I’ve noticed that they buy back about one third of your original investment every six months just from churn or whatever, so that’s about one fifteenth of your total cash pile every six months. If I need it to go quicker I can always sell the loans on the secondary market, though that comes with a 0.9% exit fee (Mintos) or 0.5% exit fee (Moncera).

I may or may not do another post on P2P investing in the future. I hope you all enjoyed the series of posts and it gave you some new investment ideas.

#mintos #p2p-lending




Monday 2 August 2021: 00:50. The last few months have felt like an awful blur. Some of it is the birth of my third child, Julia, with all the impacts to one’s routines a newborn brings with them. Some of it was gearing up to bring everyone to England in the middle of a pandemic for my brother in law’s wedding without either catching covid, despite that England was riddled with it, or getting trapped by borders closing – in the end, we rented a campervan so we’d never need enter indoors anywhere, and took ferries which brought us back to Ireland via Northern Ireland, all of which was most stressful and very draining, but we got it done at the start of July, and it all worked out well in the end (equally, I would not wish to repeat it ever again). However no doubt the rest of it is that now Julia is born and both her and mother are healthy, I’ve started the ball rolling on buying a site, and building a house on it!

The Site

So far, buying our site has not gone well! Just the buying of the site alone has been a plague of issues and stress. The site is a serviced site within a partially built housing estate deep in rural Cork which is the result of the global financial collapse in 2008. The story begins with a Joseph O’Callaghan who received planning permission to build forty-three houses as an estate in year 2000. As far as I can tell, he was not a professional developer, but rather a local businessman and farmer, and I’m guessing he did not intend to build all the houses himself. They appear to have built the roads, installed services and street lights etc, or possibly contracted in builders to do it, and the estate got itself named by start of 2006. In any case, starting from June 2005 onwards you start seeing individual site planning permissions land at a fairly rapid clip: in order, numbers 1, 7, 12, 11, 13, 20 & 21, 3, 2, 15, 6, 5, 31 & 32, 19, 35-36-37-38, 24, 28 & 29, 30, 16. And then bang!, no more planning applications for new houses on the estate between July 2007 and February 2015!

What happened was that building of the later granted sites never began before the global financial collapse of 2008. Looking through the planning applications and comparing it to the property sales register (both are public access on the web), a minority were individuals who later occupied the house they built, and a majority were from somebody involved in construction who were looking for somewhere to invest their spare cash, with the idea of building a few houses on the side of their main business and flipping them for a profit. As much as many private individuals got badly caught out in the housing price collapse of 2008, those in construction who were dipping their toe into becoming small scale builders of a few houses on the side got a lot more badly burned – a feature of this housing estate is if you don’t start building within thirty months of getting planning permission, you have to pay a fine per site of €1,000 per month! So after 2008, not only were they in deep negative equity, they were also in a cash flow crunch. Hence no planning applications for new houses for eight years!

This of course happened to lots and lots of people who either bought housing or sites just before the housing market collapsed in Ireland. And it took a good decade to sort out, what with everybody owing everybody else vast sums of money, and nobody wanting to act on any of it because that would realise their losses. At the time, I remember feeling I was losing out badly due to my then poverty, as I was still a poor student. I look back now and feel so very sorry for all those unfortunate people, it literally ruined a whole generation.

In any case, the people who own our site appear to have decided to offload their sites some time in late 2019. They went up on the market mid 2020 at an asking price of €85k each, which I reckon was about a 50% haircut over what had been paid for them. Given how far away this village is from anywhere at all with jobs, and that even a site within the Cork city boundary could be found for that kind of money, the sites did not attract much interest.

Earlier this year, I had been bidding on two sites in the North Cork village where I currently live, Dromahane, but I had bailed out when the price went to €85k as I just didn’t think either site worth that (one was very small, the other had no access to the public sewer and was too small to easily fit a septic tank). So I knew where my price limit was roughly at, and where the market was roughly at, for sites near places with jobs. Also, Megan had begun to see that getting a site near Mallow was going to be expensive, and there would likely have to be considerable compromises in terms of shape, size, or budget. So she became a bit more open to moving further away than before. In March I took her to look at sites for sale in this partially built housing estate in this rural village far away, and she agreed that the sites were much better quality, the amenities were great, there is a train station next door, indeed everything bar macro location was great (though location within the village itself couldn’t be better). Because of that poor location, I put in an offer for two of the sites purchase subject to planning, and my offer was accepted in principle end of March.

Cue then three sets of solicitors (mine, the sellers’, the estate’s) taking – to date, it’s still ongoing – four months to come up with a contract! Obviously the sellers and the estate developers wanted to push through the conditions as was in 2007 to me, with the rather important bit being the €1,000 per site per month fine if I don’t complete a house within thirty months. That was a showstopper for me, and eventually after much haggling the other sides relented. Also, since 2019 the EU has imposed much tighter regulations for building new houses, specifically you now need an energy consultant in addition to an architect and typically a structural engineer, and lead times to reach planning permission submission are now far longer than they were before 2019. So all the conditions originating from year 2007 involving what must be accomplished within X months from whatever needed to be doubled or trebled because they were no longer realistic. Hence more shuttling backwards and forwards between the three sets of solicitors.

Supposedly, the final contract will be ready for signing by me in ten days or so i.e. mid August. It’ll then need signing by the other sides, and we shall finally be off to the races after a mere five months. Yay.

The House

In terms of what to build and how to build it, our current intent is an unusually tall bungalow measuring approximately 18 metres long x 10 metres wide x 9 metres high with a 40 degree (i.e. steeply) sloped roof. If that sounds like a two storey height, you would be right – the idea is a bungalow but with Victorian height internal walls plus a loft conversion with added height in the loft, so basically the ceiling of the ground floor and floor of the loft part is a bit lower than half up the total height of the house (3.6m internal walls downstairs, 4.5m floor to peak of internal roof upstairs) i.e. instead of dividing a two storey height house into two floors and an attic, we’ll be dividing it into one floor and an attic. The hope is that it will be passive house certified, meaning that total energy consumption must be measured as below 60 kWh per metre squared per year which essentially means the house heats and cools itself using ambient heat i.e. no heating system needed (though we shall be fitting a single radiator in order to meet Irish building regulations which require there to be a heating system in the house, but also in case there is only one occupant, as the heat emitted by the human occupants makes up a substantial portion of the total heating of the house). Total internal living space is estimated to be around 260 m2, with the six metre wide ten metre long main living room running floor to roof in height i.e. the full eight metres high, which ought to be quite impressive to walk into and be in as it’s effectively like being inside a church, which is the effect we are intending.

We have commissioned as our architect Rebel Design Studio who specialise in building photorealistic virtual reality models of the proposed design, which until very recently was the preserve of high end architecture for really big developments such as shopping centres or large office complexes. We’ll be at the state of the art here, combining Unreal Engine with Twinmotion to produce a three dimensional render of the proposed design. Given my past UE4 experience during the DTS contract, I’ll then take that model and convert it for the Oculus Quest 2 VR headset, and then we’ll be able to walk around our future house to see how it feels. The Oculus Quest tracks you physically walking around exactly evenly, so if you walk one metre with the headset on, you’ll walk one metre inside the VR model. Obviously I’ll post a video flythrough here when we have them, but I suspect it’ll not be a patch on wearing a proper VR headset. The only issue will be finding a flat safe 18 x 10 metre space to walk around in with the headset on, and that assumes we don’t try walking outside the VR house!

Other unusual features of the house

Earth tube

Apart from it basically being a church which is unusual, there are a few other novel features intended which may get deleted or refined as expert advice comes in. The first is that my highly inexpert calculations currently reckon an earth tube worth the cost benefit, which would be highly unusual for a climate as mild as Ireland’s. Earth tubes are basically a 0.2m diameter pipe under the ground for 40 or 60 metres, and the ground is typically 10 - 12 C throughout the year. The ventilation unit sucks incoming air through the earth tube, so in winter this would warm the air, and in summer it would cool the air, before it enters the house. Passive houses are extremely well insulated and so airtight that without a ventilation unit you will suffocate (indeed because the concept comes from Germany, it was designed around the Central European climate and the insulation is actually overkill for the mild Irish climate, however because Passive House is a standard, it’s cheaper to meet the PH standard than do something specific for Ireland). Because the PH standard requires a highly efficient heat exchanging ventilation unit which transfers the heat from expelled air into incoming fresh air, earth tubes don’t benefit a passive house much in winter. However, in summer they provide substantial cooling, and the hotter it is outside, the better the cost benefit. Generally earth tubes only make cost benefit between Southern Central Europe and North Africa, and not in Ireland where the average summer temperature is about 17C (across day and night) which has insufficient differential to the ground temperature to provide worthwhile cooling. However in our case, I reckon an earth tube would give about negative 1kW for the house by my calculations even with all the heat pouring in all the windows. That means we can increase the amount of glazing quite a bit i.e. we spend extra money on an earth tube so we can spend more money again on more glazing and it shouldn’t overheat. This clearly doesn’t meet cost benefit by definition, but let me explain my thinking on this some more.

Almost all houses built in Ireland since the 2019 EU NZEB regulations came in have a heat pump to meet the 20% renewable energy requirement, so not having a heat pump I can already see will be controversial. If a heat pump costs €8k, because a Passive House uses so little energy, a heat pump at 400% efficiency in winter has a payback time of nineteen years. Alas a heat pump likely needs replacing every fifteen years, and has expensive maintenance (e.g. recharging every few years its heat exchange gas, which is patented and hideously expensive), so for very low energy consumption it just doesn’t have cost benefit like it would if we used more energy. To give an idea of how close this cost benefit is, if my planned house simply dumped shower waste water as-is into drainage, the energy consumption would become high enough that a heat pump becomes worth the cost benefit. But because I’ll be fitting a heat exchanger to all the shower and bath wastewater to reclaim the heat before the water is dumped to drainage, that sufficiently reduces total house energy consumption that a heat pump is no longer worth it. That waste water heat exchanger costs about €1,200, and the maths say it has one of the best cost benefits of anything else I’ve chosen – much better than solar panels, which was a surprise.

An earth tube is pretty similarly priced, at about €6k, it just needs cleaning with a brush every few years, and a new filter every year, and otherwise ought to last the building’s lifetime whilst consuming almost no electricity at all. It does almost nothing for reducing your heating costs, because the heat exchanger in the ventilation is already so efficient. But it should completely eliminate overheating in summer, and indeed make possible more glazing than would otherwise be possible. So it is more an insurance, or a fixed asset part of the glazing expenditure, than having anything to do with running costs, and therefore should not be treated as cost-benefit, but rather as ‘will spending this money get me features that I want?’ i.e. more windows.

Thermal store

Most higher end houses have a dedicated hot water tank which is heated by a heat exchanger from the home central heating i.e. the boiler pumps hot water through the radiators, and effectively there is another radiator inside your hot water tank which then heats your hot water. Obviously there is usually a valve bypass so your boiler can heat the single radiator inside your hot water tank, and not pump through the radiators in your house.

A surprising outcome from the maths I ran is that for this specific house, it makes a lot of sense to invert that design. Instead of a tank with domestic hot water heated by your radiator circuit, you make your tank contents the same as your radiator circuit, and place your domestic hot water tank inside your ‘radiator tank’. This is called a ‘thermal store’ and it basically inverts the traditional relationship between domestic hot water and your radiator circuit. Thermal stores are typical in larger buildings like office blocks. They don’t usually have cost benefit for a building as small as a house.

The reason that cost benefit works for our house is that thermal stores have weird maths. Because heat loss is a proportion of surface area, but heat capacity is a function of volume, the bigger you make your thermal store tank, the more efficient it gets. It actually has cost benefit to fit a 5,000 litre thermal store tank to this house, at least according to my crude calculations. 5,000 litres is an enormous store of heat, about 230 kWh of space heating if heated to 60C. Given that our passive house might require at worst 1.6 kWh of heating in winter, that is a potential six days of worst case space heating in a single tank, so in normal times you might have two weeks of heating in there. The reason why this matters is because the Irish weather in Spring and Autumn swings between quite sunny and overcast, typically with up to a week of overcast between the sunny days. The idea is that on that sunny day, the solar panels heat the thermal store, and then that thermal store delivers any space heating and domestic hot water needed during the overcast days, and if it is unusually overcast for a long period of time, we can use cheap night time electricity at €0.10/kWh to keep the top of the thermal store hot. If you run out the numbers, this has the second highest cost benefit after the waste water heat recovery because for eight months of the year, you shouldn’t need any electricity for space heating nor domestic hot water at all, on average. This was also quite surprising when the numbers fell out this way – passive houses generate weird numbers, because they are so insulated.

Thermal stores have other advantages too. Have you noticed how your hot water tap has low flow and your cold tap has high flow? This is due to pressure, a hot water tank doesn’t deliver much pressure compared to mains water (at least 1.0 bar in Ireland). However a thermal store feeds mains cold water directly into the inner tank within the thermal store tank. Therefore, hot water has identical pressure to cold water. This might seem unimportant, but consider every time you’ve waited for your shower to warm up, or the sink to get warm when washing your hands – at 1.0 bar, that hot water tap gets hot very quickly. That, in turn, means your shower gets instantly hot, no need to wait, and that in turn reduces waste but also improves quality of life, a few minutes saved every day adds up.

Also, your typical hot water tank fed shower might deliver five litres/minute, due to the low pressure. With a thermal store, thanks to the 1.0 bar pressure, my maths says that same shower would deliver eighteen litres/minute, which is far nicer. And thanks to the waste water heat exchanger, most of that shower water will end up heating shower water, so no need to feel guilty about dowsing oneself in eighteen litres of shower per minute. Obviously I’ve thus specified large rainfall type showers for all three showers, because with eighteen litres/minute you really will get a very good shower indeed.

Home automation

‘Smart’ homes are all the rage for high end housing right now. But I’ll be skipping multiple generations ahead by making the entire house Home Assistant based from the very beginning. Home Assistant is an open source enthusiast home automation system, so you can program things like ‘if the weather forecast says there will be no sunny days for the next week, and the thermal store has 10% hot water remaining, turn on the immersion from 12am onwards using cheap night time electricity until the thermal store has 15% hot water remaining’. Or ‘illuminate the lights around Clara to no more than 75%, but illuminate the lights around Niall to 100%’ and that light illumination would follow you around the house, including adjusting itself appropriately for when you’re stumbling towards the toilet half asleep in the middle of the night. If none of that sounds fancy enough to be worth the trouble, you can also program it things like ‘if a cat enters my property, send the robot lawnmower out to follow it to scare it away’ and ‘if a human enters my property and that human is a family member, don’t send an intrusion alert to Niall’s phone’.

This all might sound impossible to some reading, but it’s all completely possible today right now with Home Assistant. It just requires a reasonably powerful always on computer, which I already have in my current rented house. Because it’s enthusiast, it’s multiple generations beyond all but the very most expensive of commercial smart home solutions. Yes I’ll have to rig it all together myself. Yes it’ll take me years to get it all done. But I’ll have a smart home system worth €40k or so for pocket money, albeit plus quite a lot of my precious free time. And because it’ll all be hand written and hand wired, it won’t be needing a constant internet connection to work, unlike all of the commercial smart home systems as far as I can tell.

To power all this home automation, I have been careful to only choose components (e.g. the home ventilation unit) with great compatibility with Home Assistant, and I’ll be running a 48v DC circuit around the house, plus feeding the 48v into the ethernet all over the house. I expect there shall be a lot of Power over Ethernet devices, as I am not at all keen on Wifi, Zigbee nor Z-Wave IoT devices where a hard wired alternative is feasible (which is almost always). I expect the 48v DC circuit to be capable of 50 A, which is 2.4 kW of power which might seem extreme. However, not only will all the IoT will run off that line, but so will most of the lighting which I expect to be LED strips of various kinds also intelligently controlled by Home Assistant. I’m actually currently typing this underneath some hand made experimental cove lighting, and I’m rather liking it for what it cost me (mostly my precious free time, the parts were well under €100).

Projected cost

This is of course that elephant in the corner. Passive house does not come cheap. Victorian high ceilings do not come cheap. Lots of glazing does not come cheap. Yes, all this is going to cost me.

I’m no quantity surveyor, but I have compiled a list of all the components and materials I think we shall need and put my best guess as to prices on all of them (this has consumed a very great deal of my precious free time in the past few months). I currently estimate that this house plus a separate outhouse will cost €452,000 excluding professional service fees and contractor profit margin. Assuming those at 10%, this house is expected to cost around €500,000.

Now that is an awful lot of money. I am fortunate enough that right now I am earning quite well, but still, that is an awful lot of money. To put it into perspective, in the estate where we shall be building this, no house there has ever sold for more than €290,000. So if I spend €500,000, I am straight away €200,000 in negative equity. That’s just nuts if you think about it.

Still though, all this isn’t really about resale value. It’s about ‘getting what you want and how much it’ll cost you’ value. Forever homes have atypical cost benefit dynamics, because you’ll be borrowing money from the bank to build something you’ll enjoy over hopefully decades so you’re not judging expenditure against present day valuations, but against probable valuations in twenty years or so. Given the long term and ongoing decline in the interest rate as ever more people retire and ever fewer productive workers support the retired, the volatility of fixed asset pricing can only increase – and probably very considerably so. So I expect still further huge increases in valuation of real estate, but I also expect much more frequent boom-bust cycles in real estate. Because as the interest rate gets ever closer to zero, the system will only increase to destabilise unless politicians actually do something about it. Assuming near zero likelihood of politicians actually doing anything substantial to keep house prices reasonable, I think the chances are very good that in twenty years my property will be worth a million or so. And my kids shall remain living with me forever because it’ll be a much better place to live than elsewhere, but also because there is near zero chance they’ll ever be able to afford to own their own house. So my generation shall return to the historical norm outside this past half century, which is that your kids have their families right next to where you raised them, and you’ll likely get roped into grandchild care.

I’ve accounted for this in the design – it is not adverse to multiple families being reared in the property, which seems a quite likely future I reckon, especially as comparing recent empirical measurements to the 1972 predictions from The Limits to Growth appear to be close to bang on track for a predicted civilisation peak around 2040, and thereafter a steep decline in almost all metrics, including food production. As food for thought, in 2040 Clara shall be 26, Henry shall be 23, and Julia shall be 19. I will be 62, and Megan will be 56. There is even a non-zero chance that my father may just about be still alive, aged 94! I hope to be 80% food self sufficient by then, though without industrial goods that isn’t sustainable for more than a decade or two e.g. solar panels may last thirty years, but solar inverters need replacing every fifteen years. In any case, I am fairly confident that we shall have done all that is possible to give the best possible platform for our children to do as best as will be possible in a declining civilisation, and that me and Megan shall have as pleasant as possible a dotage.

Given the recent massive flooding in Europe and China, I’ve also made sure that the house is raised 0.5 metres above all surrounding land as climate change will almost certainly cause a major flood event where my house shall be during the next few decades, and a bit like with when bears are chasing you, you don’t need to be the highest just slightly higher than everything else when it comes to water.

However in the end all you can do is design around known knows and known unknowns. It’s the unknown unknowns which will catch you out.

#house




Saturday 29 May 2021: 22:44. It is almost June, so here is the latest update to my annual comparison of storage bytes per inflation adjusted dollar for magnetic hard drives, flash SSDs, and Intel Optane XPoint devices (you can find all the past posts here), which I have done every June since 2012:

Raw data: http://www.nedprod.com/studystuff/SSDsVsHardDrives.xlsx

This is an unusual year, hard drives are about one third more expensive this year than they were last year (I am very thankful I replaced earlier this year all my hard drives with 3x 16 Tb Seagate drives, I clearly timed the market beautifully). Yet, SSDs are one third cheaper than last year, which is an unusually good annual improvement which appears to have undone last summer’s SSD price increases. Meanwhile Optane X-Point is completely flat – not just nearly flat, but absolutely identical dollar prices to this time last year, only the effect of inflation very slightly improved their bytes per inflation adjusted dollar. Clearly Intel feel no need to bring NV-RAM to the mass market until competing products launch and force them to compete on price , which hopefully will be soon.

So why have hard drive prices increased? Everybody is blaming Chia mining which is a cryptocurrency based on pointlessly wrecking hard drives into landfill rather than pointlessly converting electricity into heat like Bitcoin. The Chia network is currently consuming 1.2 Exabyte at the time of writing, which might sound a lot, but it’s only 75,000 16Tb hard drives, which is a rounding error on annual production. So I suspect the true cause is the same as why car production has stalled, as has CPU production and graphics card production, it’s due to the global shortage of silicon chip production in general. And no doubt somewhat related is the post-pandemic steep rises in the price of copper and rare earths, and just that demand in general is vastly exceeding supply.

I expect this time next year hard drive prices will have dropped back onto their long term trend line, and SSD prices perhaps will be flat. We shall see!

#ssdsvsharddrives




Monday 8 March 2021: 20:44. I had a pretty bad week last week at work. My main development workstation had, on the preceding Friday, crashed taking my development VMs with them, so I spent the weekend before last reinstalling Ubuntu 20.04 with ZFS-on-Root (my standard Linux setup for five years now!), moving the work codebase onto that shared with Windows over Samba, with the intent of building for Linux within the VM, and building for Windows from the Samba share. This was a big divergence from my previous setup of Windows Subsystem for Linux v1 doing the builds for both Linux and Windows, and then I’d run the Linux executables over a Samba share. There is nothing wrong with my former setup for smaller codebases, but as the work codebase approaches 150k LOC, WSL v1 based Linux builds are getting unwieldy slow. And WSL v2 is the same as a Linux VM, except the file system is shared by 9p rather than Samba, and 9p is very considerably slower than Samba, so you’re much better off configuring your own Linux VM and Samba installation and tuning the snot out of Samba.

Anyway, all of last week my developer workstation kept locking up, losing me work in progress. I tried relocating the NVMe SSD (a Samsung 970 Pro) into a new M.2 socket, and since then it appears to be reliable again. But that’s water under the bridge, what I’m here to talk about now is how I fixed Visual Studio 2019 not building reliably over a Samba share, because absolutely nobody else seemed to find a solution to this oft reported problem (well apart from this guy here who found a workaround to a related but different problem which has the same manifestation as mine).

Firstly, I am not building into the Samba share. I create a build directory on Windows, and tell cmake to populate that Windows build directory using a git worktree located on a mapped network drive M:\ which is the Samba share of the git worktree in the Linux VM \\kate-linux. As the build never writes into the source worktree, Samba is only being used here for reads only, and so thanks to opportunistic locking (oplocks), Windows aggressively caches the source tree in Windows and build performance is pretty close to native speed.

Except, it’s not quite reliable. 99.9% of the time it works fine. But occasionally MSVC doesn’t find some header file, or Visual Studio refuses to save a file, and if you look in the directory it is creating lots of orphaned temporary files from the failed saves. The problem is much worse if you use --parallel with cmake --build . --config Debug where MSVC will fail to find lots of header files, sufficiently so that you don’t get a usable build. Initially I thought this was purely a MSVC/Visual Studio problem, as it only ever appeared there, not helped by all the google searches reporting the same problem and almost all also mentioned MSVC/Visual Studio. But I also noticed that occasionally executing git from Windows where the git repo was on the mapped network drive would fail too with messages such as:

fatal: update_ref failed for ref 'HEAD': cannot lock ref 'HEAD': unable to create lock file non-directory in the way

… and other messages suggesting that the network share was being racy with respect to changes on the network share.

My initial thought was that Samba must be misconfigured, even though it was pretty much with default config, and Ubuntu 20.04’s Samba is v4.11.6 which to my best knowledge, has no known major bugs and its default config is pretty optimal for performance, unlike earlier versions before Samba v4. I spent all last week when I was waiting on Linux build trial and error A-B testing various network and Samba configurations, alas to no avail.

This weekend passed, and today Monday morning I had a bit of a brainwave: What if Samba is absolutely fine, and it is Windows 10 which is the cause?

That led me to Microsoft’s documentation page about SMB2 Redirector Caches which documents three registry settings to fiddle with. It turns out that setting these parameters in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Lanmanworkstation\Parameters fixes all my MSVC failed-to-find-file, Visual Studio 2019 failed-save-edited-file, and git failed-to-checkout-branch problems:

  1. DirectoryCacheLifetime = (DWORD) 0
  2. FileNotFoundCacheLifetime = (DWORD) 0
  3. FileInfoCacheLifetime = (DWORD) 0

After you have set these using regedit, Run services.msc, find the Workstation service and restart it. To verify it’s working, open powershell with Administrator privileges and do Get-SmbClientConfiguration:

ConnectionCountPerRssNetworkInterface : 4
DirectoryCacheEntriesMax              : 16
DirectoryCacheEntrySizeMax            : 65536
DirectoryCacheLifetime                : 0
DormantFileLimit                      : 1023
EnableBandwidthThrottling             : True
EnableByteRangeLockingOnReadOnlyFiles : True
EnableInsecureGuestLogons             : False
EnableLargeMtu                        : True
EnableLoadBalanceScaleOut             : True
EnableMultiChannel                    : True
EnableSecuritySignature               : True
ExtendedSessionTimeout                : 1000
FileInfoCacheEntriesMax               : 64
FileInfoCacheLifetime                 : 0
FileNotFoundCacheEntriesMax           : 128
FileNotFoundCacheLifetime             : 0
KeepConn                              : 600
MaxCmds                               : 50
MaximumConnectionCountPerServer       : 32
OplocksDisabled                       : False
RequireSecuritySignature              : False
SessionTimeout                        : 60
UseOpportunisticLocking               : True
WindowSizeThreshold                   : 8

Note the zero values for the parameters we forced to zero, but large MTUs remain on, oplocks are on, and multichannel is on.

SMB Multichannel is probably the only major Samba performance enhancing feature not enabled by default in Samba v4. This is because it was buggy until recently, but now it’s working very well. SMB Multichannel lets file transfers multiplex over multiple TCP connections, so just like with Download Accelerators on the internet, you can multiply a per-TCP-connection maximum several fold over multiple connections, thus greatly increasing transfer rates. This isn’t particularly important for many small files like during a C++ compile run, but if you have multiple threads all accessing a single Samba share, with SMB Multichannel those threads actually see some concurrency whereas without SMB Multichannel, they all get funnelled through a single TCP connection with a global mutex. So, for a parallel build like what Visual Studio now does by default, SMB Multichannel is a big gain.

You can see if your Hyper-VM Linux and your Windows installation are already employing SMB Multichannel using this command in an Administrator privileged PowerShell:

Get-SmbMultichannelConnection -IncludeNotSelected

Server Name Selected Client IP     Server IP       Client Interface Index Server Interface Index Client RSS Capable Client RDMA Capable
----------- -------- ---------     ---------       ---------------------- ---------------------- ------------------ -------------------
kate-linux  False    192.168.137.1 192.168.137.235 7                      2                      False              False
kate-linux  False    192.168.2.172 192.168.137.234 11                     1                      False              False
kate-linux  False    192.168.2.172 192.168.137.234 11                     1                      False              False
kate-linux  False    192.168.137.1 192.168.137.234 7                      1                      False              False
kate-linux  True     192.168.137.1 192.168.137.234 7                      1                      True               False
kate-linux  False    192.168.2.172 192.168.137.235 11                     2                      False              False

If it prints nothing, SMB Multichannel is NOT being employed.

If your Samba is after v4.13, it should autodetect when your network setup is RSS capable on its own. If both sides can do RSS, enabling SMB multichannel is as simple as adding this into your smb.conf:

[global]

server min protocol = SMB3
server multi channel support = yes

Note you need to reboot your Linux VM and then your host Windows machine before this takes effect.

If your Samba is before v4.13, you will need to either force RSS on (ideal as it can parallelise according to CPUs in your machine) or assign more than one network adapter to both your VM and your host on the Hyper-VM bridge (not ideal, as max concurrency is the number of multiple NIC pairs between Linux and Windows). Here is how you force Samba to advertise support for RSS and RDMA:

interfaces = "192.168.137.234;if_index=1,capability=RSS,capability=RDMA,speed=10000000000"

Obviously, you will need a static IP for your Linux VM for this to work, and you need to enable RSS in the virtual 10Gb NIC and on the Hyper-VM bridge you are using.

I left RDMA enabled in there too, though it only makes sense on real hardware with a sufficiently capable real NIC on a real server. Obviously if you do have such capable hardware, you can sustain 10Gb/sec on a 100Gbit link with 256Kb per i/o @ QD8, or 2Gb/sec on a 100Gbit link with 4Kb per i/o @ QD200. Over a software emulated switch and NIC, the SMB Multichannel only mainly increases concurrency for both host and VM, helping ameliorate the VM<=>Host latency.

Finally, the only other settings which Samba v4 doesn’t currently enable which might help are:

socket options = TCP_NODELAY IPTOS_LOWDELAY
use sendfile = yes

TCP_NODELAY is already on by default in Samba v4, but IPTOS_LOWDELAY is not. This might improve performance a bit given that now Windows does no caching of metadata whatsoever given the registry changes above. And use of kernel sendfile() to zero copy transmit files is off by default, for some reason, so turning it on might reduce CPU cache loading a little.

Hopefully I helped other people now reading figure out the solution to what has been a very frustrating week for me in getting Visual Studio/MSVC to reliably build a Linux Samba share supplied git worktree.

#samba




Sunday 21 February 2021: 00:48. We currently live in a former council house near Mallow, Cork which suffers rather from damp and mould, though certainly not as bad as in many Irish houses, especially ones in the humid south. This gives us all constant coughs, plus our sinuses are always congested, and we often don’t sleep as well as we might because we wake up early due to being unable to breathe due to being all bunged up. I have a dehumidifier which is excellent at drying out a room sufficient that one sleeps very well, but it is (a) noisy (b) expensive on electricity to run. So I’ve been looking for something which could clean out some of the crap which gets into the air, is quiet enough it can run 247, is cheap enough that I can deploy it throughout the house permanently, and at least reduces the severity of what ails us from this house.

After a bit of research, I eventually settled on the Xiaomi Air Purifier 3C for €90 delivered within the EU from Aliexpress, buying one for every room in the house. These are the cheapest edition of the third generation of Xiaomi’s very popular air purifier range widely used in the big cities of China, India and Poland to reduce the fine particulate air pollution inside your home to less toxic levels (for every 10 μg/m3 increase of PM2.5 in your air, there is a +36% increase in lung cancer, and 7.5% of all heart attacks are due to PM2.5). My main attraction to them was that they can be controlled over wifi without a cloud connection (or indeed any access to any other network) by python-miio, so I can script individual behaviours for each such as when to go fast (daytime), and when to go slow (night time). Here’s my kitchen 3C in action:

They’re a very simple design, particularly the low end 3C model which has almost no onboard intelligence, unlike the more expensive models (one doesn’t need onboard intelligence if one is scripting them). They consist of a plastic base, a replaceable filter which fits into it, a quiet and high efficiency variable RPM AC turbine fan, a LED display, and a very low end ARM CPU with 2.4Ghz 11n Wifi and Bluetooth (the CPU is so low end that ping times are in the 400-700ms range, and REST API calls take 1.5 seconds or so). The turbine fan will spin at any RPM you choose between 300 and 2200, in 10 RPM increments. Finally, there is a laser-based PM2.5 sensor, but on this cheapest model no temperature nor humidity sensors.

As you can see below, my 3C came with the grey filter, which is claimed to meet the EN 1822 H13 (HEPA) standard specification removing at least 99.95% of all particulates equal or exceeding 0.3 microns in size (i.e. PM0.3). Note that anything less than 0.3 microns will get filtered by almost any kind of filter, because smaller particles bounce around a lot and get trapped by just about any density of fibre – therefore, these purifiers readily scrub the air of covid-19 and most other viruses too. Inside the wood fibre HEPA filter there is an additional activated carbon filter, which might soak up some odours and Volatile Organic Compounds (VOCs).

Despite this model’s simplicity, no other air purifier comes remotely close to the feature set for €90 delivered. In fact, you’d probably need to multiply by six if you want a well known brand such as Blueair with a similar feature set. Obviously, nobody is expecting that a Blueair model for €550 isn’t going to beat one of these for €90, but I’m fairly sure that six of these would handily beat a single Blueair, and do it quieter with cheaper replaceables, even if the Xiaomi filter isn’t as good as it claims.

Of course, by far the most important part of any air purifier is the filter itself, partly because it determines whether the device will be of any use or not, but also because they tend to be the expensive consumable. As with all things Chinese, there are a lot of clones of Xiaomi filters, but I believe I screened those out. Incidentally, I discovered on a chinese forum actual numbers for the claims by Xiaomi for their different filters, I don’t believe these are easily findable in English, so I’m going to list them here for your (and my later) convenience:

TypeModel EfficiencyColourRFIDDevice supportPrice on Aliexpress delivered to EU
EPA Economical M2R-FLPEN 1822 E12 (99.5%) BlueYes2/2C/2H/2S/Pro/3C/3H€31
EPA Anti-bacterial MCR-FLGEN 1822 E12 (99.5%) Pink PurpleYes2/2C/2H/2S/Pro/3C/3H€33
EPA Anti-formaldehydeM1R-FLPEN 1822 E12 (99.5%) GreenYes2/2C/2H/2S/Pro/3C/3H€36
HEPA M8R-FLHEN 1822 H13 (99.95%)GreyYes2/2C/2H/2S/Pro/3C/3HUnavailable

Each filter has a RFID chip which tracks how many hours it has been used for, and you will be pestered to replace it after about six months of continuous usage. The EPA grade filters are, with some difficulty to find at that price, available for as little as €31 each delivered within the EU. I could not find the HEPA filters for sale, though because they are just new on the market, you can barely buy them in China either yet, so that situation may improve within six months. Assuming they are at least €45, that means they were half the cost of buying the whole purifier!

As the air in Ireland is extremely clean from a PM2.5 perspective, auto mode based on the sensor reading isn’t useful here. That afflicts a high end brand such as Blueair just as much as this Xiaomi unit. Therefore you need to manually override them to run faster all the time in order to clean the air of mould spores, and that’s where the scriptability over wifi comes in, because I don’t really want to have to manually go around the house adjusting these manually. Here is the script I wrote to control them, you can obtain the device token using the instructions from Home Assistant (I set up a separate WiFi SSID on a VLAN, used the Xiaomi Home app to register the devices, then used the Xiaomi Cloud Tokens Extractor to get the tokens, then closed off all access between the VLAN and any other network including the internet. This script connects into the VLAN using a source IP spoofing NAT).

#!/usr/bin/python3

from miio import airpurifier_miot
from miio.exceptions import DeviceException
import time

class Purifier:
  def __init__(self, ip, token, name):
    self.ip = ip
    self.__token = token
    self.name = name
    self.__inst = None
    self.available = False
  def update(self):
    try:
      if self.__inst is None:
        self.__inst = airpurifier_miot.AirPurifierMB4(self.ip, self.__token)
        self.__inst.set_buzzer(False)
      status = self.__inst.status()
    except (airpurifier_miot.AirPurifierMiotException, DeviceException) as e:
      print("Failed to connect to", self.ip, "(" + self.name + ") due to", repr(e))
      self.available = False
      return
    self.available = True
    self.mode = status.mode
    self.powered_on = 'on' in status.power
    self.air_ppm = 0 if status.aqi is None else status.aqi
    self.led_brightness = int(status.led_brightness_level)
    self.current_rpm = int(status.motor_speed)
    self.filter_hours_used = int(status.filter_hours_used)
    self.filter_life_remaining = int(status.filter_life_remaining)
  def __repr__(self):
    ret = 'Purifier(%s) available=%d' % (self.name, self.available)
    if self.available:
      ret+= ' powered_on=%d air_ppm=%d led_brightness=%d current_rpm=%d filter_hours_used=%d filter_life_remaining=%d%%' % (self.powered_on, self.air_ppm, self.led_brightness, self.current_rpm, self.filter_hours_used, self.filter_life_remaining)
    return ret
  def enable_display(self):
    if self.available and self.led_brightness != 8:
      self.__inst.set_led_brightness_level(8)
      print('Purifier(%s) setting display to %d, led_brightness = %d' % (self.name, 8, self.led_brightness))
  def disable_display(self):
    if self.available and self.led_brightness != 0:
      self.__inst.set_led_brightness_level(0)
      print('Purifier(%s) setting display to %d, led_brightness = %d' % (self.name, 0, self.led_brightness))
  def set_rpm(self, newrpm):
    if self.available and abs(self.current_rpm - newrpm) > 20:
      if newrpm <= 400:
        if self.mode != airpurifier_miot.OperationMode.Silent:
            self.__inst.set_mode(airpurifier_miot.OperationMode.Silent)
        print('Purifier(%s) setting silent RPM to %d, current_rpm = %d' % (self.name, newrpm, self.current_rpm))
      else:
        self.__inst.set_favorite_rpm(newrpm)
        if self.mode != airpurifier_miot.OperationMode.Favorite:
            self.__inst.set_mode(airpurifier_miot.OperationMode.Favorite)
        print('Purifier(%s) setting favourite RPM to %d, current_rpm = %d' % (self.name, newrpm, self.current_rpm))

purifiers = {
  'Kitchen' : Purifier('192.168.xxx.xx0', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'Kitchen'),
  'Master Bedroom' : Purifier('192.168.xxx.xx1', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'Master Bedroom'),
  'Kids Bedroom' : Purifier('192.168.xxx.xx2', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'Kids Bedroom'),
  'Spare Bedroom' : Purifier('192.168.xxx.xx3', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'Spare Bedroom'),
}

while True:
  now = time.localtime()
  for name in purifiers:
    p = purifiers[name]
    p.update()
    print(time.asctime(now), p)
    if p.available:
      if p.powered_on:
        try:
          if 'Kitchen' in p.name or (now.tm_hour >= 9 and now.tm_hour <= 21):
            # Daytime running
            p.enable_display()
            if p.air_ppm >= 5:
              new_rpm = 1100 + p.air_ppm * 10
              if new_rpm > 2200:
                new_rpm = 2200
              new_rpm -= new_rpm % 10
              p.set_rpm(new_rpm)
            else:
              p.set_rpm(1100)
            continue
          # Nighttime running
          p.disable_display()
          p.set_rpm(700)
        except (airpurifier_miot.AirPurifierMiotException, DeviceException) as e:
          print("Failed to set", p.ip, "(" + p.name + ") due to", repr(e))

  if now.tm_hour >= 22 and now.tm_min > 1:
    print("It is after 22.01pm, exiting!")
    break
  #time.sleep(10)

Sure, it’s not pretty, but it does the job until support for these purifiers lands into Home Assistant. I have it running inside a cronjob which launches at 08.59am, then the script exits itself at 22.02pm. This is to prevent constant WiFi traffic at night time as I have one of these units right next to my head in my bedroom. As the script runs, it outputs a constant sequence of logging which looks like:

Sun Feb 21 00:13:15 2021 Purifier(Kitchen) available=1 powered_on=1 air_ppm=0 led_brightness=8 current_rpm=1100 filter_hours_used=87 filter_life_remaining=97%
Sun Feb 21 00:13:15 2021 Purifier(Master Bedroom) available=1 powered_on=1 air_ppm=0 led_brightness=0 current_rpm=704 filter_hours_used=80 filter_life_remaining=98%
Sun Feb 21 00:13:15 2021 Purifier(Kids Bedroom) available=1 powered_on=1 air_ppm=0 led_brightness=0 current_rpm=704 filter_hours_used=81 filter_life_remaining=98%
Sun Feb 21 00:13:15 2021 Purifier(Spare Bedroom) available=1 powered_on=1 air_ppm=0 led_brightness=0 current_rpm=704 filter_hours_used=81 filter_life_remaining=98%
Sun Feb 21 00:13:24 2021 Purifier(Kitchen) available=1 powered_on=1 air_ppm=0 led_brightness=8 current_rpm=1104 filter_hours_used=87 filter_life_remaining=97%
...

Something a bit worrying is what happens whenever one cooks dinner, so the hob or oven is on. My script rapidly increases RPM on a per-purifier basis if its PM2.5 sensor exceeds five μg/m3, hitting the maximum 2200 RPM from 110 PM2.5 onwards. So far, we have not failed to hit at least 50 PM2.5 in the kitchen, sometimes over 300 PM2.5, though the purifier does clear it within fifteen minutes after you stop cooking. More worrying again is that this pollution gets all over the house, the other purifiers register 30 - 40 PM2.5 in our bedrooms.

Now, I knew from general reading that this is typical in UK-Irish homes which are unusually poorly ventilated by international norms, but until now it was all kinda abstract. I hadn’t really realised what it actually meant until I saw these sensors all jump throughout the house every dinner and lunch times where we cook hot food. We do have an extractor over the hob, but it’s a cheap noisy thing which doesn’t seem to extract much. So it looks like these air purifiers might do some good there too, which was not expected before I bought them.

#air-purifiers #xiaomi




Sunday 14 February 2021: 00:08. A little over a week ago I returned to work from lunch to discover this rather unpleasant surprise:

The right half of my monitor had vanished! And it quickly transpired that the cause could not be anything else but the monitor, a 27 inch 2K Hazro HZ27WD which I bought just under ten years ago.

Never heard of Hazro? They were a British thing. Basically someone in the UK contracted some South Korean manufacturer to stick the exact same high end LG IPS panel as was then in the Apple Cinema Display and professional grade Dell monitor into a very cheap all plastic chassis with a then-novel LED backlight and knock them out for under £400, which at that time, was ludicrously cheap for a 2560x1440 IPS monitor. Needless to say they sold like hotcakes, though many died after a few years with the exact problem mine died with. On that basis, getting nearly a decade of use from it was exceptional.

Because that panel was the very highest end available a decade ago, it lasted remarkably well in terms of display quality – I didn’t get a display which beat it until the Dell XPS 13 I’m typing on now two years ago, which is not only 4K resolution, but also has slightly better colour reproduction (80% DCI-P3) than that 2011 LG panel (75% Adobe RGB). I hadn’t thus felt much need to upgrade prematurely, or indeed keep up to date with the latest in monitor technology. I was perfectly happy with that Hazro until it died.

Cue, therefore, after its confirmed death, an enormous bout of reading to choose a replacement, as the choice available is legion, and there is a surprising amount of overpriced dross in the market mainly aiming for purchase by those who haven’t done their research (this situation is very similar to mobile phones and cars, most people get “whatever’s easiest” rather than what suits their personal use case the best).

I was very definite that I wanted a 4K display at 30 inches or more, so I could use 100% text scaling and still actually read stuff (I use 200% scaling on my laptop’s 4K screen, and even then I wouldn’t want to be spending ten hours a day in front of such small text). I also wanted:

  • Full DCI-P3 colour gamut.
  • Accurately calibrated from the factory.
  • Adaptive frame sync for AMD GPUs (Freesync).
  • A VESA mount as such a big panel is a pain to place ergonomically otherwise.
  • High quality scaling from 2k to 4k with low lag for a bit of gaming.
  • An environment sensor so the display adjusts itself over time to the room like my phone does.
  • Definitely DisplayPort and HDMI inputs, ideally also USB-C for my laptop/the future.

And, of course, I didn’t want to pay too much, ideally under €500 ex VAT (€600 inc VAT) which I felt was a reasonable budget.

Given how the display of my current phone the Galaxy S10 is the best I have ever gazed upon ever in my life, period, my first thought was for an OLED monitor. Dell used to do a ‘normally sized’ one of those (i.e. not under 14 inches, not more than 40 inches) a few years ago, but they discontinued it as apparently its display wasn’t very good for its steep price. LG have announced the 32 inch 4K 32EP950 with a JOLED OLED panel, 10 bit native colour and 99% of DCI-P3 gamut coverage, but it’s not for sale yet, and when it does goes on sale, I very much doubt that it would remain in stock for long if it’s reasonably priced, as LG claim it will be. And even then, reasonably priced would be defined here as under two grand, or three times my budget.

Having ruled that out, I next looked at Dell’s monitors, and only found the 27 inch models appealing, which were too small. I then looked at the gaming monitors, but their hefty prices and things like having fans put me off. I looked at the ultrawides, but I was unwilling to afford the graphics card I’d need to power one of those, and besides to be honest, most of an ultrawide monitor is outside your field of vision in any case, so my opinion it’s a waste of money for productivity uses (plus, many of them have colour reproduction issues caused by the curve in the monitor). As my shortlist of possible candidates built up, I began to notice that almost all of them were well over a grand, so the featureset I was looking for obviously did not come cheap.

The first monitor I saw to get me excited enough to start reading its user manual was the LG 32UN880. It has:

  • 31.5 inch 4K IPS display with 95% of DCI-P3 colour gamut. LG panel.
  • AMD Freesync with nVidia compatibility.
  • USB-C input support.
  • Comes with desk clamp stand and has complete motion, including swivel.
  • Delivered for under €700 inc VAT, if you can find it in stock (none in the UK nor Germany at that time).

It seemed to tick most of my boxes, but there was a real paucity of professional reviews out there (just one!), and almost no information nor experiences of people playing games on it. I didn’t know, for example, what input lag it might have when scaling 2K content to its 4K panel, and the lack of evaluation apart from short user reviews along the lines of ‘I love this monitor’ weren’t ideal.

After lots more searching, I eventually stumbled on another monitor exciting enough for me to read its user manual, which was the BenQ EW3280U:

  • 32 inch 4K IPS display with 95% of DCI-P3 colour gamut. AU Optronics panel.
  • AMD Freesync with nVidia compatibility.
  • USB-C input support.
  • VESA mountable.
  • Better HDR than the LG, though still not a patch on the much brighter local dimming backlight models costing twice as much.
  • An environment sensor, so it can automatically adjust its brightness and colour to the current surroundings.
  • A subwoofer (very unusual!) and a remote control (even more unusual).
  • Delivered for under €700 inc VAT, from multiple suppliers across Europe including Amazon.

Unlike the LG, the EW3280U has plenty of in depth reviews, including many hours of YouTube video reviews and deep testing of the monitor in almost every conceivable use case. I read and watched a lot of those reviews, and felt I knew what I was buying, so I pulled the trigger from Amazon Germany to avoid the Brexit tax. It arrived seven days later:

After it arrived and I’d used it for a day I realised it was too high up, so I ordered a desk clamped mount the ErGear EGSS6-E from Amazon UK for £31 (which is under the Brexit tax threshold) which claims 12kg monitor weight support (the BenQ is 8kg). Despite it being pretty much the cheapest VESA mount on Amazon able to handle bigger monitors, I found it well made and it works well, no problems with the size nor weight of this monitor at all, and you can move the monitor up, down, side to side, in and out, and tilt/rotate it:

So what’s this monitor like to look at? This monitor is the best monitor I’ve ever tested on http://www.lagom.nl/lcd-test/, out of the box perfect across all the tests. Out of the box colour reproduction and gamma is perfect, without adjustment, at all brightnesses, in so far as I can test without professional equipment. No dead nor bright pixels. There is surprisingly little colour shift from your head position on the IPS panel, display technologies have improved greatly in the past ten years since I bought my previous monitor. This is a HDR and wide gamut monitor, but my five year old graphics card can’t do better than deliver a 10 bit sRGB signal, so I can’t comment on any of that stuff unfortunately. Sound quality from the monitor is unusually good due to its subwoofer, it’s actually usable for EDM though the lowest bass tones like in dubstep don’t render. You can have it optionally change its colour and brightness rendering to match your current environment e.g. turning on the room light (which is warm white) has a noticeable effect on the monitor, and that sensor can be disabled. The choice of 32 inch over 27 inch for 4k resolution was definitely the right call, I’m at 100% DPI zoom in Windows and it’s just right. All in all, for the money, I am pleased.

My only concern is that I swear the backlight flickers slightly sometimes, mainly around the top left. It isn’t always there, indeed most of the time it isn’t there. When it appears, or at least I think it appears, I’ve tried recording it with my phone at 60 fps and my phone yields me nothing – though, it may just be auto-filtering out the changes in the brightness to create a more consistent video recording. This BenQ model is supposed to come with DC rather than PWM dimming so it should not flicker. If I knock up the brightness, I swear I still see it sometimes but not always, so it’s definitely not caused by PWM.

There’s a chance it could be me, or the edge backlighting LEDs in the top left of the monitor have a fault in their circuit. Sending it back to Germany for a replacement would be irritating, but let’s see how this coming week fares, it may just be new monitor teething as the electricals settle in or something.

#monitors #vesa-mounts




Sunday 31 January 2021: 02:09. This is the ATorch DL24, a cheap Chinese battery load tester available from Aliexpress and others for about US$30. It is quite famous amongst internet battery testing enthusiasts, because it offers a comprehensive feature suite for one twentieth the cost of typical battery testers. It will do:

  • Constant current testing (Amps)
  • Constant resistance testing (Ohms)
  • Constant power testing (Watts)
  • Constant voltage testing (Volts)

You can program it to stop if voltage drops below a minimum, so you don’t wreck your batteries, or if your battery gets too hot, to prevent explosions. Voltage measurement is now by separate wires in this updated model, so there are no longer problems with voltage droop during high current test loads as found in previous models. It is festooned with connections for ease of testing: Mini, Micro and Type-C USB, plus old fashioned crocodile clips. It can transmit its measurements by Bluetooth, so you can record graphs of battery behaviour over time, just like https://lygte-info.dk/ has. It also has a very nice colour display panel which shows present measurements, and summary measurements. For the money, I came away impressed, though I would hesitate to push more than half its claimed maximum wattage (150W) through it (you can find some entertaining Russian videos on YouTube with this exact model not coping well with 150W of power going through it).

For my purposes of testing my next generation lithium-ion USB rechargeable AA and AAA batteries which I covered a few posts ago, it is absolutely fine as I won’t be testing more than one ampere at 1.5v, which is of course 1.5W, or 100x lower than the claimed maximum. Indeed, during my testing, the heat generated was so low than the fan didn’t even turn on.

Anyway I did not go nuts testing these batteries, so I don’t have a lot of samples. This is because I could only leave it run after the kids went to bed, but I had to tidy it all up before I went to bed, and this limited total testing time possible to a few hours, which necessitated higher load currents under test. So my results are rather for higher currents than is fair to these batteries, as lower current draws will show more battery capacity, by definition. Still my results essentially match those of lygte-info.dk, so I can confirm that my AA ZNTER batteries are absolutely identical to that specific Blackube branded USB battery:

After one month since chargingAfter one day since chargingBlackube measured by lygte (source)
Load current:1A1A0.4A1A0.5A
Capacity (claimed: 1.7Ah):1.357Ah1.471Ah1.556Ah1.591Ah1.629Ah

The higher results for lygte I think are because he has much thicker, higher quality, testing wires than I do. At 0.4A, the gap between my results and his drop markedly, as you’d expect from thinner wires, and if I had had the time to run a 0.1A test, I’d expect mine to be very close to his.

An interesting additional data point is the approx 8.4% capacity loss over a month since charging. I’d love to know if this is due to the lithium cell, in which case the loss will be inverse compounding, or due to the microprocessor handling the voltage conversion which would draw down the battery linearly. If it’s the former, the battery will quickly reduce itself to half capacity, but very slowly reduce thereafter, whereas if it’s the former, these batteries will be flat within twelve months, which I would imagine would do no favours to the longevity of the lithium cell.

I also tested some of the AAA model, which unlike the AA model does not claim comparable power storage to NiMH nor alkaline AAA batteries:

After one month since chargingAfter one day since charging
Load current:1A1A
Capacity (claimed: 0.6Ah):0.489Ah0.525Ah

The self discharge rate here is similar to the AA models at approx 8% per month, and the overstatement of claimed capacity relatve to what I measured is almost identical as to the AA model, at about 15%.

As I concluded in my last post on these batteries, I don’t think these USB rechargeable batteries are quite ready for prime time yet. Firstly, the Chinese really ought to stop adding +12% to all battery capacity claims. It does them no favour longer term. Secondly, these really need to last as long as NiMH batteries do, despite delivering a sustained 1.5v throughout, if people are going to be willing to spend multiple times more to buy them over NiMH batteries. One obvious fix to this is to not deliver 1.5v, but instead to deliver say 1.25v (ideally it would be switchable), and that would deliver a +20% gain in runtime. If they can squeeze a further 20% capacity into the same size profile, now you have a better AA battery in every way, apart from cost.

That’s for the AA size which already has comparable total power (Wh) to NiMH batteries. For the AAA model however, the gap is far larger, currently by about 2x for the higher quality NiMH AAA sized batteries. I suspect this is because the voltage converter and charge electronics takes up much more space, relatively speaking. Given how small those batteries are, how fixed size the converter electronics must be, the AAA size I think will never catch up. Equally, going the other way, C-size and D-size batteries have larger volume where the lithium cell’s much higher energy density really could shine, so for the bigger batteries I can see this next generation technology will become dominant quickly. Not least because few have NiMH C-size and D-size rechargeable batteries as they require a separate charger, and these USB recharged batteries are therefore much more compelling, including containing more power and being much lighter.

#rechargeable-batteries




Click here to see older entries


Contact the webmaster: Niall Douglas @ webmaster2<at symbol>nedprod.com (Last updated: 2019-03-20 20:35:06 +0000 UTC)