Pages: [1]   Go Down
Author Topic: Arduino XM10 webcontrol  (Read 706 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello guy,

after i read and try to understand how to use all this stuff together i m here to ask for your help

i do have at home several appliance working with x10 protocol (marmitek) and decieded to upgrade with a web interface using arduino and the xm10 module

i tryed several libraries and managed to make the xm10 module working with simple sketch of X10 example like this

Code:
// include the X10 library files:
#include <x10.h>

const int rxPin = 3;    // data receive pin
const int txPin = 4;    // data transmit pin
const int zcPin = 2;    // zero crossing pin


void setup() {
  // begin serial:
  Serial.begin(9600);
  x10.begin(rxPin, txPin, zcPin);
  // Turn off all lights:
  x10.beginTransmission(A);
  x10.write(ALL_UNITS_OFF);
  x10.endTransmission();
}

void loop() {
  x10.beginTransmission(A);
  // Turn on first module:
  x10.write(UNIT_1);              
  x10.write(ON);  
  // Turn off second module:  
  x10.write(UNIT_2);            
  x10.write(OFF);
  delay(500);
  // Turn off first module:
  x10.write(UNIT_1);
  x10.write(OFF);
  // turn on second module:
  x10.write(UNIT_2);              
  x10.write(ON);
  delay(500);
  x10.endTransmission();
}

then i found in net some sketch to have an web interface with my arduino and try to send command trough a web page but witought big success i used 2 different library, the classic x10.h and x10ex.h
i don't have very good experience in programming and can t understand where is my mistake
for x10.h i used this kind of command line
Code:
x10.beginTransmission(A);
  x10.write(ALL_UNITS_OFF);
  x10.endTransmission();
and x10ex.h i used this
Code:
myHouse.write(HOUSE_P, UNIT_1, 3);
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

this is a part of the sketch i used for my webinterface

Code:
void WEBloop()
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          Serial.print(readString);
       if(readString.indexOf("L=1") > 0) {// lettura del valore se il LED si deve accendere
          // il led sarà acceso

         x10.sendCommand( A, ON);
         x10.beginTransmission(A);
         x10.write(UNIT_12);               
         x10.write(ON);
         x10.endTransmission();[/color]
          LEDON = true;
          Serial.print("ON pin ");
          Serial.println(outPin);
          }
         
          else
          {
          //il led sarà spento
          digitalWrite(outPin, LOW); //sengo il led
          LEDON = false;
          Serial.print("OFF pin ");
          Serial.println(outPin);
        }
     

Logged

Pages: [1]   Go Up
Jump to: