

Again, many thanks for all the advice and time you have taken to respond to me. I can see how I’ll have to learn more about it to make sure things are running properly. Frankly I didn’t realize how much influence the RTOS had over my apps. This is really the first problem that threw me for a loop. I really like the ESP and learning from Rui’s tutorials has been amazing. I have only written 3 apps using the ESP32 so far. I have written over 100 sketches for the Arduino family from AT85s to the MEGA. I like the idea of leaving the watchdog timer alone to make sure it can do its job. In the past, I have used the procedure of removing code, a little at a time, to find where the failure point occurs.
Arduino infinite loop code#
But once I added a few more sensors to cpu 1 and made the code on cpu 2 closer to the actual application, it began to fail.


I even added some GPS code to the sensor cpu and that was working fine. It was working just running the basic code that Rui presented in this tutorial. Basically, it is like some that you have mentioned where one cpu monitors multiple sensors and the other cpu performs a critical task, as long as the sensors are reading ok. All of you are fantastic! I’m under a NDA with this project, so I can’t say too much about the application or the code. WOW! I am amazed at all the responses to my question and I am very grateful for all the information that has been sent to me.
Arduino infinite loop serial#
Open the Serial Monitor at a baud rate of 115200. Make sure you have the right board and COM port selected. So, instead of creating a task to run on core 1, you can simply write your code inside the loop(). Note: as mentioned previously, the Arduino loop() runs on core 1. Here’s how the task function looks like: Void Task1code( void * parameter) In this example you need to create the Task1code() function. After creating the task, you should create a function that contains the code for the created task. Task1code, /* Function to implement the task */ģ. That function takes several arguments, including the priority and the core where the task should run (the last parameter). In the setup() create a a task assigned to a specific core using the xTaskCreatePinnedToCore function. An example for Task1: TaskHandle_t Task1 Ģ. To create tasks you need to follow the next steps:ġ. The processor will run the tasks with higher priority first. When creating a task you can chose in which core it will run, as well as its priority. Priority values start at 0, in which 0 is the lowest priority. To assign specific parts of code to a specific core, you need to create tasks. For example, it can be blinking an LED, making a network request, measuring sensor readings, publishing sensor readings, etc… Tasks are pieces of code that execute something. This allows us to handle several tasks in parallel that run independently. The Arduino IDE supports FreeRTOS for the ESP32, which is a Real Time Operating system.
