accur4te
accur4te
DIIDevHeads IoT Integration Server
Created by accur4te on 6/20/2024 in #edge-networking
use MAX485 TTL to RS485 Converter Module with esp32 to get convert value of rs485 output to serial
#include <HardwareSerial.h> #define DE_PIN 2 // GPIO pin connected to DE (Data Enable) and RE (Receiver Enable) pins of MAX485 #define RS485_SERIAL Serial2 // Define the Serial port used for RS485 communication void setup() { Serial.begin(9600); // Initialize serial monitor RS485_SERIAL.begin(9600); // Initialize RS485 serial communication pinMode(DE_PIN, OUTPUT); // Set DE pin as output } void loop() { digitalWrite(DE_PIN, HIGH); // Enable transmission mode if (RS485_SERIAL.available()) { // If data is available on RS485 port while (RS485_SERIAL.available()) { // Read all available data char c = RS485_SERIAL.read(); // Read character Serial.print(c); // Print character to serial monitor } } digitalWrite(DE_PIN, LOW); // Disable transmission mode delay(100); // Delay before checking for new data }
13 replies