Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: New network setup, same program, now won't work on: March 16, 2013, 01:50:00 pm
I hooked my laptop up to the switch that lies between the wireless router and the project.  I was not able to have connectivity with the laptop.  Looking at this now, and how the wireless router is designed, I would have to have an extra cable between the wireless router ports and the switch which I do not have.

Instead I took the time to move the project and plug it into the wireless router, works now.

Otherwise, yes, I have had issues running out of memory, and have not tried F() yet.  Just today, I noticed it got very buggy or totally non-responsive to webpage input if I added my field for "Indoor Temperate:  somefloat".  I will work with the F() functionality and see if that helps me.

If I want a 'larger' or 'nicer' webpage to interface with, should I consider going to the SDcard based webserver or something else altogether?

I feel I'm already at the end of the rope here with just a few radio buttons.

Will the F() functionality save me a ton of memory?

I want the webpage to have:
-20 radio buttons
-about 5 float pt number displays
-several user text and float input fields

Also, when viewing html tutorials I notice the syntax here is very different.  What gives with the vast amount of quotes " " and \/ forward or backslashes present in the arduino client.print commands? 

2  Using Arduino / Programming Questions / New network setup, same program, now won't work on: March 09, 2013, 03:17:43 pm
I have either a memory or network settings issue.  

This code worked fine on these network settings at let's say location "A":
ip:  10.0.202.75
subnet:  255.255.252.0
gateway:  10.0.200.1

location "B" is simply a different network of which I also know and control the gateway, now it is just
ip:  192.168.1.
subnet:  255.255.255.0
gateway:  192.168.1.1

Now it won't work.  It has worked at location "B" before, however I had to give back the long ethernet cable I was using to connect to my wireless router.  In location "B" I now connect to the switch with a shorter cable versus direct to the wireless router.  Cable works otherwise (tried with laptop).

The other difference is I had to migrate my IDE to a new laptop and migrate over my program library files.  That must have worked because it doesn't moan at me about compile errors for the custom X10 library stuff (or any other commands).

Since it worked with no changes other than network setup and this laptop, I'm inclined to believe it has to do with it being hooked up to the switch versus directly to the wireless router.

The only other hint I have seen searching online is that the program might be too large for the Uno R3 memory.  It says it sits at 17.5kb out of like 34kb available.  Which seems fine, but also seems large one way or another.

I hope somebody can find a stray character or something.  Code is below.

Code:
/*
  Web Server
 */

#include <SPI.h>
#include <Ethernet.h>
#include <X10Firecracker.h>
#define RTS_PIN     2                   // RTS line for C17A - DB9 pin 7
#define DTR_PIN     3                   // DTR line for C17A - DB9 pin 4
#define BIT_DELAY   1                   // mS delay between bits (1 mS OK)

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x7B, 0xD4 };
IPAddress ip(192,168,1,75);
byte gateway[] = {192,168,1,1};
byte subnet[] = {255,255,255,0};
byte fireplace = 0;
int indoortempraw = 0;
float indoortempval = 0;
char indoortempvalstr;
int outputpin7 = 7;
int outputpin6 = 6;
int outputpin5 = 5;
int outputpin4 = 4;
byte heaton = 0;
byte acon = 0;
float tempstpt = 0;


// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup()
{
  X10.init(RTS_PIN, DTR_PIN, BIT_DELAY);  //
  Serial.begin(9600);    //  open up serial port connection to PC
  // start the Ethernet connection and the server:
  Ethernet.begin(mac,ip,gateway,subnet);
  server.begin();
  digitalWrite(outputpin7,HIGH);
  digitalWrite(outputpin6,HIGH);
  digitalWrite(outputpin5,HIGH);
  digitalWrite(outputpin4,HIGH);
  pinMode(outputpin7, OUTPUT);
  pinMode(outputpin6, OUTPUT);
  pinMode(outputpin5, OUTPUT);
  pinMode(outputpin4, OUTPUT);
  }
