Loading...
  Show Posts
Pages: [1] 2 3 4
1  Using Arduino / Networking, Protocols, and Devices / Re: Unstable Connection ENC28J60 / HanRun HR911105A with Nano on: March 14, 2013, 10:06:15 am
Did you guy manage a solution for this problem?

Thanks
2  Using Arduino / Programming Questions / Re: dtostrf with 0 value give error when send http on: March 10, 2013, 06:57:35 pm
Mistake by me i always have bad request event if temp is more the 1 degree, If i put it manually like this everything is find and update:
Code:
ether.browseUrl(PSTR("/data_request?id=variableset&DeviceNum=48&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature&Value=7"), "", website, my_callback);

How the do i include the temerature after the=
3  Using Arduino / Programming Questions / Re: dtostrf with 0 value give error when send http on: March 10, 2013, 06:42:16 pm
Maybe that when it convert the 0 in the first bytes, bytes is null? Could that be my problem and if so could a byte be 0 not null.
4  Using Arduino / Programming Questions / Re: dtostrf with 0 value give error when send http on: March 10, 2013, 06:39:55 pm
If value of the sensor is more then 1 , data is send to the server and i receive a ok message. as soon as the temperature is 0, i receive a bad request error 400.
5  Using Arduino / Programming Questions / Re: dtostrf with 0 value give error when send http on: March 10, 2013, 06:33:49 pm
Really dont understand your answer
6  Using Arduino / Programming Questions / dtostrf with 0 value give error when send http on: March 10, 2013, 06:28:53 pm
Hi again,
             could it be possible that when temperature is start with 0, it unable to send the url it give me a error?

Code:
if ((timing ==1) && (millis() > timer)) {
    timer = millis() + 5000;
    sensors.requestTemperatures();
    Serial.println();
    Serial.println("<<< REQ ");
    float sensor1 = (sensors.getTempCByIndex(1));
    char buffer[10];
    dtostrf(sensor1, 5, 2, buffer);
    Serial.println("Sensor2 temperature is:");
    Serial.println(buffer);
    timing = 0;
    delay(500);
    ether.browseUrl(PSTR("/data_request?id=variableset&DeviceNum=48&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature&Value="), buffer, website, my_callback);
   
7  Using Arduino / Programming Questions / Re: Put long string in flash memory on: March 06, 2013, 08:45:39 pm
Thanks,
           yes it will help. could you tell me how to read it after that.
8  Using Arduino / Programming Questions / Re: itoa function with dot in on: March 04, 2013, 02:15:54 pm
got it thanks

Code:
  ether.packetLoop(ether.packetReceive());
  if (millis() > timer) {
    timer = millis() + 5000;
    sensors.requestTemperatures();
    Serial.println();
    Serial.println("<<< REQ ");
    float sensor1 = (sensors.getTempCByIndex(0));
    char buffer[10];
    dtostrf(sensor1, 5, 2, buffer);
    Serial.println(buffer);
    delay(500);
    ether.browseUrl(PSTR("/data_request?id=variableset&DeviceNum=38&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature&Value="), buffer, website, my_callback);

I need to put a delay before sending the url cause it was giving me sometime some bad number.
9  Using Arduino / Programming Questions / itoa function with dot in on: March 04, 2013, 01:20:03 pm
Hi again,
             i finally got my sketche working with the enc28j60. Now i'm able to send to my domotic box the temperature of a one-wire sensor. The only problem that i have is it dont take in concideration the . and the to number next to it so if temperature is 21.56 only 21 will be sent.
Here the code:
Code:
void loop () {
  ether.packetLoop(ether.packetReceive());
  if (millis() > timer) {
    timer = millis() + 10000;
    sensors.requestTemperatures();
    Serial.println(sensors.getTempCByIndex(0));
    Serial.println();
    Serial.println("<<< REQ ");
    char myIntAsString[24]; // 7 bytes is enough to contain any int, including minus sign and terminating zero
    itoa((sensors.getTempCByIndex(0)), myIntAsString, 10);
    Serial.print(myIntAsString);
    ether.browseUrl(PSTR("/data_request?id=variableset&DeviceNum=38&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature&Value="), myIntAsString, website, my_callback);
}
}


Here the result in the serial print:
Code:
P:  192.168.2.124
GW:  192.168.2.1
DNS: 192.168.2.1
SRV: 192.168.2.19
19.25

<<< REQ
19>>>
HTTP/1.1 200 OK
content-Type: text

...

So before convert it to a compatible const char*, sensor read 19.25, but it send 19.

Any idea
Thanks

 
10  Using Arduino / Programming Questions / Re: error: invalid conversion from 'char' to 'const char*' on: March 03, 2013, 07:33:27 pm
Thanks,
           i try what you say and now i'm able to compile it without error.
The problem now is that it give me a bad request. If i print the temp, it give me the temperature. If i replace the temp with "88", no error occur and value 88 is updated. I'm lost
11  Using Arduino / Programming Questions / Re: error: invalid conversion from 'char' to 'const char*' on: March 03, 2013, 07:09:27 pm
Try with int and float, same problem, ethercard seems to need a const char* in the formule: ether.browseUrl(PSTR.....
How could i declare a const char* that could be variable.

Thanks in advance
12  Using Arduino / Programming Questions / error: invalid conversion from 'char' to 'const char*' on: March 03, 2013, 06:49:29 pm
Hi all,

        My problem is i want to put a variable for the temperature but i have an error: error: invalid conversion from 'char' to 'const char'
 here the code:

Code:
// Demo using DHCP and DNS to perform a web client request.
// 2011-06-08 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[700];
static uint32_t timer;

char website[] PROGMEM = "192.168.2.19";
static byte hisip[] = {192,168,2,19};
char temperature;

// called when the client request is complete
static void my_callback (byte status, word off, word len) {
  Serial.println(">>>");
  Ethernet::buffer[off+300] = 0;
  Serial.print((const char*) Ethernet::buffer + off);
  Serial.println("...");
}

void setup () {
  Serial.begin(57600);
  Serial.println("\n[webClient]");

  if (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0)
    Serial.println( "Failed to access Ethernet controller");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip); 
  ether.printIp("DNS: ", ether.dnsip); 
  ether.copyIp(ether.hisip, hisip);
  ether.hisport = 3480;
  ether.printIp("SRV: ", ether.hisip);

  if (!ether.dnsLookup(website))
    Serial.println("DNS failed");
}

void loop () {
  ether.packetLoop(ether.packetReceive());
 
  if (millis() > timer) {
    timer = millis() + 10000;
    temperature = 77;
    Serial.println();
    Serial.print("<<< REQ ");
    ether.browseUrl(PSTR("/data_request?id=variableset&DeviceNum=49&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature&Value="), temperature, website, my_callback);
}
}
13  Using Arduino / Programming Questions / Re: error compile my code on: February 27, 2013, 10:40:21 pm
Ok other method, let say i want to insert value in the url:

Code:
ether.browseUrl(PSTR("/data_request?id=action&DeviceNum=(((HERE))&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue="), "1", website, my_callback);
In python i use the s% function like this:
Code:
"/data_request?id=action&DeviceNum=%s&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=" $ devid
but is there a way in arduino code
thanks
14  Using Arduino / Programming Questions / Re: error compile my code on: February 27, 2013, 10:12:41 pm
Normally to call it i use String not string, if i put string, it say that i have not  declare it.
15  Using Arduino / Programming Questions / Re: error compile my code on: February 27, 2013, 09:53:36 pm
maybe it late here but i don't understand what you means?
Sorry
Pages: [1] 2 3 4