Midweek Ramblings

Following my addition of the BME280 code to Home Control 2016, a couple of guys have suggested they might like to see more accuracy than the integer I use for temperature so I’ve added a new polled value {hightemperature} which is simply the temperature value *10 – but with that extra accuracy – so for example hightemperature mod 10 would give you the decimal point. Not sure I see a need for even higher precision so we’ll leave it at that – personally I just use temperature to the nearest degree.


I’m also playing as you know with port expanders and having already ran out of ports I’ve added an experimental additional 8 port outputs via one of those cheap port expanders I referred to in a previous blog entry.  So assuming this is set to address 38 (typically that’s switch 3 set to off, the others set to on) you can do simply control of out17 to 24, bearing in mind these things start off as inputs floating high.

Port expander

I’ve not attempted at this point to store values in FLASH or preset them on power up – let’s see how much use this gets.

See the Home Control 2016 manual for updates.

On a different tack, this might seem obvious to the hardware guys here and it should have been obvious to me as I’ve been working with electronic hardware since I was old enough to think –  but I made the mistake of getting lazy recently – on my new pergola. I set up on of our boards with a cheap Chinese relay board on GPIO12 – to control a water mister (it gets hot here).  So I would use the timed outputs for example {out12:6,2] which sets output 12 on for 2 minutes before timing out back to OFF state.

I had the water fittings all set to go, got my Imperihome App out, pressed the button and sure enough – excellent misting. I pressed the button to turn the mist off and…. nothing.

I figured a jammed relay – but no. Out of desperation I checked the actual state of the port as set in memory – and it said the output was on – but I’d turned it off – this was impossible. I sat and went through the code over and over – no issues.

I made the classic mistake of assuming the hardware was perfect and it had to be a software issue. In FACT, even though the misting system was kind of isolated from the board by the little external relay board, said relay was powering a 12v washing machine coil – and as it turns out the backlash from the coil was having the weirdest effect on the board – stopping that port turning off – to this day I still can’t explain it as it was actually affecting storage of info in the chip.  I can only assume a voltage spike getting back to the board itself.


I know, sounds daft, so I put a diode across the washing machine solenoid – something I should have done in the first place. Immediately – 100% perfect operation tested over and over. Worth knowing about. See purple diode below.

diode to stop interference

Also added {reset_config} command so that from serial you can reset the board to defaults  – for security this will not work from MQTT.


13 thoughts on “Midweek Ramblings

  1. I installed a Heatmiser wifi thermostat at home and took the mains power from a nearby light switch (strangely, our light switches have both live and neutral in the box behind the facial). Anyway, it made the wiring easy.

    That evening, as I turned off the florescent light in our utility room, I heard a little ‘pop’. I didn’t think anything about it. As it got colder in the house, I went to the Heatmiser and the display was blank. After a bit of investigation, I found the Heatmiser was OK but the 240V to 5VDC power supply had blown.

    I spoke to Heatmiser tech support and they suspected the florescent lamp was causing the failure. The guy told me that such a lamp could put a spike of over 700V onto the supply. I re-wired the Heatmiser into the ring main with a switched spur and all has been fine ever since.

    So, beware of florescent lamps too!!

    1. Well yes indeed, I’m aware of this – but good advice for others in here with less hardware experience.

  2. Hi Pete,
    It is a rule of thumb to connect a reverse biased diode parallel to any DC driven solenoid – snubber diode prevents damaging the driving circuit from back emf.

  3. Again – it’s not the relay board – it’s the inductive load at the other end – no doubt a spike coming down the wire and getting inducted somehow back to the board…. the diode stopped it.

  4. Hi Pete,
    I’ve recently been thinking about some projects using relays and every time I have, a little voice in the back of my head reminded me about “switching inductive loads” but for the life of me I couldn’t remember why that stuck in my head from 30 years ago when I did my BTEC in Electronics. I think your experience with the solenoid just illustrated that.

    1. Yes Brian – it is far to easy to forget that the simple backlash of turning juice OFF to a coil can in itself be dangerous. In fact I missed off part of the story as I’d already fitted a VDR to the relay connector on the little relay board – clearly in this case it was not good enough – but with the diode in place, continuous testing shows all is well. The good old 1n4001 continues to show it can do a good job despite the ridiculous low cost (mind you – I also have a roll of several hundred of them lying around which is another incentive to use that particular device) 🙂

        1. The inductance issue is not coming from the relay board – it’s coming from the honking great inductor in the washing machine controller…. and yes, I’ve used them and they are fine though usually lower power handling than relays – but boy – they have come down in price.

          1. The little relay breakout modules typical of arduino have in general a little diode on board for each relay… Is it enough or is it only to protect arduino pins?

  5. Peter, if you remember i had problems with an olimex esp8266-evb board that integrates a relay, a few days ago… turns out it was my laptop power supply to interfere with the relay… i had the same issues as you, relay reported as on or off, but i didn’t “tick” the coil… if i put it near my laptop PS, it gets crazy…

    side note: if you have more than 1 I2C device, how do you connect to the esp? Do you have a board where to connect in parallel the modules’ i2c pins? or what?

    1. Yes electrical interference – bane of my life – anyway that diode fixed it…. more than one I2c device – well you make sure only ONE of them has pullup resistors on SDA and SCL – and just fasten them all in parallel… given the nature of the GPIO pins I would guess you could probably stick half a dozen or more on with short leads – I’m running 3 devices without issue.

  6. Does a double take on picture to confirm that the wiring to the solenoid is running @ 12V and not mains!

    Wish I had more time to work on this kind of stuff, but the day job gets in the way!

    1. You could of course run the solenoid on the mains – and it might then double up to fry eggs with a pan above it 🙂

      Make sure the day job doesn’t get too much in the way – we don’t live forever – and fun is important!

Comments are closed.