Wie ich feststellen musste, hab ich auch 2 Adriges Kabel verlegt, wohl nach dem Motto
NO NEED SIR...... working with 2 line only
Ich bin ein totaler noob was die Elektronik angeht, bin seit ca 1,5 Jahren erst dabei. Also seitdem ich in diesem Forum registriert bin.
Hatte mich auch damit auseinander gesetzt, zuerst mir KNX mein Glück versucht da ein Kumpel sein Haus damit ausgestattet hat.
Dann kam CAN ins Spiel, war aber komplizierter und teurer als RS485, also entschied ich mich dafür. Auch wenn bei CAN das Protokoll integriert ist. Modbus funktioniert ja auch super in der Industrie also warum nicht im Haus?!
Wenn du das ganze mit openHAB machen willst ( was ich jedem raten kann ), dann brauchst du nur Slaves.
Lies dir meine Threads bezüglich des Programmierens durch.
http://forum.arduino.cc/index.php?topic=258332.0
http://forum.arduino.cc/index.php?topic=206317.msg1835859#msg1835859
#include "ClickButton.h"
#include <ModbusSlave.h>
// Nr. of buttons in the array
#define buttons 7
#define TASTER_ELTERN 22
#define TASTER_KIND1 24
#define TASTER_KIND2 26
#define TASTER_KIND3 28
#define TASTER_WC 30
#define TASTER_FLUR 32
#define TASTER_ABSTELLRAUM 34
#define LICHT_ELTERN 23
#define LICHT_KIND1 25
#define LICHT_KIND2 27
#define LICHT_KIND3 29
#define LICHT_WC 31
#define LICHT_FLUR 33
#define LICHT_ABSTELLRAUM 35
//const int inputPins[buttons] = {TASTER_ELTERN,TASTER_KIND1,TASTER_KIND2,TASTER_KIND3,TASTER_WC,TASTER_FLUR,TASTER_ABSTELLRAUM};// Arduino pins to the LEDs
const int ledPin[buttons] = {LICHT_ELTERN,LICHT_KIND1,LICHT_KIND2,LICHT_KIND3,LICHT_WC,LICHT_FLUR,LICHT_ABSTELLRAUM};// Arduino pins to the LEDs
int ledState[buttons] = { 0, 0, 0, 0, 0, 0, 0 };
int LEDfunction[buttons] = { 0, 0, 0, 0, 0, 0, 0 };
// Instantiate ClickButton objects in an array
ClickButton inputPin[7] = {
ClickButton (TASTER_ELTERN , LOW, CLICKBTN_PULLUP),
ClickButton (TASTER_KIND1 , LOW, CLICKBTN_PULLUP),
ClickButton (TASTER_KIND2 , LOW, CLICKBTN_PULLUP),
ClickButton (TASTER_KIND3 , LOW, CLICKBTN_PULLUP),
ClickButton (TASTER_WC , LOW, CLICKBTN_PULLUP),
ClickButton (TASTER_FLUR , LOW, CLICKBTN_PULLUP),
ClickButton (TASTER_ABSTELLRAUM , LOW, CLICKBTN_PULLUP),
};
/***************************************************
/ Modbus globals
/***************************************************/
#define PIN_MODBUS 2
#define MB_SLAVE_ID 3
#define MB_BAUDRATE 9600
#define MB_PARITY 'n'
ModbusSlave modbusSlave;
enum
{
BUS_LICHT_ELTERN,
BUS_LICHT_KIND1,
BUS_LICHT_KIND2,
BUS_LICHT_KIND3,
BUS_LICHT_WC,
BUS_LICHT_FLUR,
BUS_LICHT_ABSTELLRAUM,
MB_REGS // total number of registers on slave
};
int modbusRegisters[MB_REGS];
void setup()
{
for (int i=0; i<buttons; i++)
{
pinMode(ledPin[i],OUTPUT);
// Setup button timers (all in milliseconds / ms)
// (These are default if not set, but changeable for convenience)
inputPin[i].debounceTime = 20; // Debounce timer in ms
inputPin[i].multiclickTime = 250; // Time limit for multi clicks
inputPin[i].longClickTime = 1000; // Time until long clicks register
}
modbusSlave.configure(MB_SLAVE_ID, MB_BAUDRATE, MB_PARITY, PIN_MODBUS); // initialize modbus
for (int i=0; i<MB_REGS; i++){ modbusRegisters[i] = 0;} // set all modbus registers to 0
}
void loop()
{
modbusSlave.update(modbusRegisters, MB_REGS);
// Go through each button and set the corresponding LED function
for (int i=0; i<buttons; i++)
{
// Update state of all buitton
inputPin[i].Update();
// Save click codes in LEDfunction, as clicks counts are reset at next Update()
if (inputPin[i].clicks != 0) LEDfunction[i] = inputPin[i].clicks;
// Simply toggle LED on single clicks
// (Cant use LEDfunction like the others here,
// as it would toggle on and off all the time)
if(inputPin[i].clicks == 1) {
ledState[i] = !ledState[i];
modbusRegisters[i] = !modbusRegisters[i];
}
// blink faster if double clicked
if(LEDfunction[i] == 2) ledState[i] = (millis()/500)%2;
// blink even faster if triple clicked
if(LEDfunction[i] == 3) ledState[i] = (millis()/200)%2;
// slow blink (must hold down button. 1 second long blinks)
if(LEDfunction[i] == -1) ledState[i] = (millis()/1000)%2;
// slower blink (must hold down button. 2 second loong blinks)
if(LEDfunction[i] == -2) ledState[i] = (millis()/2000)%2;
// even slower blink (must hold down button. 3 second looong blinks)
if(LEDfunction[i] == -3) ledState[i] = (millis()/3000)%2;
}
for (int i=0; i<MB_REGS; i++){
ledState[i] = modbusRegisters[i];
}
// update the LEDs
for (int i=0; i<buttons; i++)
{
digitalWrite(ledPin[i],ledState[i]);
}
}
Achja... .nett dass du dich vorstellst, es muss sich aber hier keiner ein Namen machen.
Es sei denn du stellst es so wie HaWe an..... schwamm drüber.
PS: es soll SkorpiNULLACHT heißen, also dann einfach Skorpi 