hi guys!
i connect arduino and nodemcu to each other with software serial.
i send a message like "20ha " (this word has 16 letter) from arduino to nodemcu.
but now i donot know how to save this message to string in nodemcu.
pls help if u know.
nodemcu code:
#include <SoftwareSerial.h>
SoftwareSerial s(D6,D5);
String GetDate;
void setup()
{
Serial.begin(9600);
s.begin(9600); Serial.println("yes we connect to eachother");
}
void loop () {
while (s.available())
{
GetDate = ???????? /// what code i should write here?
}
Serial.println(GetDate);
delay (2000);
}
Did you use 5V to 3.3V level translation?
aarg:
Did you use 5V to 3.3V level translation?
i mean i connect with software serial.
aarg:
Yes, but did you?
why should i connect 5v to nodemcu ?!!!!!
can you help me to solve this problem.
okay i found the solution. thank god!
#include <SoftwareSerial.h>
SoftwareSerial s(D6,D5);
char chare [16] ={};
int R;
void(*Reset) (void) = 0;
char inchar ;
String a;
void setup()
{
Serial.begin(9600);
s.begin(9600); Serial.println("yes we connect to eachother");
while (!s.available())
{
delay (1000);
Serial.println("pls send data");
}
for (int i=0; i <16; i++)
{
while (s.available())
{
Serial.println("data received !");
inchar = s.read();
a += inchar;
}
}
void loop()
{
Serial.println(a);
delay (5000);
}
hadimargo:
okay i found the solution. thank god!
#include <SoftwareSerial.h>
SoftwareSerial s(D6,D5);
void(*Reset) (void) = 0;
char inchar ;
String a;
int R;
void setup()
{
Serial.begin(9600);
s.begin(9600); Serial.println("yes we connect to eachother");
while (!s.available())
{
delay (1000);
Serial.println("pls send data");
}
for (int i=0; i <16; i++)
{
while (s.available())
{
Serial.println("data received !");
inchar = s.read();
a += inchar;
}
}
void loop()
{
Serial.println(a);
R=Serial.read();
delay (5000);
if (R == '0')
{
Reset();
}
}
the question is how i could not save the blank letters in this code! (' ')
how?
hadimargo:
why should i connect 5v to nodemcu ?!!!!!
can you help me to solve this problem.
You are not familiar with the terminology. That's okay. How are the serial connections made between the two processors? Did you just connect Arduino TX to ESP RX and ESP TX to Arduino RX? If so, you've connected a 5V output to a 3.3V input, which can damage the ESP.
About your software question, you have not stated the problem clearly enough for people to understand and help you.
aarg:
You are not familiar with the terminology. That's okay. How are the serial connections made between the two processors? Did you just connect Arduino TX to ESP RX and ESP TX to Arduino RX? If so, you've connected a 5V output to a 3.3V input, which can damage the ESP.
About your software question, you have not stated the problem clearly enough for people to understand and help you.
yes i connect rx and tx from arduino to tx and rx nodemcu.
okay sorry. i didnot know that but in most projects i see connecting without resistor! maybe it's little current didnot make big damage.
my problem solved ! i can create the Solution code for my problem and share it here but one question still is here how to not save blank letters!.
That is drop dead easy. You read the character, check to see if it's a space, and don't append it to the string if it is... I assume you are familiar with the 'if' statement that you can use for this.
if (inchar != ' ') {
As far as the 5V/3.3V thing, "most projects" are wrong. It's great that beginners can play with this stuff, but it has flooded the internet with projects that are full of beginner mistakes. The ESP isn't going to just give up and die instantly because of an overvoltage. But the reliability is severely impacted. Just wait until you hit your first real "mystery roadblock"... glitch that only happens when you are sleeping, sending you running around checking all your code, your hardware and so on. You are building a house - the house is only as good as its foundations.
aarg:
That is drop dead easy. You read the character, check to see if it's a space, and don't append it to the string if it is... I assume you are familiar with the 'if' statement that you can use for this.
if (inchar != ' ') {
As far as the 5V/3.3V thing, "most projects" are wrong. It's great that beginners can play with this stuff, but it has flooded the internet with projects that are full of beginner mistakes. The ESP isn't going to just give up and die instantly because of an overvoltage. But the reliability is severely impacted. Just wait until you hit your first real "mystery roadblock"... glitch that only happens when you are sleeping, sending you running around checking all your code, your hardware and so on. You are building a house - the house is only as good as its foundations.
okay i found an easy order to delete ' ' (spaces); just in last line of setup void, i should add this:
a.trim();
and string a hasnot sapce.
so i should use resistor in serial connection?
aarg:
You are not familiar with the terminology. That's okay. How are the serial connections made between the two processors? Did you just connect Arduino TX to ESP RX and ESP TX to Arduino RX? If so, you've connected a 5V output to a 3.3V input, which can damage the ESP.
The ESP8266 I/O is 5V tolerant unless couple of uA current can destroy the chip. Except for completely wrong wiring, such as feed 5V into 3.3v rail or feed 5V into output pin (in output low state or in output high with push-pull mode), 5V on GPIO pins will not destroy ESP8266.Aug 3, 2016
I have been always interfacing my UNO with NodeMCU/ESP8266 without level sifter.
hadimargo:
so i should use resistor in serial connection?
you were told two or three times to put a level shifter. If you dont know what it is, google it
@GobalmMustafa
I "followed" such suggestions for SIM800L module. After burning 2 of them, I used a level shifter
GRuser:
@GobalmMustafa
I "followed" such suggestions for SIM800L module. After burning 2 of them, I used a level shifter
We are talking about connecting UNO and ESP not UNO/ESP and SIM800L.
what does a level sifter Do?
GolamMostafa:
We are talking about connecting UNO and ESP not UNO/ESP and SIM800L.
hadimargo:
what does a level sifter Do?
Hope that the following picture/diagram (Fig-1) will help you to understand the need/function of a level sifter.
Figure-1:
1. BME280 chip works on 3.3V; so, any potential/logic greater than 3.3V (when impressed on the chip) might damage the chip. Therefore, it is necessarry to use 5/3.3V level sifter and 5/3.3V voltage regulator for the operation of the chip with 5V UNO (Fig-1).
2. There are BME280 Modules which contain BME280 chip, the 5/3.3 voltage regulator, and 5V/3.3V/5V level sifters; these modules can be directly connected with UNO without level sifters (Fig-2).

Figure-2:

Level shifters are not necessary. Simple 1K series resistors will work just fine.
Regards,
Ray L.