Show Posts
|
|
Pages: [1] 2 3 4
|
|
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: 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=
|
|
|
|
|
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? 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);
|
|
|
|
|
8
|
Using Arduino / Programming Questions / Re: itoa function with dot in
|
on: March 04, 2013, 02:15:54 pm
|
got it thanks 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: 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: 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
|
|
|
|
|
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: // 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: 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: "/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
|
|
|
|
|