void loop()
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    String buffer = "";  //  Declare the buffer variable

    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.print(c);  //  Send every character read to serial port
        buffer+=c;        //  Assign to the buffer

        // 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
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<body background=\"http://i111.photobucket.com/albums/n130/sflemon/ClearBlueBackground.jpg\">");
          client.println("<font color=white><h1 align=center>8204 Shadowstone Ct. Home Command Page</font></h1>");
          client.println("<hr />");
          client.println("<hr />");

          if (digitalRead(8)){  //  1<-- Display LED status
            client.println("<img src=\"http://i111.photobucket.com/albums/n130/sflemon/indicator-green_zps8552e624.png\" width=20 height=20 />");
          }else{
            client.println("<img src=\"http://i111.photobucket.com/albums/n130/sflemon/indicator-red_zps75caf320.png\" width=20 height=20 />");
          }
          client.println("<br />");
    
          // 2<-- Create a form, control output 8
          client.print("<FORM action=\"http://192.168.1.75/\" >");
          client.print("<P> <div align=left><INPUT type=\"radio\" name=\"status\" value=\"1\">ON" "<INPUT type=\"radio\" name=\"status\" value=\"0\">OFF" "<INPUT type=\"submit\" value=\"  Yellow LED \"></div>" "</FORM>");
          
          if (fireplace==1){  //  1<-- Display LED status
            client.println("<img src=\"http://i111.photobucket.com/albums/n130/sflemon/indicator-green_zps8552e624.png\" width=20 height=20 />");
          }else{
            client.println("<img src=\"http://i111.photobucket.com/albums/n130/sflemon/indicator-red_zps75caf320.png\" width=20 height=20 />");
          }
          client.println("<br />");
          
          // 2<-- Create a form, control output 7
          client.print("<FORM action=\"http://192.168.1.75/\" >");
          client.print("<P> <div align=left><INPUT type=\"radio\" name=\"status2\" value=\"1\">ON" "<INPUT type=\"radio\" name=\"status2\" value=\"0\">OFF" "<INPUT type=\"submit\" value=\"  Red LED \"></div>" "</FORM>");
          client.println("<br />");
          //client.println("Indoor Temperature: ");
          //client.println(indoortempval,4);
          client.println("<br />");
          client.println("<P> <div align=left><img src=\"http://wwwcache.wral.com/asset/weather/doppler5000/2006/08/07/1001059/ice_2011_dd5k_wake-640x480.jpg\" width=480 height=360 />" "<img src=\"http://wwwcache.wral.com/asset/weather/2008/04/22/2774561/ice_2011_forecast_7day_wral_raleigh-600x450.jpg\" width=480 height=360 />");
          client.println("<br />");
          
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
          buffer="";       //  Clear the buffer at end of line
        } else if (c == '\r') {            
          if(buffer.indexOf("GET /?status=1")>=0)
            digitalWrite(8,HIGH);  // Catch ON status and set  Yellow LED
          
          if(buffer.indexOf("GET /?status=0")>=0)
            digitalWrite(8,LOW);  // Catch OFF status and set Yellow LED
            
           if(buffer.indexOf("GET /?status2=1")>=0){
          X10.sendCmd( hcA, 2, cmdOn );
          fireplace=1;
           }
    
          if(buffer.indexOf("GET /?status2=0")>=0){
          X10.sendCmd( hcA, 2, cmdOff );
         fireplace=0;
          }
            
          indoortempraw = analogRead(A0);
          indoortempval = (float(indoortempraw)/1023.0*257.0);
          if(indoortempval>(tempstpt+3)){
            acon = 1;
          }
          if(indoortempval<(tempstpt-3)){
            heaton = 1;
          }
          if(acon == 1){
            digitalWrite(outputpin7,LOW);
            digitalWrite(outputpin6,LOW);
          }
          if(heaton == 1){
            digitalWrite(outputpin7,LOW);
            digitalWrite(outputpin5,LOW);
          }
        }
        else {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    
  }
}
3  Topics / Home Automation and Networked Objects / Re: X10, html code not playing nice on: January 15, 2013, 08:53:20 am
That probably will work, once the right hardware arrives in the mail.   smiley-evil

