0

Multitasking Question
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Multitasking Question

by dbeck01 on Mon Nov 27, 2017 1:18 pm

Hello Experts,

I have a question about Adafruit IO and a project I've been working on.

Right now, I have deployed a Feather Huzzah (ESP8266), programmed in Arduino IDE, with a slightly modified version of the Digital Out example sketch to control an SSR hooked up to an aircraft preheater (115VAC) which I control over Adafruit IO. It works great and I'm grateful for the guidance and support offered by Adafruit to realize this project.

My question is, I would like to add the ability for the project to report back the engine temperature every five minutes or so, whether the heat is on or off.. I also built the temp/humidity example on a breadboard but I am wondering if it will be possible to COMBINE control and monitoring on one board/sketch without conflicts. Specifically, my concern is what would happen if a "DIGITAL HIGH" command is sent when the sketch is polling the temperature sensor? Would the incoming command remain "in cue" and be executed milliseconds later, or would it be missed and lost while the temperature task is executing? I realize I should use a MILLIS command vs DELAY to time the sending interval but I'm not really familiar with how the subscription commands are handled with other tasks going on.

Your expert advice is greatly appreciated.

Doug

dbeck01
 
Posts: 2
Joined: Thu Nov 16, 2017 1:53 pm

Re: Multitasking Question

by btreichel on Wed Nov 29, 2017 6:18 pm

Yes, however you will want to wrap the either the controls, or comm in a timer. aka read millis, and then execute on if mills + 5000 is > type setup. Thats the simple way to time things and allow other tings to execute.

btreichel
 
Posts: 79
Joined: Tue Jul 25, 2017 3:00 pm

Re: Multitasking Question

by btreichel on Sun Dec 03, 2017 12:12 pm

Ran across this, this morning. Good guide for what you want to do. https://learn.adafruit.com/multi-tasking-the-arduino-part-1/overview then just add in the ada io as another task.

btreichel
 
Posts: 79
Joined: Tue Jul 25, 2017 3:00 pm

Please be positive and constructive with your questions and comments.