Show Posts
Pages: [1] 2
1  Using Arduino / General Electronics / Re: Voltage Divider Help on: May 16, 2013, 04:15:42 pm
DVDdoug!

Thanks, this was very helpful!
2  Using Arduino / General Electronics / Re: Voltage Divider Help on: May 16, 2013, 11:08:52 am
Good to know.... I actually ordered one yesterday when i couldn't figure this out.

I appreciate your help.
3  Using Arduino / General Electronics / Voltage Divider Help on: May 16, 2013, 10:50:27 am
I created a simple voltage divider to step down my cars 12V to 8.5ish.  I used a 150 ohm resister and a 330 ohm resistor.

When i feed 12V into it as expected i get about 8.5V between the two resistors. However When i plug it into my arduino with a SIM900 GSM Shield attached it doesn't supply enough power and the voltage drops to around 5V's.

I am assuming this has to do with Current... The Arduino with GSM/cell shield attached draws around 2 amps (not constant, but during start up or cell activity).

What am I missing/ not understanding?

Any guidance is appreciated.

-Brian

Cell Sheild Link: www.elecfreaks.com/3080.html
Using: Arduino Uno V3
4  Using Arduino / Motors, Mechanics, and Power / Device to hold and release Mouse Trap. on: February 12, 2013, 04:42:25 pm
I know this is a rather odd request, but can anyone thing of a device that could hold the bar (connected to the spring) of a mouse trap open and then release it per servo or some other means with the arduino.


Any idea's welcome.

Brian
5  Using Arduino / Programming Questions / Re: Reading html data only, storing as String on: February 10, 2013, 06:33:05 pm
Let's say you are able to get it into a string like "68.00, 1, 0, 1, 1, 66.00, 0, 0, 5, 23, 20, 0".  What are you going to do with it then?

Eventually have the arduino at as a server where i could query it for these settings.

This string would be converted into an array.
6  Using Arduino / Programming Questions / Re: Reading html data only, storing as String on: February 10, 2013, 03:08:53 pm
For such a simple parsing requirement I'd just process the input stream one character at a time, looking for the opening brace ('{').

Once found, process each subsequent character, probably in a switch statement:

Not sure how to do this... not even sure where to begin looking.  here is how i think it might look (OBVIOUSLY WAY WRONG AS IT DOESN'T EVEN COMPILE).

Sorry for my ignorance, i'm trying folks.

Code:
void loop()
{
 
char start = "{";
 
 if (client) {
    while (client.connected()) {
      if (client.available()) {
       
            if (client.read() == start);
            {
              char c = client.read()
              readString += c;
            }
        }   
    }
}
 
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
;
  }
}
7  Using Arduino / Programming Questions / Re: Reading html data only, storing as String on: February 10, 2013, 11:45:02 am
Thanks for your replies. Obviously I am a extreme newbie, not just with arduino but with programming anything. In fact today marks my 2 week anniversary  since I wrote my first "hello world" so you'll have to forgive my "stupid" decisions when it comes to efficiency. To me, getting the arduino to do something I want, efficient or not, is a big victory for me.

Quote
Is that data from an external page or one you generate yourself?

The web page is generated from my thermostat and I don't have any means of altering it. As far as i can tell the website is very simple, i don't think it even contains HTML as the source page looks identical to the page i see in the browser which contains only this:

{"temp":66.00,"tmode":1,"fmode":0,"override":1,"hold":1,"t_heat":66.00,"tstate":0,"fstate":0,"time":{"day":6,"hour":9,"minute":29},"t_type_post":0}

Quote
Why not read each character 'c' and compare to the start of what you are looking for. Once you find that charter the. Start to store in the string until you reach the last character, at which point stop adding the read bytes to the string.

This sounds like a great idea, I just don't know where to begin. Could you perhaps provide an example? or point me in the right direction.

Quote
How many times is this loop going to iterate? For loops that explicitly iterate once are pretty stupid, in my opinion.

 PaulS, ironically I spent a good 20 mins learning the "for" loop (so i didn't look dumb posting code that looped my client.read() over and over) thinking it was a great solution to having my Serial.print print only once. I guess avoiding looking stupid backfired.

I'm all ears on learning new and better ways of doing things.


8  Using Arduino / Programming Questions / Re: Simple HTTP POST to Wifi Thermostat. HELP NEEDED on: February 10, 2013, 02:30:36 am
Thank you everyone for your help. Finally working now....

In the interest of someone else stumbling onto this question, here is my working code:


Code:
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(192,168,1,101); // Thermostats IP
EthernetClient client;

int temp = 64;

void setup()
{
 Ethernet.begin(mac);
  Serial.begin(9600);

  delay(2500);
  Serial.println("connecting...");

  if (client.connect(server, 80))
  {
    Serial.println("connected");
    delay(2500);
    client.println("POST /tstat/remote_temp HTTP/1.1");
    client.println("Content-length: 15");
    client.println("Connection: Close");
    client.println();
    client.print("\"rem_temp\":");     //Set Remote temperture to ___
    client.print(temp);
    client.println("}");
  }
    else
    {
    Serial.println("connection failed");
    }
}
void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c); 
  }
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
;
  }
}
9  Using Arduino / Programming Questions / Reading html data only, storing as String on: February 10, 2013, 02:23:13 am
This forum has been great at responding to question and I have yet another.

