Hello people,
i still learning to build and program some project and need your help. I want to use NodeMCU (ESP8266) + magnet sensor + active buzzer + BME280 on one board and one sketch. I did success program my BME280 to collect and send data to my SQL server, but now I want to add some other futures like magnetic sensor (for detecting fridge door open) + active buzzer. Did my wiring I thing correct and want to change my .ino file. At the moment in the loop have to collect data from temp sensor and send to MySQL on every 5 minutes. Now I want to monitor magnetic sensor and in case is open more than 3 minutes , buzzer to start ringing. Can I ask you to give me good hint/tutorial how can I do two loops, or monitor two tasks in one loop ?
Turn the computer off, and then on again. It's in the sticky threads at the top of the forum.
aarg:
Turn the computer off, and then on again. It's in the sticky threads at the top of the forum.
https://forum.arduino.cc/index.php?topic=223286.0
this one ?
Yes. With the ESP8266 you also have the option of using RTOS for multitasking. I'm not recommending it, just letting you know.
aarg:
Yes. With the ESP8266 you also have the option of using RTOS for multitasking. I'm not recommending it, just letting you know.
Thank you. I will read that cerafuly.
I think using a RTOS is oversized for your project. I guess it is enough if you detect the opening of the fridge-door after half a second or even after 2 seconds. RTOS is used if you have to react on multiple things within milliseconds and you want to guarantee that the reaction is done always within milliseconds.
How long does it take to send the data to the SQL-server?
I guess you are using the delay()-command to realise the 5-minute-interval.
the command delay() is used in these very basic LED-blink demos. I think showing the command delay to newbees is a very bad idea. The command delay() delays finishing projects through helpless tries to get multiple things working at the same time.
Of course it is possible to to lots of things in one and the same loop. These multiple things are executed one after another but so fast that it looks like "at the same time" Every PC does (most of his work) this way.
If you use the command millis() for realising intervals you can do dozens of things in just one loop.
Here is an introduction to how to use the function millis()
https://forum.arduino.cc/index.php?topic=503368.0
If you post your complete code (the whole *.ino-file ) others can take a look at your code and can give well suited advice
best regards Stefan
You are absolutely right Stefan. I use delay for this project and i'm completely newly ...
Here is my code
i already start to read about millis (), but can't find info about RTSO.
I will give a try with millis ()
topche:
Thank you. I will read that cerafuly.
Oh. The irony.
Hi topche,
if any questions arises I encourage you to post them here. The beginner's guide to use millis() can still be improved. IMHO the best way is to improve a tutorial is read beginners questions.
best regards Stefan