Rs485 blynk

I have such a scheme, the nano transmits the millis () value through the RS485 module, the mega receives this signal and must transmit it to Blynk to the smartphone, everything works separately, I checked the transmission through the Serial, the connection to Blynk is also correct, several reservations at once, transmitted to later, there will be a different value, but this is like a test, and such a frequent interval of calling the timer timer1 in mega to catch the reception of a signal from the RS485 module

mega sketch

#include <Blynk.h>

#include <Ethernet2.h>
#include <BlynkSimpleEthernet2.h>
#include <SoftwareSerial.h>
#define DIR 6
#define DIR1 7
/*

        Pins 10, 11, 12 and 13 are reserved for Ethernet module.
        DON'T use them in your sketch directly!
*/

SoftwareSerial RS485(50,51);  // (RX,TX)
//  ro - RX 
//  di - TX
BlynkTimer timer1;

void test(){
  
if (RS485.available())
{
  Serial.write(RS485.read());
  
}
}


/char auth[] = "Gz2ilfCKCdrdrxoMx76zFRAbB3jFSmMK";


void setup()
{
  
  RS485.begin(9600);
  Serial.begin(9600);
  
 timer1.setInterval(5,test);
   Blynk.begin(auth);
  pinMode(DIR,OUTPUT);
  digitalWrite(DIR,LOW);
  
  pinMode(DIR1,OUTPUT);
  digitalWrite(DIR,LOW);
  
} 


void loop()
{ 
// test();
Blynk.run();
timer1.run();  
}


nano


#define DIR 13

SoftwareSerial RS485 (7, 6);



void setup() {
  
RS485.begin(9600);

pinMode(DIR,OUTPUT);
digitalWrite(DIR,LOW);

pinMode(13,OUTPUT);
digitalWrite(13,LOW);

}

void test()
{
  
  digitalWrite(DIR,HIGH);

  RS485.println(millis());
 
  digitalWrite(DIR,LOW); 
  
 delay(2000);
}

void loop() {
 test();
}

Well, you don’t have any Blynk libraries in your Mega sketch, you aren’t initiating a connection to the Blynk server, you aren’t servicing the Blynk connection via a Blynk.run() command, and you aren’t writing any data to Blynk via Blynk.virtualWrite() commands, so this statement can’t be true.

Pete.

my mistake, I did not add #include, but they are in the code, and I commented out the lines and forgot, just commenting on certain lines, I checked the functionality of the code

So are you going to post your actual code?

Pete.

now everything is relevant

You should try compiling the code you’ve posted, then you’ll see that is still isn’t a viable sketch.

What do you see in your serial monitor?

How do you imagine that the data is being sent to Blynk?

Pete.

when I comment on the part when connected to the connection with the blink, then the reception from Rs485 works, when I comment the lines with the blink, the reception from Rs485 starts working, the code works, in parts, but not at the same time =)

Pete.

outputting the millis () value that comes with nano, but this is when I comment out the connection lines with the blink,
first, I would like to receive a signal via rs485 and see the board in the list of connected on the smartphone

This is the Blynk forum. We aren’t interested in what happens when you comment-out the Blynk code.

I’ve asked you two questions, and repeated them a second time. You haven’t shown us what appears in the serial monitor, or told us how you think the uptime data will make its way to the Blynk app.

If you want us to help you then you have to start by helping yourself and answering questions fully and providing information when it’s requested.

I’ll try again…

Pete,

1 Like