Your topic was MOVED to its current forum category which is more appropriate than the original as it has nothing to do with Installation and Troubleshooting of the IDE
Why do you read from DataSerial into the global String data until '\n' is read and then don't do anything with it? You set data to "" before doing anything with it.
if (Serial.available() > 0)
{
char inChar = (char)Serial.read();
data += inChar;
if (inChar == '\n')
{
parsing = true;
}
}
In this code if there are more than 3 '#' characters in data you will write past the end of the arrData array which could cause all kinds of weirdness due to memory corruption. You may want to put a safety check in for the j index.
int j = 0;
arrData[j] = "";
for (int i = 1; i < data.length(); i++)
{
if ((data[i] == '#'))
{
j++;
arrData[j] = "";
}
else
{
arrData[j] = arrData[j] + data[i];
}
}
here I connect the Arduino Uno with the nodemcu esp8266, the main microcontroller here is the Arduino Uno. Initially, the process of transferring data from Arduino to nodemcu was done by sending a "Yes" message to the nodemcu serial monitor, and it worked. but at this point I want to change the action by using the button.
I still haven't found a solution to solve this problem. Maybe you can help me, for more detailed diagram and code I have posted a new forum here. Thanks in advance.
Hello Everyone.. I have some problem in building a prototype..
Actually, I've asked this problem on my forum before, but I still can't find a solution.
At first, my prototype parse the data that had been obtained into the database by type some characters on the serial monitor. But now, I want to change that action by pressing the button.
Your two topics on the same or similar subject have been merged.
Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.
Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.
Repeated duplicate posting could result in a temporary or permanent ban from the forum.
Could you take a few moments to Learn How To Use The Forum
It will help you get the best out of the forum in the future.
I still haven't given the code to access the button because I'm still confused where I should put the code, whether I should put it in the NodeMCU or in my Arduino.
If it's like this then I put the code to access the button on my Arduino, isn't it? Then what about the data request action that was initially performed by NodeMCU?
why do you have both an Arduino and MCU? how do they communicate? can't the MCU connect to the same devices
on the processor the button is connected to
in your MCU code why do you put client code inside the condition when parsing is true? don't you want it to execute when you haven't received any serial data?
shouldn't the relevant code under the parsing condition only be executed when you've received serial data?
shouldn't you only "connect" once, in setup()?
why are there 2 while loops checking for client available
why is there a timer that delays execution in parsingData()? is this unrelated to Serial input?
if there are multiple sources of input shouldn't loop() be structured and either doing a read() or readBytesUntil()?
void loop ()
{
if (Serial.available() > 0) {
char inChar = (char)Serial.read();
// ...
}
if (DataSerial.available() > 0) {
data += char (DataSerial.read());
// ...
}
if (client.available()){
String line = client.readStringUntil ('\r');
// ...
}
}
I use Arduino cause I need some analog pins in this case. But this Arduino that I used can't directly connect to the internet, that's why I connect My Arduino with NodeMCU using serial communication.
And about the other question, I think you are right, maybe I check again my MCU's code.