Wow, 32 days since my last post! Thank you for the messages from people on how they enjoyed the blog, and that I need to continue. I have been struggling for 5 weeks with stability on my ‘production system’, which I never moved from breadboards yet. The one board - in the roof at my geyser - gave me  trouble & instability, does not come up after power surges, etc. It feels like I spent more time in the roof the last 5 weeks, than in the home…. a frustrating journey.
But, my soldering skills have improved dramatically, I now know exactly how a opto-coupler works, what all the specifications means on its spec sheets, the rules-of-thumb electronic engineers uses to either limit the flow in a circuit, or pull it up, and have my first properly soldered board, with a nice enclosure in place. I built two boards, had to scrap the first one after it gave really funny results. That was after I discovered the proto-board has a VCC and GND row on the outmost rows running parallel down inside the board, would have been great if this was on the specs of the web page where I bought it. But then used a second board, utilising these two rows.
Also now know the ins-and-outs of how the 100Amp solid state relay work with which I switch the geyser on- and off. When I applied 5v directly to it, without any circuitry, it would open the 230v flow, but any form of circuitry in between would only switch on an LED on the relay, but not actually for the 230v circuit. No matter what I tried, could not get this sorted. Tried to drop the optocoupler and used a logic level converter 3.3v from ESP8266 GPIO02 to the 5v relay, swopped GPIO02 to GPIO16, played around with the optocoupler 4N25 circuits, tried the two ways it can be wired, tried all the combinations of IN and OUT inline resistors using the calc’s people suggested on forums. By the way, of all the sites I studied on how to wire an Opto, this 'talking electronics' one was best.  Do you know the two ways to wire an Opto?

I got it working on the 2nd option, using rule-of-thumb of calculating current limiting resistors - calculate for 200-300% of flow, taking into consideration the max current flow the Opto can work with, in the case of the 4N25, 50mA in and out. But I tested the output voltage, and current, went for the lowest possible current and volts that switches the 100A relay, to save power. I also learnt that over time the LED’s in Opto’s and solid state relays decays with use, specially if the current is at its max, so time will tell if going for the lowest working current was a good idea. By the way, to keep this relay open, takes the optimum of 7.3 mA, measuring 2.98V over the 5-24v pins of the opened relay. I finally went with a 260Ω in-line resistor on pin 5 of the Opto to GND, and a 330Ω in-line from GPIO16 to pin 1 of the Opto. But it turned out the 100A was u/s, the chaps at robotics.org.za did some thinking with me, then at last exchanged the relay, and it is now working again with this config. See this relay below:

Below a picture of the enclosure I built - closed. I love how neat it came out. the 2nd picture shows the inside, see how neat the 12-way plug makes the internals. (Steve Jobs would not have approved, but he was also very particular about how the circuits looked like!)

This circuit unit does the following, using the connectors to linkup with its designated sensors:

  1. Reads rain with a tipping bucket rain meter, using a haul effect tipper ; (every counted bucket tip = 0.2794 mm rain)
  2. Switches a geyser on/off based on rules for time of day, rules engine on ESPEasy, on the ESP SoC;
  3. Reads the hot water flow from the geyser to bathrooms; (450 pulses = 1 Litre of water flow)
  4. Reads the outside temp with a Dallas 18b20 - 2 digits accuracy;
  5. Reads the outside luminosity with a TLS2561.

I run the fantastic code from the open source community at espeasy, here to whom I contribute to the community on the discussion forums. As per my previous posts, all comms goes from the ESP, with connected actuators and sensors, to a central RaspberryPi, which hosts MQTT on Mosquitto, Node-Red for IoT control, and MySQL for storing the data from all sensors.
I have learnt so much building the first proper permanent circuit and enclosure, (twice !), that I went onto the next circuit straight away. This circuit will replace the functionality of a 4 channel sprinkling system. I will use 6 relays, 4 for the channels, one to switch on the bore-hole pump, the other one to switch off the current sprinkler controller whilst this IoT based solutions controls the valves, and two water flow meters, one of the municipality incoming water, the other to measure hate flow of the borehole. A last spare GPIO to measure the outside temperature and humidity wit ha DHT22. For this enclosure, it needs to have 6 relay data lines and 5v VCC and GND to a separate enclosure for the 6 relays. For this, I use a 8-way plug used in the sound industry, I also need 4 wires, 2 for data lines on the two haul effect flow meters, and a VCC/GND for them, thus a 4-way plug. Lastly, a 3-way 3.5mm audio plug will feed the DHT22. All of these fed from one circuit, see the progress of it from outside, much neater than the first one !
In a next post, I will continue with the analogy of IoT philosophy to the home-IoT stuff I am doing.

Circuit greetings! Do not give up, push through!

(Originally posted on 7 July 2016 on IoTPlay blogspot)