Show Posts
Pages: [1]
1  Using Arduino / Networking, Protocols, and Devices / Re: uploading sketch using ethernet on mega and ethernet shield on: July 04, 2013, 11:23:03 pm
I had been looking all over the Internet for a solution to the same dilemma. As I understand it, one must have an AVR ISP MkII programmer in order to burn any bootloader to the mega2560 because of its large memory. The UNO ISP sketch isn't able to address the extended memory of the 2560.

Is this correct?

I really do not want to spend the $30 that they cost (or whatever it is). Anyone in Phoenix have one I could barrow for, uhh, idk, 10 minutes?
2  Using Arduino / Programming Questions / Re: Cant use server.print. Cant figure out server.write- I'm a month deep- PLZ HELP on: April 28, 2012, 01:33:10 pm
Thank you very much!
3  Using Arduino / Programming Questions / Re: Cant use server.print. Cant figure out server.write- I'm a month deep- PLZ HELP on: April 28, 2012, 11:49:23 am
Wow, that easy... Thank you very much.

I haven't used the printf function either. In fact, until recently I didnt even know one coukd use C functions not shown on the Arduino site. I am...a noobie.

I'm assuming that goes in the loop, or because its a formatter and the variable is updated in the loop can I put it in setup and not have to run 3-5 (or more) of these every time 'round the loop?

Thanks!
Joey
4  Using Arduino / Programming Questions / Re: Cant use server.print. Cant figure out server.write- I'm a month deep- PLZ HELP on: April 28, 2012, 04:27:10 am
Oops, I thought I had mentioned that the dev said I need to use just one. I had been using multiple print statements in the very beginning when I was testing and only had one field that displayed (only one because I was just experimenting). It was supposed to stop reading data for a display and move on to the next when it go the new line terminator. So I was, of course, using print statements and making the last one println. Then things got crazy! If I had 3 fields, 1, 2, and 3 that should display A, B, and C respectively, I would get all sort of displays like: 1:C 2:A 3:BA then at the next refresh interval it might have been 1:AB 2:B 3:<blank>. If I happened to push a button one of the 3 may have displayed the default OK response.

Anyways, I found someone's page with a simple tutorial on sprintf. I still am going to have to read all weekend to figure it out. If someone knows of a good page/tutorial, or even a YouTube video, that would be really helpful. If someone knows it by heart and would quick click out the one I described above that would be great! (88 % where 88 is an analog input put into an int variable then mapped to between 0 and 100). I could draw off of that to figure the other few out.

Thanks guys!
Joey
5  Using Arduino / Programming Questions / Re: Cant use server.print. Cant figure out server.write- I'm a month deep- PLZ HELP on: April 27, 2012, 11:49:23 pm




Please forgive me further. These pain pills they've got me on have me feeling like a hippie at woodstock basking in the Sunshinesmiley-razz

I am new to Ardolino and programming as a whole for that matter so this is not coming to me very easily. My intoxicated state doesn't make things any easier. LOL. I've read that page a few times now and I'm just not quite getting it. Could I trouble you to give an example of how it would be implemented for my purposes. Providing you are proficient with the use of this function of course; I wouldn't ask anybody to sit and learn something just to make it easier for me to learn it.

If it helps at all, I'll be trying to do the same thing with a temperature. That is, formatting an analog read and then appending space F to the end.

Your help is very much appreciated. In my injured state I don't have much to do, so I'm using my time to work on my project. Almost makes it worth it, hardly. But it is nice to have time to work on my Arduino project.

Joey
6  Using Arduino / Programming Questions / Re: Email send question. on: April 27, 2012, 11:07:08 pm
READ ONE POST UP!
I don't know if it'll work with Hotmail. I tried to do the same thing using my Gmail account, until I found out that it won't work with Gmail. I wound up using the SMTP server, and thus the email account that my ISP gives me. Works perfect every time and hasn't failed on me once since I implemented it. In fact, my first sketch didn't have anything to stop it so before I could get to the Arduino to unplug it, my iPhone had close to 30 text messages. (I have the emails sent to my phone number @ my cellular provider so they come through as SMS messages.)
7  Using Arduino / Programming Questions / SOLVED - Can't use server.print. Can't figure out server.write- I'm a month deep on: April 27, 2012, 10:55:15 pm
Please bear with me, I've injured my wrist and I am dictating this post on my iPhone. If you see any typos please excuse them. This is also the reason why I didn't post my entire code, I don't think it's really relevant anyways.