I have a CM11A, their computer interface.  DOH!  Researching online, it doesn't work with the libraries for the TW523 and PSC05 stuff.  They don't sell those two new any-longer (or are scalped really expensive) so I bought two of the rf transceivers to work with the CM17 thingie I have.

I have the cm17, just not the transceivers.

So, root cause is incorrect hardware.
4  Topics / Home Automation and Networked Objects / Re: X10, html code not playing nice on: January 14, 2013, 12:37:33 pm
Alright, back to basics..........I went here:  http://www.arduino.cc/en/Tutorial/X10

I downloaded and placed the libraries in that tutorial in the appropriate places and all compiles fine.  I have the same issue others had with the sketch getting to print in the serial monitor:  lights on and never does anything else.

I have a CM11A.  Pin 1 is yellow, Pin 2 is green, Pin 3 is red, Pin 4 is black.  I have it hooked up as in the tutorial. It's not getting past that in the program.  The library I used from the tutorial doesn't have a .O file to delete like some of the other forum topic on this issue.  I thought Hogan stated that that tutorial DOES work with that library if wired correctly.

Not sure what I'm doing wrong.  I also tried a few other libraries and examples and none worked.

I tried Hogan's library link on the transmit AND receive he did, but #include <x10constants.h> has a compile error.  At this point I would like somebody to essentially point me to EXACTLY the library, example program, and wires for a CM11A.

I have this one hooked up as others say they have, and no dice.

 I am using the blink example sketch in the folder with those library files:

Code:
/*
  X10 blink
 
 Blinks an lamp on an X10 lamp module.  
 Example was built using a PL513
 X10 One-Way Interface Module from http://www.smarthome.com
 as the modem, and a Powerhouse X10 Lamp Module from Smarthome
 to plug the lamp in.
 
 created 15 June 2007
 modified 6 May 2011
 by Tom Igoe
 
 */
#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() {
  // initialize serial and X10:
  Serial.begin(9600);
  x10.begin(rxPin, txPin, zcPin);
}

void loop() {
  // open transmission to house code A:
  x10.beginTransmission(A);
  Serial.println("Lights on:");
  // send a "lights on" command:
  x10.write(ON);

  delay(5000);
  Serial.println("Lights off:");
  // send a "lights off" command:
  x10.write(OFF);
  x10.endTransmission();
  delay(5000);
}


Moderator edit: [code] [/code] tags added.
5  Topics / Home Automation and Networked Objects / X10, html code not playing nice on: January 11, 2013, 04:50:22 pm
Uno with e-net shield.  Works fine with html page turning on and off the one LED you see in the code.  I altered the code to include the X10 code examples.  Color of wires from RJ11 plug are commented in the code to help any troubleshooting.  Using an X10 CM11A 2-way controller.

Issue:  I can't get to the point of troubleshooting the actual x10 stuff because something isn't playing nice in the html code at the bottom where I call the X10 commands.  With X10 commands at the bottom lines of code, I can turn on and off my one original LED on the html page UNTIL I try to turn on the other button now linked to the X10 command.  If I comment out the if(.... statements with the X10 code after it at the bottom, html plays nice and original LED works.  So something isn't working down there.

After trying the button linked to X10 commands, webpage also will crash.  

Help is appreciated, I edit "working" code from others and include it to do what I want, I don't have a lot of html or C++ experience.

Code:
Code:
/*
  Web Server
 
 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield.
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)
 
 created 18 Dec 2009
 by David A. Mellis
 modified 4 Sep 2010
 by Tom Igoe
 
 */

#include <SPI.h>
#include <Ethernet.h>
#include <x10.h>

const int rxPin = 3;    // data receive pin,green
const int txPin = 4;    // data transmit pin,yellow
const int zcPin = 2;    // zero crossing pin,black
byte CODE1;

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x7B, 0xD4 };
IPAddress ip(10,0,202, 75);
byte gateway[] = {10,0,200,1};
byte subnet[] = {255,255,252,0};



// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup()
{
  Serial.begin(9600);    //  open up serial port connection to PC
  pinMode(8, OUTPUT);    //  Set digital pin 8 as output
  pinMode(7, OUTPUT);    //  Set digital pin 7 as output
  digitalWrite(zcPin, HIGH);
  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip,gateway,subnet);
  server.begin();
  x10.begin(rxPin, txPin, zcPin);
}

void loop()
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    String buffer = "";  //  Declare the buffer variable

    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.print(c);  //  Send every character read to serial port
        buffer+=c;        //  Assign to the buffer

        // 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
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<body background=\"http://i111.photobucket.com/albums/n130/sflemon/ClearBlueBackground.jpg\">");
          client.println("<font color=white><h1 align=center>8204 Shadowstone Ct. Home Command Page</font></h1>");
          client.println("<hr />");
          client.println("<hr />");

          if (digitalRead(8)){  //  1<-- Display LED status
            client.println("<img src=\"http://i111.photobucket.com/albums/n130/sflemon/indicator-green_zps8552e624.png\" width=20 height=20 />");
          }else{
            client.println("<img src=\"http://i111.photobucket.com/albums/n130/sflemon/indicator-red_zps75caf320.png\" width=20 height=20 />");
          }
          client.println("<br />");
          
          // 2<-- Create a form, control output 8
          client.print("<FORM action=\"http://10.0.202.75/\" >");
          client.print("<P> <div align=left><INPUT type=\"radio\" name=\"status\" value=\"1\">ON" "<INPUT type=\"radio\" name=\"status\" value=\"0\">OFF" "<INPUT type=\"submit\" value=\"  Yellow LED \"></div>" "</FORM>");
          
          if (digitalRead(7)){  //  1<-- Display LED status
            client.println("<img src=\"http://i111.photobucket.com/albums/n130/sflemon/indicator-green_zps8552e624.png\" width=20 height=20 />");
          }else{
            client.println("<img src=\"http://i111.photobucket.com/albums/n130/sflemon/indicator-red_zps75caf320.png\" width=20 height=20 />");
          }
          client.println("<br />");
          
          // 2<-- Create a form, control output 7
          client.print("<FORM action=\"http://10.0.202.75/\" >");
          client.print("<P> <div align=left><INPUT type=\"radio\" name=\"status2\" value=\"1\">ON" "<INPUT type=\"radio\" name=\"status2\" value=\"0\">OFF" "<INPUT type=\"submit\" value=\"  Red LED \"></div>" "</FORM>");
          client.println("<br />");
          client.println("<P> <div align=left><img src=\"http://wwwcache.wral.com/asset/weather/doppler5000/2006/08/07/1001059/ice_2011_dd5k_wake-640x480.jpg\" width=480 height=360 />" "<img src=\"http://wwwcache.wral.com/asset/weather/2008/04/22/2774561/ice_2011_forecast_7day_wral_raleigh-600x450.jpg\" width=480 height=360 />");
          client.println("<br />");
          
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
          buffer="";       //  Clear the buffer at end of line
        } else if (c == '\r') {            
          if(buffer.indexOf("GET /?status=1")>=0)
            digitalWrite(8,HIGH);  // Catch ON status and set  Yellow LED
          
          if(buffer.indexOf("GET /?status=0")>=0)
            digitalWrite(8,LOW);  // Catch OFF status and set Yellow LED
            
           if(buffer.indexOf("GET /?status2=1")>=0)
           x10.beginTransmission(HOUSE_A);
           x10.write(UNIT_1);
           x10.write(ON);
           x10.endTransmission();
            
    
          if(buffer.indexOf("GET /?status2=0")>=0)
          x10.beginTransmission(HOUSE_A);
           x10.write(UNIT_1);
           x10.write(OFF);
           x10.endTransmission();
        }
        else {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(2);
    // close the connection:
    client.stop();
    
  }
}


Moderator edit: [code] [/code] tags added.
Pages: [1]