I not sure how to efficiently get the data I want using client.read() from a local webpage using a GET request

When i get the Data and view it over serial I get the following.


HTTP/1.1 200 OK
Server: Marvell 8688WM
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Pragma: no-cache

94
{"temp":68.00,"tmode":1,"fmode":0,"override":1,"hold":1,"t_heat":66.00,"tstate":0,"fstate":0,"time":{"day":5,"hour":23,"minute":20},"t_type_post":0}
0



I am only interested in the info after /n,  between "94"  &  "0".  More specific I really only need the int's from that section. as long as their in order I would know which was which.

So from the about html responce I would love to get it into a String variable like this:

68.00, 1, 0, 1, 1, 66.00, 0, 0, 5, 23, 20, 0

I did find some examples of client.read(), however it takes a minute or more to finish reading the values this way. Here is my test code:


Code:
void loop()
{
  
 if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        readString += c;
        }  
    }
}
 
 if (count < 3){
    for (int i=1; i < 2; i++)  {
      Serial.print(readString);
      client.stop();
    }
    count = 4;
  }
}

Is their a better, faster, more efficient way of targeting this data?
10  Using Arduino / Programming Questions / Re: Simple HTTP POST to Wifi Thermostat. HELP NEEDED on: February 08, 2013, 01:29:53 am
My mistake, the braces didn't effect it was just putting it after the "

I can connect to the page i need to post to with a GET using the following code:

Code:
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(192,168,1,101); // Thermostats IP
EthernetClient client;

void setup()
{
 Ethernet.begin(mac);
  Serial.begin(9600);

  delay(1000);
  Serial.println("connecting...");

  if (client.connect(server, 80)) {
    Serial.println("connected");
 
    delay(1000);
    client.println("GET /tstat/remote_temp HTTP/1.1");
    client.println();
    //client.println("{\"rem_temp\":62}");

  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {


    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
;
  }


}

Which gives the the expected return over the serial monitor of:

Code:
connecting...
connected
HTTP/1.1 200 OK
Server: Marvell 8688WM
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Pragma: no-cache

e
{"rem_mode":0}
0

When I try and change it to a POST with the following code:

Code:
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(192,168,1,101); // Thermostats IP
EthernetClient client;

void setup()
{
 Ethernet.begin(mac);
  Serial.begin(9600);

  delay(1000);
  Serial.println("connecting...");

  if (client.connect(server, 80)) {
    Serial.println("connected");
 
    delay(1000);
    client.println("POST /tstat/remote_temp HTTP/1.1");
    client.println();
    client.println("{\"rem_temp\":62}");

  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {


    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
;
  }


}

I Get This Response:

Code:
connected
HTTP/1.1 200 OK
Server: Marvell 8688WM
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Pragma: no-cache

HTTP/1.1 500 Internal Server Error
Server: Marvell 8688WM
Connection: close
Transfer-Encoding: chunked
Content-Type: text/plain

13
wsgi handler failed
0

HTTP/1.1 404 Not Found
Server: Marvell 8688WM
Connection: close
Transfer-Encoding: chunked
Content-Type: application/octet-stream

181
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><title>Wireless Thermostat - 404</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
Whoops!  This page doesn't exist.  You probably meant to go to <a href="home.shtml">the main page.</a>
</body>
</html>

0


Not sure what i'm doing wrong....

11  Using Arduino / Programming Questions / Re: Simple HTTP POST to Wifi Thermostat. HELP NEEDED on: February 08, 2013, 01:00:39 am
Thank for the quick reply.

That took care of putting quotes inside of my data but didn't work for the { } symbol's (braces I believe is what there called).


Any tricks for including these inside of my client.println(" "); ?
12  Using Arduino / Programming Questions / Re: Simple HTTP POST to Wifi Thermostat. HELP NEEDED on: February 08, 2013, 12:05:32 am
SUCCESS!!  Well partially anyway.

I was able to get a response from the thermostat with a GET request. here is the code that worked.

Code:
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(192,168,1,101); // Thermostats IP
EthernetClient client;

void setup()
{
 Ethernet.begin(mac);
  Serial.begin(9600);

  delay(1000);
  Serial.println("connecting...");

  if (client.connect(server, 80)) {
    Serial.println("connected");
 
    delay(1000);
    client.println("GET /tstat HTTP/1.1");
    client.println();

  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {


    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
;
  }


}


Not sure why that was so difficult, i'm sure you all are thinking the same thing, lol.

Ok so for what i hope to be the easier question. I'm sure i can figure out the POST except for how to format the data i need to send. As mentioned in an earlier post the data i need to send in the response line looks like this:

Code:
{"rem_temp":72}

now how do I put that into:

Code:
client.println("");

When I try to add it into the quotations it doesn't like the braces or quotation that are apart of my data string.

I know with windows command prompt and cURL I had to alter it alittle like this:

Code:
"{\"rem_temp\":65}"

i'm sure there is something I can do to tell it that this is part of my data and not code.

your help is great guys!

Thanks!


13  Using Arduino / Programming Questions / Re: Simple HTTP POST to Wifi Thermostat. HELP NEEDED on: February 07, 2013, 01:21:57 am
ok i'm very frustrated. i tried for 4 hours to get this to work, trying to use the GET method to even return something.

It seems that it connects to the thermostat but almost immediately disconnects. I'm not sure if this is because the data that is on the site is so small that it sends it and the disconnects. or if this is a bug. I though i read somewhere people were having trouble with connecting to Linux servers.

Also, not sure if this is a factor but when viewing one of the web pages that contains setting info from the browser, it appears to only be returning TEXT. the text on the web pages is as follows:

{"temp":66.00,"tmode":1,"fmode":0,"override":1,"hold":1,"t_heat":66.00,"tstate":0,"fstate":0,"time":{"day":2,"hour":23,"minute":16},"t_type_post":0}

When i went to view the source to see the HTML it didn't have any HTML. the source page looks the same as the web page.

In answer to your questions i have had success communicating (GET & POST) with the thermostat via my android phone and an app called "tasker". I tell this app the address i'd like to post ( 192.168.1.101/tstat/remote_temp ) and the data i'd like to send is this: 

{"rem_temp":72}

The link to the api i send in my first post says the data can be added to responses of GET and POST methods.

Also, I have used cURL successfully from windows command prompt (with curl installed). This is the the .bat file I use with cURL.

Code:
ECHO OFF
curl -d "{\"rem_temp\":65}" http://192.168.1.101/tstat/remote_temp --silent -o "results.txt"

::| CLIP

::ECHO OFF

I know its hard to troubleshoot problems without being able to fiddle with them yourself. I appreciate you helping me though.


 
14  Using Arduino / Programming Questions / Re: Simple HTTP POST to Wifi Thermostat. HELP NEEDED on: February 05, 2013, 01:55:35 pm
haha, you going to wish you hadn't tried to help me.

After failing time and time again with the POST I had that same thought process. "let see if i can even get info (current settings) from thermostat with GET". Didn't work so well, I'm sure i'm trying something way over my pay grade, however this is kinda the reason I went with arduino.

I love learning new thing but at this point in my life I don't have a ton of time to learn C programming language. I guess i was hoping I could find my way though it with other examples.

Problem is there doesn't appear to be very many http post examples, especially ones that are simplified.

The Arduino is playing the roll of sending the temperature from out bedroom upstairs down to the thermostat so its basing decisions to the the AC or Heater on from the temperature upstairs not at the thermostat itself.
15  Using Arduino / Programming Questions / Re: Simple HTTP POST to Wifi Thermostat. HELP NEEDED on: February 04, 2013, 05:53:02 pm
Thanks for your reply.

Yes i am connected to the network via a switch which is connected directly to the router all via Ethernet.

I honestly am not good enough to alter this example (spent hours trying). Don't know how to get it so it accepts a simple temperature as the posting element.

The thermostat accepts JSON formatting which I assume is what the example is.

Not sure if this helps but the documentation has this in it:

 "The HTTP operation POST updates the resource and assumes a JSON representation of the resource as the values to be updated."

Maybe i'm being naive but this code seems excessive for what i'm trying to accomplish. Is sprintf the only method for http post's?


Thanks again for your help.
Pages: [1] 2