Tuesday 16 December 2014

ArduinoHomeAutomationProject: The BridgeNode: PROTOTYPE & SKETCH (USE AT OWN RISK!!!)

The BridgeNode: PROTOTYPE & SKETCH (USE AT OWN RISK!!!)

The bridge is handling the data from the RaspberryPI SerialPort. I decided to take the USB Serial because there is no need to add a voltage divider (RPI 3,3V Logic, Arduino 5V Logic). The Incoming data is forwarded over the SoftwareSerial (RS485) while setting the DE Pin of the MAX485 high.
This is working for both directions. It is working at the moment, but i have to test it with more nodes to check for timing mismatches.

The Setup is an ArduinoNano + MAX485. 




THE CODE

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup()
{
  Serial.begin(19200);
  mySerial.begin(19200);
}
void loop()
{  mySerial.listen();
  if (mySerial.available())
    Serial.write(mySerial.read());
    //delay(1);
  if (Serial.available())
    mySerial.write(Serial.read());
    delay(2);
}

No comments:

Post a Comment

Impressum

Auer Markus
Karwendelstr. 13
A - 6020 Innsbruck