started: 08.05.2020

#### The project code on GitHub

My goal is change the hot-tub project so that I can change the temperature of the water flowing to the hot tub programmatically instead of having to set the heat before going into the hot tub. This could allow me later, to check how cold it is out side and determine how much the temperature needs to change according to that. I will continue using the system VoffCon to handle the commands via the internet. But additionally I will use google home and IFFFT to allow me to give voice commands while in the hot tub.

I could use a schematic with BC547 provided by Brjánn Guðjónsson to start with. I will probably need to tweek the values for R4 and C1 to configure the frequency to get a decently clean voltage.

Or maybe I could use a MCP4725 to do this.

Valve

Proportional Valve with Esp32

Schematic with BC547

Convert from 3.3V to 5V

RC filter

Filtering out noise from a PWM signal

### Todo:

• Create environment so you can start sexperiment 7. That is connect the two valves to a water supply and connect the temperature sensor also.
• Finish test 7. That experiment should result in a program which can be used to mix the heat of the water flowing to the hot tub.
• Finish test 8. Think about the weather out side, if it's cold and/or windy out side we will need hotter water. (Maybe get info about current wether from vedur.is programmatically).
• Remove current fill motorized valve (R1) from the home plumming system.
• Plug proportional valve 1 into my house hot water pipe and connect it to the hot tub pipe.
• Plug proportional valve 2 into my house cold water pipe and connect it to the hot tub pipe.
• Plug the valve into my house hot and cold water pipes and connect it to the hot tub fill valve.
• Design a box around the project, glue it and put the project into it.
• Wire everything, put it into the box and mount it on a wall.

### Tests

#### Test 1 - Arduino Nano connected to valve (fail)

Arduino Nano D5 pin connected directly to the valve green wire. V5 GND and 12V ground connected together. 12V+ connected to valve red wire. and 12V- connected to valve black wire.

#### Result

I consider this test as a fail because the valve was very jittery. That is, the valve did change position, but never completely stopped. Alway continues little irritating corrections.

#### Test 2 - Nano with RC filter (Success)

Using the RC filter (see image "RF filter") connected to D5 on a Arduino Nano. The test code makes the Arduino Nano read a value from the serial and writes that value to the D5 pin. Then nano will read a A1 pin which is connected to a feedback wire on the Valve.

##### Connections
Arduino Nano Mini USB
Is connected to Computer USB
Arduino Nano D5
Is connected to R6
R6 1kΩ
Is connected to Arduino D5, C5 and R1
C5 0.1μf
Is connected to Ground, R6 and R1
R1 10kΩ
Is connected to R6, C5, C1 and Valve green wire
C1 10μf
Is connected to Ground, R1 and Valve green wire
Valve black wire
Is connected to Ground
Ground
Is connected to Arduino Nano GND, Power supply 12V-, Valve black wire, C5 and C1
Power supply 12V +
Is connected to Valve red wire
Arduino Nano A0
Is connected to Valve white wire
Valve yellow wire
Should be, but isn't connected to R7
R7 680Ω resistor
should be, but isn't connected to 12V+ and LED
LED 3.3V
Should be, but isn't connected to 12V+ and R7

#### Result

Success, You can click here if you want to see a YouTube video of this test in action.

#### Test 3 - Esp32 with RC filter and logic level converter (fail)

test3-second

Possible connections for test 3 - second image

#### Result

This experiment failed. The voltage on the output Green wire went from low: 1.2V to high: 3.2V, but needs to go from 0V to 5V. The valve was little bit open and then just opened just a little more. Never completely open nor completely closed.

#### Test 4 - Esp32 with BC547 (fail)

Using the BC547 (see image Schematic with BC547) and the RC filter (see image RC filter) connected to the Esp32. Then nano will read a A1 pin which is connected to a feedback wire on the Valve.

#### Perhaps I could get away with wiring like this

test4-second

Possible connections for test 4 - second image

I tested powering the Esp32 with 12V via til VIN pin. This resulted in the on board voltage regulator heating up to 56° while just blinking one led, no wifi operations where even running. After little googling I found out this is a issue with the Esp32, it's probably best to be in the 5-7V range. The valve will run on 9V. So may be I'll try that. I would like to have only one power source powering the Esp32 and the valve. Maybe I can step down the voltage from 12V before connecting it to the VIN.

#### Result

The experiment was a Fail. Because there are issues, like little jittering and out max output to the green wire is just over 4 volts, but should be max 5 volts.

#### Test 5 - Esp32 with PWM to Voltage converter module (Success)

Using the PWM to Voltage Converter module (see product PWM to Voltage Converter on aliexpress)

#### Wiring the experiment

##### Valve wire colors
(RD) +DC 9-24V (Red wire)
(BK) -DC GND (Black wire)
(GR) lin: 0-5V (Green wire)
(WT) Out PWM OC signal (White wire)
(YM) Error output signal (Yellow wire)

##### Wiring diagram
                                                     GND +12V
│   │
│   │
╔═══════════╗      ╔═════════════╗  │   │
║  -ESP32-  ║      ║    PWM to   ║  │   │      ╔══════════════╗
║           ║      ║   voltage   ║  │   │      ║     Valve    ║
╔══════════╗   ║           ║      ║  converter  ║  │   │      ║              ║
║-HLK-PM01-║   ║           ║      ║             ║  │   │      ║      PWM Out-╟─(WT)─
║          ║   ║           ║      ║        GND -╟──┘   │      ║         ERR -╟─(YW)─
║+Vo (+5V)-╟───╢ VIN       ║      ║        VCC -╟──────┴─(RD)─╢- VCC         ║
║     -Vo -╟───╢-GND  GND -╟──────╢- GND   GND -╟────────(BW)─╢- GND         ║
╚══════════╝   ║      D26 -╟──────╢- PWM  VOUT -╟────────(GW)─╢- LIN         ║
╚═══════════╝      ╚═════════════╝             ╚══════════════╝


Ps. Instead of using 12V power supply you could any source ranging from 12v to 24V.

test5

Image of connections for test 5

#### Result

The experiment was a total Success. No jittering problems and the voltage range is from 0 - 5V volts.

#### Test 6 - Esp32 reading from temapture sensor (success)

Reading values from DS18B20 (see product DS18B20)

#### Wiring the experiment

##### Wiring diagram
 ╔═══════════╗                        ╔═══════════╗
║   ESP32   ║                        ║  DS18B20  ║
║           ║                        ║  Sensor   ║
║           ║                        ║           ║
║    GND   -╟────────────────────────╢-   GND   -║
║    3V3   -╟──┬─────────────────────╢-   VCC   -║
║           ║  │  ╔═══════════╗      ║           ║
║           ║  │  ║-Resistor -║      ║           ║
║           ║  └──╢-  4.7kΩ  -╟──┬───╢-  Signal -║
║           ║     ╚═══════════╝  │   ╚═══════════╝
║    G12   -╟────────────────────┘
╚═══════════╝


#### Result

The experiment was a Success. The sensor I used did not react quickly to temperature change but I think that will be ok if i use the PID library.

#### The Test code

To use this code you must first get these two libraries
• OneWire library by Paul Stoffregen
• DallasTemperature by Miles Burton.

#### Test 7 - Create a water mixer program (not started)

Create a program which can be used to mix the heat of the water flowing to the hot tub. Best would be to use a the PID library to do mix the water.

todo:

#### Test 8 - Get the current local wether (not started)

Get the temperature and wind outside so you can deside if the water flowing to the hot tub needs to be a little warmer or colder

todo: