Show Posts
Pages: [1]
1  International / Software / Re: Arduino mega2560 + wifi shield = DOMOTICA ON LINE on: May 04, 2013, 06:24:44 am
si fammi sapere magari li integriamo
2  International / Software / Re: Arduino mega2560 + wifi shield = DOMOTICA ON LINE on: May 02, 2013, 02:51:26 pm

allora parti da qua per il tuo progetto

http://playground.arduino.cc/Code/WebClient

la versione GET

e segui la mia guida per il mio sito ti aiuta sicuramente

http://www.dataino.it/help/help.htm

occhio .. usa sempre questo formato Serial.println(F("Ready"));   

F("Stringa da stampare sulla seriale")  ti eviti un casino di crash e cose strane

altra cosa usa solo >>>> char var[] = "&Temp="; <<<< per definire le stringe
e soprattutto le variabili stringhe non usarle proprio fanno casino ci ho perso una giornata

http://arduino.cc/forum/index.php/topic,163797.0.html


codice funzionante che legge un sensore e manda la temp online
per vederlo all'opera in locale cambia la apy-key con e gli ip del server
 
Code:
//===================
// dataino.it
//===================
#include <Ethernet.h>
#include <SPI.h>
//===================
// DS18B20
//===================
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Assign the addresses of your 1-Wire temp sensors.
DeviceAddress insideThermometer = {
  0x28, 0x67, 0xE7, 0x47, 0x04, 0x00, 0x00, 0x2B };
//===================
//dataino.it
//===================
//~~~~~~~~~~~~~~~~~~~
// remember to chang mac!!!
// this must be unique
//~~~~~~~~~~~~~~~~~~~~
byte mac[] = {
  0x90,0xA2,0xDA,0x0D,0x82,0x39};
// change to your network settings
IPAddress ip(192,168,6,91);
IPAddress gateway(192, 168, 6, 90);
IPAddress subnet(255, 255, 255, 0);
//~~~~~~~~~~~~~~~~~~~~
// LOCAL HOST SERVER
//~~~~~~~~~~~~~~~~~~~~
//IPAddress server(192,168,6,90); //localhost
//char API_key[] = "41uX-u50e-84d4-8f0u-kP0s";
//~~~~~~~~~~~~~~~~~~~~
//~ ONLINE SERVER !!!
//~~~~~~~~~~~~~~~~~~~~~
IPAddress server(94,23,64,3); //dataino.it
String API_key = "68bS-4p6r-r8FR-3W0X-bZ68";
//~~~~~~~~~~~~~~~~~~~~~~

char cmd_find[] = "find_value";
char cmd_add[] = "add_value";
char cmd_read[] = "read_value";
char cmd_delete[] = "delete_value";
char cmd_set[] = "set_value";
char var[] = "&Temp=";

int totalCount = 0;
int loopCount = 0;
char pageAdd[128];

//~~~~~~~~~~~~~~~~~~~
EthernetClient client;
//===================
// S E T U P
//===================
void setup(void)
{
  // start serial port
  Serial.begin(9600);
  //===================
  // DS18B20
  //===================
  // Start up the library
  sensors.begin();
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(insideThermometer, 10);
  //===================
  //dataino.it
  //===================
  // Start ethernet
  Serial.println(F("Starting ethernet..."));
  Ethernet.begin(mac, ip, gateway, gateway, subnet);

  // If using dhcp, comment out the line above
  // and uncomment the next 2 lines

  // if(!Ethernet.begin(mac)) Serial.println(F("failed"));
  // else Serial.println(F("ok"));
  //digitalWrite(10,HIGH);

  Serial.println(Ethernet.localIP());

  delay(2000);
  Serial.println(F("Ready"));
}
//===================
// PRINT TEMP
//===================
void printTemperature(DeviceAddress deviceAddress)
{
  //===================
  // DS18B20
  //===================
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print(F("Error getting temperature"));
  }
  else {
    Serial.print(F("C: "));
    Serial.print(tempC);
    Serial.print(F(" F: "));
    Serial.print(DallasTemperature::toFahrenheit(tempC));
    //===================
    // dataino.it
    //===================
    //dtostrf(FLOAT,WIDTH,PRECSISION,BUFFER);
    char buffer[10];
    dtostrf(tempC, 5, 2, buffer);
    sprintf(pageAdd ,"/dataino.it/api/%s.php?api-KEY=%s%s%s" ,cmd_add, API_key, var,buffer);
  }
}
//===================
// DS18B20
//===================
void loop(void)
{
  if(loopCount < 50)
  {
    // if loopCount is less than 50, just delay a 100 millisecond
    delay(100);
    Serial.print(F("."));
  }
  else
  {
    // every tree seconds this runs
    loopCount = 0;
    Serial.print(F("\n\r"));
    //===================
    // DS18B20
    //===================
    Serial.print(F("Getting temperatures...\n\r"));
    sensors.requestTemperatures();
    Serial.print(F("Inside temperature is: "));
    printTemperature(insideThermometer);
    Serial.print(F("\n\r"));

    //================
    if(!getPage(server,pageAdd)) Serial.print(F("Fail "));
    else Serial.print(F("Pass "));
    totalCount++;
    Serial.println(totalCount,DEC);
  }   

  loopCount++;

}
//===================
// dataino.it
//===================
byte getPage(IPAddress ipBuf,char *page)

{
  int inChar;
  char outBuf[128];
  Serial.print(F("connecting..."));
  if(client.connect(ipBuf,80))
  {
    Serial.println(F("connected"));
    sprintf(outBuf,"GET %s HTTP/1.0\r\n\r\n",page);
    client.write(outBuf);
    Serial.println(F("outBuf"));
  }
  else
  {
    Serial.println(F("failed"));
    return 0;
  }

  // connectLoop controls the hardware fail timeout

  int connectLoop = 0;
  //Unsigned long variables are extended size variables for number storage,
  //and store 32 bits (4 bytes). Unlike standard longs unsigned longs
  //won't store negative numbers, making their range from 0 to 4,294,967,295
  long VAL[16];
  while(client.connected())
  {
    while(client.available())
    {
      //=======
      inChar = client.read();

      if (inChar==char('#'))
      {
        inChar = client.read();
        //=======
        while (inChar!='#'){
          int count_val =0 ;
          unsigned long i = 1;
          VAL[count_val]=0;
          //=======
          do {
            VAL[count_val] = VAL[count_val] + (inChar-48) * i;
            i=i*10;
            inChar = client.read();
          }
          while ((inChar!=char(';')));
          //=======
          //Serial.print(var[count_val]);
          //Serial.print("=");
          //Serial.print(VAL[count_val]);
          //Serial.println();

          inChar = client.read();
          //Serial.print(inChar);
          //=======
          if (inChar==char('*')){
            Serial.print(F("Query="));
            Serial.print(VAL[count_val]);
            break;             
          }
          count_val=count_val+1;
        }
      }
     
      // set connectLoop to zero if a packet arrives
      connectLoop = 0;
    }
    connectLoop++;
  }
  // if more than 10000 milliseconds since the last packet
  if(connectLoop > 10000)
  {
    // then close the connection from this end.
    Serial.println();
    Serial.println(F("Timeout"));
    client.stop();
  }
  // this is a delay for the connectLoop timing
  delay(1);


  Serial.println();

  Serial.println(F("disconnecting."));
  // close client end
  client.stop();

  return 1;
}


3  Using Arduino / Networking, Protocols, and Devices / Re: Internet access via wifi shield and cell phone hotspot - anyone done it? on: May 01, 2013, 07:57:49 pm
dou have enabled "Use packet data" under "mobil network" 
4  Using Arduino / Networking, Protocols, and Devices / Re: Control simultaneously 40 Led DIMMER with RF on: May 01, 2013, 07:28:42 pm
do u need the same light an all 40 led ?
5  Using Arduino / Networking, Protocols, and Devices / Re: Arduino Webserver/homepage on: May 01, 2013, 07:24:08 pm
and why u do not use a externa web server for controll arduino from internet ?

take a look !!

www.dataino.it

6  Using Arduino / Networking, Protocols, and Devices / Re: HTTP GET MALFORMED COMMAD AFTER 5 SEND (ARDUINO+ETHERNET) on: May 01, 2013, 04:24:30 pm
Fantastic !!!

    //dtostrf(FLOAT,WIDTH,PRECSISION,BUFFER);
    char buffer[10];
    dtostrf(tempC, 5, 2, buffer);

+3k of memory free now

thx again

 please register to my site www.dataino.it and give me a feedback
7  Using Arduino / Networking, Protocols, and Devices / Re: HTTP GET MALFORMED COMMAD AFTER 5 SEND (ARDUINO+ETHERNET) on: May 01, 2013, 01:24:45 pm
wath about the conversion of the float temp in strng and than in char is correct ?


    String val = ftoa(tempC,2,5);
    char VALUE[10];
    val.toCharArray(VALUE,10);

8  Using Arduino / Networking, Protocols, and Devices / Re: HTTP GET MALFORMED COMMAD AFTER 5 SEND (ARDUINO+ETHERNET) on: May 01, 2013, 01:10:59 pm
RESOLVED thx

add  F()

convert in char

char API_key[] = "41uX-u50e-84d4-8f0u-kP0s";
char cmd_find[] = "find_value";
char cmd_add[] = "add_value";
char cmd_read[] = "read_value";
char cmd_delete[] = "delete_value";
char cmd_set[] = "set_value";
char var[] = "&Temp=";
char pageAdd[128];

and use

sprintf(pageAdd ,"/dataino.it/api/%s.php?api-KEY=%s%s%s" ,cmd_add, API_key, var,VALUE);

to form get command

one question about convert

floa >to> string >to> char

    Serial.print(DallasTemperature::toFahrenheit(tempC));
    //===============================================================================
    // dataino.it
    //===============================================================================
    String val = ftoa(tempC,2,5);
    char VALUE[10];
    val.toCharArray(VALUE,10);

is the best way?
9  Using Arduino / Networking, Protocols, and Devices / Re: HTTP GET MALFORMED COMMAD AFTER 5 SEND (ARDUINO+ETHERNET) on: May 01, 2013, 09:36:28 am
the model is arduino UNO

Code:
#include <Ethernet.h>
#include <SPI.h>
// DS18B20
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
// Assign the addresses of your 1-Wire temp sensors.
DeviceAddress insideThermometer = {
  0x28, 0x67, 0xE7, 0x47, 0x04, 0x00, 0x00, 0x2B };

//dataino.it
// remember to chang mac!!!
// this must be unique
byte mac[] = {
  0x90,0xA2,0xDA,0x0D,0x82,0x39};
// change to your network settings
IPAddress ip(192,168,6,91);
IPAddress gateway(192, 168, 6, 90);
IPAddress subnet(255, 255, 255, 0);

// LOCAL HOST SERVER
//IPAddress server(192,168,6,90); //localhost
//String API_key = "41uX-u50e-84d4-8f0u-kP0s";

//~ ONLINE SERVER !!!
IPAddress server(94,23,64,3); //dataino.it
String API_key = "68bS-4p6r-r8FR-3W0X-bZ68";

String cmd_find = "/dataino.it/api/find_value.php?api-KEY=";
String cmd_add = "/dataino.it/api/add_value.php?api-KEY=";
String cmd_read = "/dataino.it/api/read_value.php?api-KEY=";
String cmd_delete = "/dataino.it/api/delete_value.php?api-KEY=";
String cmd_set = "/dataino.it/api/set_value.php?api-KEY=";
String command = "";
String var[]={
  "Temp="};
int totalCount = 0;
int loopCount = 0;
char pageAdd[128];
EthernetClient client;
// S E T U P
void setup(void)
{
  // start serial port
  Serial.begin(9600);
  
  sensors.begin();
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(insideThermometer, 10);
    
  // Start ethernet
  Serial.println(F("Starting ethernet..."));
  Ethernet.begin(mac, ip, gateway, gateway, subnet);

  // If using dhcp, comment out the line above
  // and uncomment the next 2 lines

  // if(!Ethernet.begin(mac)) Serial.println(F("failed"));
  // else Serial.println(F("ok"));
  //digitalWrite(10,HIGH);

  Serial.println(Ethernet.localIP());

  delay(2000);
  Serial.println(F("Ready"));
}
// PRINT TEMP
void printTemperature(DeviceAddress deviceAddress)
{
// DS18B20
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Error getting temperature");
  }
  else {
    Serial.print("C: ");
    Serial.print(tempC);
    Serial.print(" F: ");
    Serial.print(DallasTemperature::toFahrenheit(tempC));
    // dataino.it
    String val0= ftoa(tempC,2,5);
    
    command = cmd_add + API_key + "&" + var[0] + val0 + "\0";
    command.toCharArray(pageAdd, 128);
    
  }
}
// DS18B20
void loop(void)
{
  if(loopCount < 50)
  {
    // if loopCount is less than 50, just delay a 100 millisecond
    delay(100);
    Serial.print(".");
  }
  else
  {
    // every tree seconds this runs
    loopCount = 0;
    Serial.print("\n\r");
    // DS18B20
    Serial.print("Getting temperatures...\n\r");
    sensors.requestTemperatures();
    Serial.print("Inside temperature is: ");
    printTemperature(insideThermometer);
    Serial.print("\n\r");

    //================================================================================
    if(!getPage(server,pageAdd)) Serial.print(F("Fail "));
    else Serial.print(F("Pass "));
    totalCount++;
    Serial.println(totalCount,DEC);
  }    

  loopCount++;

}
//===============================================================================
// dataino.it
//===============================================================================
byte getPage(IPAddress ipBuf,char *page)

{
  int inChar;
  char outBuf[128];
  Serial.print(F("connecting..."));
  if(client.connect(ipBuf,80))
  {
    Serial.println(F("connected"));
    sprintf(outBuf,"GET %s HTTP/1.0\r\n\r\n",page);
    client.write(outBuf);
    Serial.println(F("outBuf"));
  }
  else
  {
    Serial.println(F("failed"));
    return 0;
  }

  // connectLoop controls the hardware fail timeout

  int connectLoop = 0;
  //Unsigned long variables are extended size variables for number storage,
  //and store 32 bits (4 bytes). Unlike standard longs unsigned longs
  //won't store negative numbers, making their range from 0 to 4,294,967,295
  long VAL[16];
  while(client.connected())
  {
    while(client.available())
    {
      
      inChar = client.read();

      if (inChar==char('#'))
      {
        inChar = client.read();
        
        while (inChar!='#'){
          int count_val =0 ;
          unsigned long i = 1;
          VAL[count_val]=0;
          
          do {
            VAL[count_val] = VAL[count_val] + (inChar-48) * i;
            i=i*10;
            inChar = client.read();
          }
          while ((inChar!=char(';')));
          
         inChar = client.read();
          //Serial.print(inChar);
          
          if (inChar==char('*')){
            Serial.print("Query=");
            Serial.print(VAL[count_val]);
            break;            
          }
          count_val=count_val+1;
          
        }
        
        
      }
      
      // set connectLoop to zero if a packet arrives
      connectLoop = 0;
    }
    connectLoop++;
  }
  // if more than 10000 milliseconds since the last packet
  if(connectLoop > 10000)
  {
    // then close the connection from this end.
    Serial.println();
    Serial.println(F("Timeout"));
    client.stop();
  }
  // this is a delay for the connectLoop timing
  delay(1);


  Serial.println();

  Serial.println(F("disconnecting."));
  // close client end
  client.stop();

  return 1;
}

String ftoa(float number, uint8_t precision, uint8_t size) {


  String s = "";

  // Negative
  if (number < 0.0)  {
    s = "-";
    number = -number;
  }

  double rounding = 0.5;
  for (uint8_t i = 0; i < precision; ++i)    rounding /= 10.0;

  number += rounding;
  s += String(uint16_t(number));  // prints the integer part

  if(precision > 0) {
    s += ".";                // prints the decimal point
    uint32_t frac;
    uint32_t mult = 1;
    uint8_t padding = precision -1;
    while(precision--)     mult *= 10;

    frac = (number - uint16_t(number)) * mult;

    uint32_t frac1 = frac;
    while(frac1 /= 10)    padding--;
    while(padding--)      s += "0";
    s += String(frac,DEC) ;  // prints the fractional part
  }
  if (size>0)                // checks size
    if (s.length()>size)        return("#");
    else while(s.length()<size) s = " "+s;
  return s;
}

10  Using Arduino / Networking, Protocols, and Devices / HTTP GET MALFORMED COMMAD AFTER 5 SEND (ARDUINO+ETHERNET) on: April 30, 2013, 07:43:03 pm
GET /dataino.it/api/add_value.php?api-KEY=41uX-u50e-84d4-8f0u-kP0s&Temp=22.75 HTTP/1.0" 200 6 "-" "-"
GET /dataino.it/api/add_value.php?api-KEY=41uX-u50e-84d4-8f0u-kP0s&Temp=22.75 HTTP/1.0" 200 6 "-" "-"
GET /dataino.it/api/add_value.php?api-KEY=41uX-u50e-84d4-8f0u-kP0s&Temp=22.75 HTTP/1.0" 200 6 "-" "-"
GET /dataino.it/api/add_value.php?api-KEY=41uX-u50e-84d4-8f0u-kP0s&Temp=22.75 HTTP/1.0" 200 6 "-" "-"
GET /dataino.it/api/add_value.php?api-K\xc4\x06=41uX-u50e-84d4-8f0u-kP0s&Temp=22.75 HTTP/1.0" 200 983 "-" "-"

why ??????????
programm hang !!!

for test online

IPAddress server(94,23,64,3); //dataino.it
String API_key = "68bS-4p6r-r8FR-3W0X-bZ68";

11  International / Software / Re: Arduino mega2560 + wifi shield = DOMOTICA ON LINE on: April 30, 2013, 12:48:02 pm
ciao valerio io sto sviluppando un sito (www.dataino.it) che permette di creare queste applicazioni online
il server il database e il software per vreare il tutto è gratuito ed è online
crei tu il database e il relativo pannello di controllo e ti crei anche i grafici dai dati raccolti
io ci sto lavorando da mesi ed è a buon punto e mi farebbe piacere una tua opinione e come tester dell'applicazione

se invece vuoi ti aiuto e molto volentieri se vuoi creartene uno tuo.

Si ti serve un ip statico in teoria poi alcuni provider non lo sanno ma c'è un modo per bypassare
il problema e con pochi euro hai un sito con ip statico anche se non lo è

per la creazione del tuo sito avrei necessità di maggiori info

quante stanze quante luci

on off o dimmer

quanti sensori ecc. ecc..

Ciao
12  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet to Internet ??? Addressing problem. on: April 16, 2013, 07:21:30 pm
u need a Dynamic DNS service

http://en.wikipedia.org/wiki/Dynamic_DNS

http://dnslookup.me/dynamic-dns/
13  Using Arduino / Networking, Protocols, and Devices / WEB SERVER www.dataino.it for collect data and control arduino on: April 16, 2013, 06:54:24 pm
hi
 
I develop www.dataino.it for manage data from arduino and create graph and make web interface for control arduino output .

now i have this problem what is the best way for send data  to arduino ?

in my project  i Make a HTTP request:
     client.println("GET /~dataino/api/read.php?api-KEY=cl38-hi8j-4lmG-19K4-JNm2&bedroom=i&kitchen=i
HTTP/1.1");
      client.println("Host: www.dataino.it");    
      client.println("User-Agent: Arduino");  
      client.println("Connection: close\r\n");    
      client.println();

and a php page Response:

#bedroom;0;kitchen;82;

"#" is used for recognize data and ";" for split data

is this the best way?

thx




14  Using Arduino / Networking, Protocols, and Devices / Re: Network on: April 16, 2013, 01:36:08 pm
take a look at www.dataino.it is my website developed for arduino that can help u
u can add a project for reciving data from arduino and create graph or if u need control arduino u can d it
via web page.

the websit is in beta and i need opinion and neet to debag funciont if u test send me a report

thx


Pages: [1]