BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Home Thermostat Under review will re post it soon

#1

Home Thermostat is under review at this time, will re post it soon.

4 Likes

#2

You should take a look at this article:

Adopting this coding approach will give you a system that’s much more stable and reliable in the long term.

Pete.

0 Likes

#3

very nice project.

I think your loop() function is fine, it is using millis to ensure that things run only when needed. The CPU does not care if the instructions are generated by code within the loop or in functions called by the loop, so it all comes down to how well the code is structured, and you have structured it fine. timer would essentially do what you are already doing.

I would have expected all commercial thermostats to have a DZ. I am surprised to read that they don’t!

Did you check the accuracy of the temperature readings you are getting? I am testing a temperature monitoring system using TMP36 and I am finding the readings rather inaccurate, but then the other three thermometers I am comparing it to are also all over the place!

0 Likes

#4

Code under review, will re post soon

3 Likes

#5

In that case, I think we’ll have to agree to disagree as I stand by my comments 100%

Pete.

2 Likes

#6

I’m surprised there is no flood with this loop :thinking:

0 Likes

#7

Very nice project!!.. Clean looking as well. And I like the detailed info in your topic.

As usual, there is many ways to write code… and wire electrical… but generally there is only a few “approved” ways or regional wiring “codes”.

With Blynk, using the timers like BlynkTimer (version of SimpleTimer) is the approved way primarily to keep things simple and functional for all users to understand and follow along when we teach them how to Blynk.

Often timers can be easier for some to understand than all the millis math. That is why people build these timer libraries in the first place :stuck_out_tongue: It also avoids the ‘traditional’ “Fill yer void loop() with everything” concept of old, which can have dire consequences for new users with Blynk and other IoT applications where constant communication links are required.

You code seems well laid out for a self proclaimed “programming noob” and if it works, great… but I would, as have others, recommend you look at how BlynkTimer works, as it might change how you code further projects.

Now I am going to go twist all the unused white and black wires in my electrical panels together since someone told me the recommendations don’t apply and doing so will stop the unused electricity from dribbling away… :crazy_face: :zap::zap::zap:

(In our youth, I had my sister convinced that static electricity came from unused electrical outlets spilling power onto the carpets :joy:)

0 Likes

#8

Code under review, will re post it soon

1 Like

#9

Oh, not saying to not use millis(), there are times you need to compare time, and timers, while great at countdowns, repetitions, or repetitions within specific counts, etc. They are not necessarily meant for clock related comparisons. The right tool for the job and all that :slight_smile:

But glad to introduce you to the world of BlynkTimer. I have many strange uses of it here - C++ Blynk - Code Examples for Basic Tasks (Work in Progress)

0 Likes

#10

The problem I have with the void loop is this…
A well written void loop should execute hundreds of times per second. It won’t do that if there are too many steps to execute, so the void loop slows down. In your loop, the following has to happen each time it runs:

  • Blynk.run executes (100% essential)

  • Blynk timer executes (not used, so a waste of processor time)

  • Update_Time function runs, this does the following:

    • Evaluates a millis comparison and executes once per 24 hours
  • Heater_ON_OFF function runs, this does the following:

    • Reads the value of a digital pin and assigns the result to a global variable
    • Compares the result to the previous value for that pin
  • Cooling_ON_OFF function runs, this does the following:

    • Reads the value of a digital pin and assigns the result to a global variable
    • Compares the result to the previous value for that pin
  • Fan_ON_OFF function runs, this does the following:

    • Reads the value of a digital pin and assigns the result to a global variable
    • Compares the result to the previous value for that pin
  • Performs an if comparison with millis and 2 global variables

  • Performs an if comparison with millis, one global variable and one static value

  • Performs an if comparison with millis, one global variable and one static value

  • Performs an if comparison with millis, one global variable and one static value

This is the minimum that happens for each void loop cycle, assuming that all of the if statements evaluate to false (which the will most of the time).
There are 3 digital pin reads per void loop cycle, which would probably be better handled using interrupts, and a lot of if comparisons against the current millis values.

One instance of the Blynk timer function would handle all of these timer comparisons automatically, and simplify the code dramatically, whilst allowing the void loop to execute use much more quickly.

If you don’t want to use Blynk timer then you should certainly remove the timer declaration and the timer.run from the void loop, as these are just taking-up memory and processor time.

Pete.

2 Likes

#11

code under review , will re post soon

1 Like

#12

Thank you, Gunner, for the link. You have some good codes examples there. Of course, I will study them, etc. I like the Simple AC Power Monitor Using ACS712.

0 Likes

#13

Love your work on this! Just one question, where are you getting the 12VDC from?

0 Likes

#14

Code pictures under review, will re post soon

0 Likes

#15

Got it thanks. I am still search for an elegant way to take power from the 24VAC and use that to power the thermostat. Even in situations where continuous 24VAC is present (typically orange wire) you could still use the 24VAC to keep a small Li-ion battery charged.

0 Likes

#16

https://www.digikey.com/product-detail/en/cui-inc/PBK-5-24/102-3102-ND/4332653?WT.srch=1&gclid=EAIaIQobChMIlP2GiviR4AIVhSCtBh3JcA1OEAQYASABEgLbwvD_BwE

24v ac to 5 volt dc. use it to power the charger and use the charger and battery to power the esp.

0 Likes

#17

I am using these and they are not expensive but you need house current.
powersupply

0 Likes

unlisted #18
0 Likes