Hi guys
I'm not very good at English, sorry if I have typing problems
I ran into a problem in my project
I have an rs485 temperature module that I monitor the temperature with the following code, a default code from internet sites
The problem is that
I want to send an int value with another arduino to the arduino master that reads the temperature
With rs485 module
I don't know how to do this
Further, you're using Serial1 for communication with the other Arduino ad far as I understand your code. In which case you still have the USB available on the Every for debugging.
Serial port 1 is only for displaying my information and in Arduino every serial for printing should be serial 1
But in Nano I use serial
And the sending code, for example, the last code for the test is as shown below
#include <ModbusMaster.h> //Library for using ModbusMaster
#include <SoftwareSerial.h>
SoftwareSerial Serial2(9, 3); // RX, TX
#define MAX485_DE 4
#define MAX485_RE_NEG 5
ModbusMaster node; //object node for class ModbusMaster
void preTransmission() //Function for setting stste of Pins DE & RE of RS-485
{
digitalWrite(MAX485_RE_NEG, 1);
digitalWrite(MAX485_DE, 1);
}
void postTransmission()
{
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);
}
void setup()
{
pinMode(MAX485_RE_NEG, OUTPUT);
pinMode(MAX485_DE, OUTPUT);
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);
Serial.begin(9600);
Serial2.begin(9600);
Serial.setTimeout(50);
node.begin(1, Serial2);
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
}
void loop()
{
node.writeSingleRegister(1,123);
}
Can you post a wiring diagram showing how everything is connected?
Are you using the boards package for the Thinary Nano Every, since you appear to have the third-party version of the board and not the official Nano Every with the atmega4809.
If you use MCUdude's MegaCoreX you will be able to use all three hardware serial ports on that board.
I connected the pins as shown above to the rs485 module and Arduino nano every, of course I receive data from the module, but I can't receive information from the second Arduino, the two Arduinos are connected the same way
This post is no improvement from the previous wiring description. For the second Arduino, which pins are used and where do those wires connect elsewhere in the circuit. For a better explanation of the information necessary to understand your project and provide you with help instead of just questions, please refer to this article:
When we see the circuit diagram, we will be more helpful. Thank you for your understanding.
I think I see the problem but without an annotated schematic I will decline to take a SWAG. KiCad is a great CAD (Computer Aided Design) package that is so inexpensive it is free for the download. A donation is requested but not required.
Is the 2nd Arduino connected to the RS485 bus, or are you attempting to connect the 2nd Arduino directly to the 1st Arduino on the same pins as the RS485 module?