IoT Hottub Temperature Controlled Power Switch: Difference between revisions

From munkjensen.net/wiki
Line 33: Line 33:
Enter the IP in your browser and configure the TH16 to connect to your WiFi. BE AWARE that if you screw this up and enter wrong data/credentials you MIGHT need to re-flash to get the first-boot WiFi and webpage to launch again ;-)
Enter the IP in your browser and configure the TH16 to connect to your WiFi. BE AWARE that if you screw this up and enter wrong data/credentials you MIGHT need to re-flash to get the first-boot WiFi and webpage to launch again ;-)


Find the NEW IP that the TH16 got on your own WiFi and open that IP in your webbrowser. You should land on the Main-page that shows som genereal information about the TH16.


 
# Click the Config Tab.
# Set Unit Number to 1. If you got more that one TH16 then you need to give them each a unique number here.
# Click Submit at the bottom.
# You don't need to change anything on the Controllers tab.
# Click the Hardware tab.
# Set GPIO → LED to use GPIO--13 (D7)
# GPIO ⇄ SDA & SCL to none.
# Click Submit at the bottom.
# Click the Devices tab.
# Click the Add button left of task 1.
# Select the device that fits your temperature sensor. Environment - DS18b20 if you bought the same as me.
# Set the name to sensorTemp.
# Set GPIO ← TX to GPIO-14(D5)
# Set Number Output Values to Single
# Set Device Resolution to maximum (12 Bit)
# Scroll to bottom of the page.
# Set the name of Value 1 to temperature
# Set the number of decimals to 2.
# Click Submit at the bottom.
# Click the Add button left of task 2.
# Select Generic - Dummy Device
# Set the name to varTemp
# Click the Enable tick-box so it is enabled.
# Set Output Data Type to Single
# Set Interval to 0.
# Set the name of Value 1 to lastValue.
# Set the number of decimals to 2.
# Click Submit at the bottom.
#
#
#
#
#


=== Rule Set 1 ===
=== Rule Set 1 ===

Revision as of 11:10, 17 December 2021

Shopping list

  1. Buy a TH16.
  2. Buy a temperature sensor that fits TH16 and your needs. I use the Sonoff DS18B20 waterproof temperature sensor.
  3. Buy a 3.3 volt USB to seriel adaptor

Documentation & inspiration pages

Flashing

  • DO NOT CONNECT THE TH16 TO MAINS POWER WHILE FLASHING!
  • I flashed my TH16 Ver. 2.1 dated 2019-08-26 with the file ESP_Easy_mega_20211105_normal_ESP8285_1M.bin.

The page Basics: Connecting and flashing the ESP8266 also got a lot of good advice.

Configuration after flashing

You need to do a bit of configureing after your TH16 have been succesfullly flashed. I reccomend keeping the TH16 connected to you computer using the 3.3 volt USB to seriel adaptor untill you are certain it works as you intend. I reccomend this of two reasons.

  1. There is no need to connect it to the mains power before you actually want to use it. This way you are much safer from getting electrical shocks ;-)
  2. You can use PuttY to monitor the activities that your TH16 is performing including errors... and errors will most probably happen unless you are lucky like nobody else.

First boot

NOTE: TH16 can only connect to 2.4Ghz WiFi

Reboot the TH16 after the flasing. Keep an eye on the Putty console. If nothing shows up you need to make sure PuttY is configured to listen on the correct COM port using the correct serial port settings.

After reboot is done the TH16 will start to spit out repeating lines.

Now fetch your smartphone or another wireless enabled device and connect to the open WiFi that the TH16 is broadcasting. Is will be named something like ESP_Easy_0 and you will need to enter configesp as WiFi password. If you are not presented with a webpage automagically - look at Putty to figure out what IP address the TH16 have given it self... 192.168.4.1 could be it but you never know if it gets changed in the future.

Enter the IP in your browser and configure the TH16 to connect to your WiFi. BE AWARE that if you screw this up and enter wrong data/credentials you MIGHT need to re-flash to get the first-boot WiFi and webpage to launch again ;-)

Find the NEW IP that the TH16 got on your own WiFi and open that IP in your webbrowser. You should land on the Main-page that shows som genereal information about the TH16.

  1. Click the Config Tab.
  2. Set Unit Number to 1. If you got more that one TH16 then you need to give them each a unique number here.
  3. Click Submit at the bottom.
  4. You don't need to change anything on the Controllers tab.
  5. Click the Hardware tab.
  6. Set GPIO → LED to use GPIO--13 (D7)
  7. GPIO ⇄ SDA & SCL to none.
  8. Click Submit at the bottom.
  9. Click the Devices tab.
  10. Click the Add button left of task 1.
  11. Select the device that fits your temperature sensor. Environment - DS18b20 if you bought the same as me.
  12. Set the name to sensorTemp.
  13. Set GPIO ← TX to GPIO-14(D5)
  14. Set Number Output Values to Single
  15. Set Device Resolution to maximum (12 Bit)
  16. Scroll to bottom of the page.
  17. Set the name of Value 1 to temperature
  18. Set the number of decimals to 2.
  19. Click Submit at the bottom.
  20. Click the Add button left of task 2.
  21. Select Generic - Dummy Device
  22. Set the name to varTemp
  23. Click the Enable tick-box so it is enabled.
  24. Set Output Data Type to Single
  25. Set Interval to 0.
  26. Set the name of Value 1 to lastValue.
  27. Set the number of decimals to 2.
  28. Click Submit at the bottom.

Rule Set 1

on sensorTemp#temperature do

        // Store current sensor temperature in a dummy variable
    TaskValueSet,varTemp,Dummy,[sensorTemp#temperature]

        // If temperature is above 37 OR the toggleSwitch state is 1
        // then set dummy Switch1 state to 1
    if [varTemp#lastValue]>=37 or [toggleSwitch#state]=1
       TaskValueSet,Switch1,state,1
    else
       TaskValueSet,Switch1,state,0
    endif

        // Set the relay and red LED state to the same state as dummy Switch1 state
    gpio,12,0[Switch1#state]
endon

https://hos.munkjensen.net/vildmarksbad.php