IoT Hottub Temperature Controlled Power Switch: Difference between revisions

From munkjensen.net/wiki
No edit summary
No edit summary
Line 2: Line 2:
=== Shopping list ===
=== Shopping list ===
# Buy a [https://www.google.com/search?q=sonoff+th16 TH16].  
# Buy a [https://www.google.com/search?q=sonoff+th16 TH16].  
# Buy a temperature sensor that fits TH16 and your needs. I use the Sonoff DS18B20 waterproof temperature sensor.
# Buy a temperature sensor that fits TH16 and your needs. I use the [https://www.google.com/search?q=Sonoff+DS18B20+waterproof+temperature+sensor Sonoff DS18B20 waterproof temperature sensor].
# Buy a 3.3 volt [https://www.google.com/search?q=usb+to+ttl+ch340 USB to seriel adaptor]
# Buy a 3.3 volt [https://www.google.com/search?q=usb+to+ttl+ch340 USB to seriel adaptor]


Line 15: Line 15:
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.
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.
# 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 ;-)
# 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 ;-)
# 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.
# You can use [https://www.chiark.greenend.org.uk/~sgtatham/putty/ 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 configuration ====
''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 ;-)
 


 





Revision as of 10:46, 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

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 configuration

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 ;-)



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