So here is what's going on. I got this really cool app for my iPhone called Net IO. Among other things, it has fields that we'll send a user-defined string to the Arduino and display the response from the Ardolino. I was using print statements, but they would display random and garbled. After many weeks of pestering and bugging the developer, who is a very nice guy by the way, talking in to logging into my Ardolino and testing out my sketch. Should also mention that he didn't develop this app strictly for Arduino, it can communicate with a computer, an AVR board- whatever -anything that can receive strings and send responses. After he logged in, he asked me to upload an example sketch. I saw that it used a server.write function, so I tried that in my sketch. It actually worked, everything displayed where it should. However, it wasn't my entire sketch it was simply test strings within the write function. For example I had server.write(val). This works fine.... please keep reading.

My problem is this, I need to be able to take a variable such as one set equal to a mapped out analog reading, and write it followed by space and a percentage sign.

For example:
val = analogRead(A5);
lightper = map(val, 0, 1023, 0, 100);
server.write(????);

I was using server.print(lightper + " %") but unfortunately the app doesn't accept that. It's confusing and unfirtunately nothing that I can solve because I can't reprogram the iphone application.

I really don't see how the rest my code could be relevant but I'll post it later if anybody wants. It's just hard to do anything on the computer other than dictate because of my wrist.

Any thoughts? Thank you,
Joey
8  Topics / Home Automation and Networked Objects / Re: Anybody else have the iPhone app NetIO - A.K.A. NetIO Controller on: April 14, 2012, 02:16:57 am
Here is my sketch.  Had to remove all non-essential parts because its too long.
It wouldn't make the one part bold so I took that out.

Thanks again!

Code:
//------------------------------------------------------------------BEGINNING void setup()
void setup(){
    
  pinMode(ceilingLight, OUTPUT);
  pinMode(lamp, OUTPUT);
  pinMode(siren, OUTPUT);
  pinMode(toneSpeaker, OUTPUT);
    //PIN 4 RESERVED - SD Card - HOPE TO IMPLEMENT A FILE SERVER SOON!  :]
  pinMode(5, OUTPUT);
  pinMode(squareLED, OUTPUT);
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  pinMode(irLEDs, OUTPUT);
    // PINS 10, 11, 12, 13 RESERVED FOR ETHERNET SHIELD.  I know, I know...I should have typed <int ethernetShieldPins[5] = {10, 11, 12, 13;}> My first programming Joke. HA? Pfff, Nah. [:
  pinMode(pirSensor, INPUT);
  pinMode(15, INPUT);  //make analog later
  //pinMode(16, INPUT);
  //pinMode(17, INPUT);
  pinMode(18, INPUT);  //TEMPORARY, WILL BE ANALOG
  
  Ethernet.begin(mac, ip);
  iPhoneAppServer.begin();           // start the server
  Serial.begin(115200); //for debug
  }
//--------------------------------------------------------------------------------END void setup()


//--------------------------------------------------------------------------------BEGINNING void loop()
void loop()
{
  int index = 0;
  char Remote[BUFSIZ];    // Remote -> Buffer which holds string received from iPhone App or other client.
  EthernetClient client = iPhoneAppServer.available();
//Remainder of server code INCLUDING STRINGS Tx/Rx & ACTIONS COMMANDED are at the end of loop()

 
  if(SysStatus == armed)
  {
    if(digitalRead(18) == HIGH && PhCStatus == armed && PhCMsgSent == false)
    {
      smtp();
      PhCStatus = breached;
      PhCMsgSent = true;
      digitalWrite(siren, HIGH);
      delay(1500);
      digitalWrite(siren, LOW);
    }
    if(digitalRead(pirSensor) == HIGH && PIRStatus == armed && PIRMsgSent == false)
    {
      smtp();
      PIRStatus = breached;
      PIRMsgSent = true;
      digitalWrite(siren, HIGH);
      delay(1500);
      digitalWrite(siren, LOW);
    }
  }

//--------------------------------------------------------------BEGINNING of if(client)
  if (client) {
    if (client.connected()) {//--------------------BEGINNING of if(client.connected)
      while (client.available()) {
        char c = client.read();
        Serial.print(c);              // Print string data received from iPhone App to the serial monitor.
        if (c != '\n' && c != '\r'){    // This just means that the Arduino has not received a linefeed or a carriage return, so we have it keep reading the incoming string.
          Remote[index] = c;
          delay(3);
          index++;
          if (index >= BUFSIZ) index = BUFSIZ -1;
          continue;
      }
        Remote[index] = 0;
      }
      if (strstr(Remote, "NetIO Requesting Link")) {  // Initial send from App
        client.println("OK");
      }
//................ABOVE STRINGS ARE Tx/Rx OF INITIAL SEND.........................
//............BEG CORE OF SEND RECEIVE ACTIONS AND RESPONSES......................
//................NetIO requires response to all strings (or it may crash, dev->"3 second timeout")..........

//###########Home page of Net IO################
      if (strcmp (Remote, "PhC") == 0)
      {
        client.println(analogRead(A4));  //Change to <var name> when PhotoCell is hooked up, light measurements taken, and analogRead mapped to <var name>
      }else client.println("procreate Knows\n");
      if (strstr(Remote, "Temp"))
      {
        client.println("Farenheit 76.4");  //When temp sensor arrives, change to change to display temperature nice
      }

//###########Alarm page of Net IO###############
  //SYSTEM
      if (strstr(Remote, "SysStatus"))
      {
        if (SysStatus == disarmed) client.println("System is not Active");
        if (SysStatus == armed) client.println("System is Active");
        if (SysStatus == breached) client.println("BREACH");
      }
      if (strstr(Remote, "ToggleSys"))
      {
        client.println("OK");
        if (SysStatus == disarmed) SysStatus = armed;
        if (SysStatus == armed) SysStatus = disarmed;
        if (SysStatus == breached) SysStatus = disarmed;
      }
      if (strstr(Remote, "ResetSys"))
      {
        client.println("OK");
        PhCMsgSent = false;
        PIRMsgSent = false;
       // IRMsgSent = false;
      //  LNMsgSent = false;
        SysStatus = disarmed;
      }
  //PHOTOCELL
      if (strstr(Remote, "PhCStatus"))
      {
        if (PhCStatus == disarmed) client.println("Light detection is not Active");
        if (PhCStatus == armed) client.println("Light detection is Active");    // "(...)All Clear(...)" ???
        if (PhCStatus == breached) client.println("BREACH");
      }
      if (strstr(Remote, "TogglePhC"))
      {
        client.println("OK");
        if (PhCStatus == disarmed) PhCStatus = armed;
        if (PhCStatus == armed) PhCStatus = disarmed;
        if (PhCStatus == breached) PhCStatus = disarmed;
      }
      if (strstr(Remote, "ResetPhC"))
      {
        client.println("OK");
        PhCMsgSent = false;
        PhCStatus = disarmed;
      }
  //PASSIVE INFRARED
      if (strstr(Remote, "PIRStatus"))
      {
        if (PIRStatus == disarmed) client.println("Motion detection is Disarmed");
        if (PIRStatus == armed) client.println("Motion detection is Armed");    // "(...)All Clear(...)" ???
        if (PIRStatus == breached) client.println("BREACH: Motion has been detected");
      }
      if (strstr(Remote, "TogglePIR"))
      {
        client.println("OK");
        if (PIRStatus == disarmed) PIRStatus = armed;
        if (PIRStatus == armed) PIRStatus = disarmed;
        if (PIRStatus == breached) PIRStatus = disarmed;
      }
      if (strstr(Remote, "ResetPIR"))
      {
        client.println("OK");
        PIRMsgSent = false;
        PIRStatus = disarmed;
      }

//  DIGITAL WRITE COMMANDS BY PORT # FOR "LAB" PAGE.  [15 PORTS - 0 to 14 (Apr12,12)]
       if (strstr(Remote, "D0H")) {
        client.println("OK");
        digitalWrite(0, HIGH);
      }
       if (strstr(Remote, "D0L")) {
        client.println("OK");
        digitalWrite(0, LOW);
      }
      if (strstr(Remote, "D1H")) {
        client.println("OK");
        digitalWrite(1, HIGH);
      }
      if (strstr(Remote, "D1L")) {
        client.println("OK");
        digitalWrite(1, LOW);
      }
      if (strstr(Remote, "D2H")) {
        client.println("OK");
        digitalWrite(2, HIGH);
      }
      if (strstr(Remote, "D2L")) {
        client.println("OK");
        digitalWrite(2, LOW);
      }
      if (strstr(Remote, "D3H")) {
        client.println("OK");
        digitalWrite(3, HIGH);
      }
      if (strstr(Remote, "D3L")) {
        client.println("OK");
        digitalWrite(3, LOW);
      }
if (strstr(Remote, "D5H")) {
        client.println("OK");
        digitalWrite(5, HIGH);
      }
      if (strstr(Remote, "D5L")) {
        client.println("OK");
        digitalWrite(5, LOW);
      }
      if (strstr(Remote, "D6H")) {
        client.println("OK");
        digitalWrite(6, HIGH);
      }
      if (strstr(Remote, "D6L")) {
        client.println("OK");
        digitalWrite(6, LOW);
      }
      if (strstr(Remote, "D7H")) {
        client.println("OK");
        digitalWrite(7, HIGH);
      }
      if (strstr(Remote, "D7L")) {
        client.println("OK");
        digitalWrite(7, LOW);
      }
      if (strstr(Remote, "D8H")) {
        client.println("OK");
        digitalWrite(8, HIGH);
      }
       if (strstr(Remote, "D8L")) {
        client.println("OK");
        digitalWrite(8, LOW);
      }
       if (strcmp (Remote, "D9H") == 0) {
        client.println("OK");
        digitalWrite(9, HIGH);
      }
       if (strstr(Remote, "D9L")) {
        client.println("OK");
        digitalWrite(9, LOW);
      }
      if (strstr(Remote, "D14H")) {
        client.println("OK");
        digitalWrite(14, HIGH);
      }
      if (strstr(Remote, "D14L")) {
        client.println("OK");
        digitalWrite(14, LOW);
      }
    } //-------------------------------------------END of if(client.connected)
  } //--------------------------------------------------------- END of if(client)
} //-----------------------------------------------------------------------------END of void loop()



//@@@@@@@@@@@@@@@@@@@@ BEG of emailFunction() @@@@@@@@@@@@@@@@@@@@@@
/*removed this because it was full of my personal info and I'm too tired to edit it line by line*/
}
//@@@@@@@@@@@@@@@@@@@@ END of emailFunction() @@@@@@@@@@@@@@@@@@@@@@


//  END OF SKETCH
//  fin
//  the end
//  go home
//  ok, you can stay
//  no need to cry
//  I said stop crying
//  want a lollie?
//  ok, here's a lollie  (*thought=what, am I british now?)  {*thought=syntax error. expected '{' token after you gave me a lollie}
//  note to self...staying up all night coding is bad for one's psyche
//  at least I spelled psyche correctly, I checked

9  Topics / Home Automation and Networked Objects / Anybody else have the iPhone app NetIO - A.K.A. NetIO Controller on: April 14, 2012, 02:14:36 am
I really like this application. My problem is that it works with AVR boards too, and the dev doesn't even do Arduino. I managed to take an Ard example from another user that he posted on his site and adapt it to Arduino 1.0. I was pretty stoked considering that was my second sketch ever...the first was Blink.

My project is nearing completion. I really need some help though. I have emailed back and forth with the developer for quite a while now, but because he doesn't know Arduino he can't just look at my sketch.

Two customizable attributes to the buttons and labels are called sends and reads. Sends sends a string that you can program the sketch to react to.  The app requires a simple response, any will do. Reads also sends a strings, but it displays the response on a button or label.

The reads attributes in my JSON config file (thats the file you setup to design the app layout and the strings you want to send and such) display randomly.  What I mean by that is the responses end up in the wrong places.  For a very basic (cuz I could write a book explaining all the details I have gone through here) example - 2 labels. Both with refresh intervals of 500 milliseconds (does not matter if they are different, probelm still occurs).  Reads attributes = Temp - PhotoCell. First should receive a temperature like 76F.  Second should receive a number with a percentage symbol like 44%. Open the app and see = 44% & 76F.  Next refresh = 76F & 44%.  Next = 44% & 44%. Next = 44% & 76F.  Next = [blank] & 44%. Next = 76F & OK. And so on.  The OK is what I have for the response for all the strings that don't display the response, like D9H (digital 9 high, this is all configurable by the user).  The OK shows if you tap a button near enough to the interval (refresh) of the reads attributes.  So basically the responses go where ever the funk they want, if they even show up to class that day [blank].  /:

I know that my json config is good because the developer has gone over it with a fine tooth comb.  A little insight into it, my sketch, and I'm gonna sit back and pray all you fellas can help me out here.  I'm about to pull my hair out...I got my Mother's hairline (thank God) so no sense in getting a discount at the barber like my Father does.  He he he [:

The app automatically appends a newline (\n I think, I'm new to this) to every type of string it sends.  It apparently waits for a response before moving on and can place in its cue up to 30 strings.  I went reound and round with the dev insisting that was not working properly.  It seems logical considering how the responses jump all around the screen(s)/page(s) in the app.  I also tried to blame it on the following characteristic.  Same thing the other way.  It requires a newline thing at the end, but the developer tells me that using client.println() is adequate because it automatically appends the string with just such a separator (lingo may be inaccurate, I'm a noob).  So the problem must be in my sketch.

I went ahead and put the code that I think is relevant in bold.  There are a ton of comments in here that are for my own personal use. There also may be code in there that require some other code...I'm not done yet.  I am a total noob guys.  This is my second sketch, please be gentle with me...I'm sensitive!  smiley-eek-blue I'm kidding, but just that last part.  I enthusiastically welcome constructive criticism...so long as its constructive.

Thanks for your time,
Joey
10  Using Arduino / Programming Questions / Re: Sending message text to an email function. [Probably same for SMS] on: April 07, 2012, 07:29:59 pm
void textMsgPushNotif()//int MsgContent)
  {
    const int waiting = 50;
   
    if(mailClient.connect(mailServer, 25))
      {
      mailClient.println("HELO x@x.xyx");//Say hello.
      delay(waiting); //Wait for a response.
      mailClient.println("MAIL From: x@x.xyx"); //Identify sender.
      delay(waiting);
      mailClient.println("RCPT To: 5555555555@messaging.CellularSP.com");//Identify recipient.
      mailClient.println("DATA");
      delay(waiting);
      mailClient.println("Subject: System has been triggered by some shady bizness."); // Insert subject here.
      mailClient.println("FROM: x@x.xyx");//Sender's address, again.
      mailClient.println("TO: 5555555555@messaging.CellularSP.com");//Recipient's address, again.
      mailClient.println("I wish this whole line was something like: mailClient.println(msgBody); - Same for subject line: ...ntln(msgSubject);"); //Insert body of the email.
      mailClient.println("."); // end message
      mailClient.println("QUIT"); // terminate connection
      delay(waiting);
      mailClient.println();
      mailClient.stop();
      return; //??? Not sure if this is needed
  }
}

Is the last line containing "return;" even required?
11  Using Arduino / Programming Questions / Re: Sending message text to an email function. [Probably same for SMS] on: April 07, 2012, 12:51:59 am
Shoot. I'll give it a shot. I've always been far too loquacious for my own good.

How does one pass text (as in a sentence or two, like I'm attempting to ask my question using) to a function? I have an emailing function which works perfectly. The problem is it only sends the email subject and body that I have permanently typed into the function. I'm looking for more dynamic function.

For example, I'd like to be able to have my sketch call up the email function like this:

If (x == true) {
  sendEmail("x is true.", "Take my word for it bro, the rabbit hole is pretty deep!");
}

instead of just:

if...(){
 sendEmail();
}

Where the first string is the subject of the email and the second string is the body. These can of course be variables that I define elsewhere. ie msgSubject1 and msgBody1 and so on. I've no idea how to do this.

Currently all I can do (I think it would work) is have an integer variable passed to the function and include if statements in the function. If var = 1 {then relist the code for sending the email over and over with different message text for each variable value I define; portion or all if the SMTP makes me.}

That's quite a waste of space. I'm sure this is possible. Am I being unclear at all? Please tell me if that isn't understandable.

Thanks fellas!
Joey

Oh yea, so it turns out I can't has to question just a couple sentences.
12  Using Arduino / Programming Questions / Sending message text to an email function. [Probably same for SMS] on: April 06, 2012, 12:18:50 pm
{I previewed this message and saw how long it was. OMG! It's Siri's fault. She's just such a good secretary. I start dictating and before I realize it we've written a book! Sorry. She keeps up really well. smiley-wink

Hey fellas,

I'm pretty new to Arduino (got it and Ethernet Shield a couple months ago) and I am 99% new to programming. My first program is a socket server to send and receive strings to/from an iPhone app called Net IO. (I'll take this opportunity to say that it is simply an amazing app. It is 100% customizable and well worth the $8 or $10. It even supports multiple simultaneous connections. The creator is very nice and helpful too.) None of this has anything to do with the question I am about to ask, but I wanted to throw that in just so that you get a grasp on the fact that I am new to Ardolino, but while I'm not the sharpest tool in the shed, I'm sharpened with the same stone...if that makes sense.

So aside from that and the SD card File Server I plan to add to it next, it includes a function for sending an email which I have addressed to my phone number @ my cellular carrier .com so that I get text messages triggered by events as notifications. Currently I only have worked out how I want it to work with the Alarm elements of myHone Automation, but will add others such as temperature later on.

I want to be able to change the subject and body of the email/text based on which event I'm being notified about. For example: "Breach at front door" or "Alarm triggered-zone 1". (I'll figure out times stamping once it's up and running. Every little thing I do I have to read and read to teach myself how to make it happen!)

Currently the only way that I think I could do it with my current knowledge-scratch that, call it basic understanding-is to pass the function a variable when it is called by the if statement that is checking the alarm state for a breach. Then within the email function, have if statements (or maybe a switch case?) that instruct the Arduino to send different text to the SMTP server depending on which value of the variable the function is given.

I have been trying to understand strings and I just can't figure them out. I barrowed roughly 15-20 lines of code from an example sketch so that's how I got my server to send/receive strings when I don't know how to code for them smiley-wink Gotta love open source! Really, I think this community of DIY'rs and Techies is great! Anyways, I don't even understand how to send that email function a feasible word as the variable that tells it which message to send. I'd have to use integers and just remember that the PIR needs message 2 sent when triggered, or whatever number I gave it. I would really like to be able to leave my email function pretty much as it is, and simply give it the message body and subject that I want it to use.

I'm at work on my iPhone, or else I could include my sketch. I can post it a little later if necessary. My question is probably quite simple (at least to those out there that know how) and I'm guessing only requires a little bit of code, so I figured that you guys could provide an answer without having to see my sketch. Upon its completion, I do plan on posting it for everybody to use should they do desire. Right now it is incomplete, messy, and needs to be commented out.

Thanks so much for you help fellas, and ladies (;
Hey, my first post!
Joey
Pages: [1]