Bonjour tout le monde
Alors voila j'ai un shield GPRS seeed studio (v2) de ce type : http://www.evola.fr/product_info.php/shield-gprs-p-479
aucun soucis pour l'envoi de SMS, mais ca se complique pour l"envoi de données sur un serveur.
j'ai installé le programme donné en exemple ici : https://docs.google.com/file/d/0B6Qn4nam5VvfNGNlYTYyNjYtZjg3ZS00ZWVhLWI2MWItMzBiMjRiOTk4ZmFm/edit
en prenant soin de le modifier en version arduino 1.0 (les bytes, write etc ...) comme ceci :
//Remember when using GPRS Shield with Seeeduino Stalker v2.0
//please dismount the OK_READ Jumper (i.e. open it).
//This will disconnect the Battery Charger IC's OK pin from
//the microcontrollers Digital Pin 7 and hence allow unhindered
//communication with GPRS Shield using NewSoftSerial Library.
//Replace the following items in the code:
//1. Replace the Access Point Name "TATA.DOCOMO.INTERNET"
//and the DNS server name "10.6.6.6" in the AT+CGDCONT and AT+CSTT
//commands with those of your own service provider.
//
//2. Replace the Pachube API Key with your personal ones assigned
//to your account at pachube.com
//
//3. You may choose a different name for the the data stream.
//I have choosen "TMP102". If you use a different name, you will have
//to replace this string with the new name.
//
#include <SoftwareSerial.h>
#include "tmp102.h"
//Please fetch tmp102.h and tmp102.cpp from "Stlker logger AM06 Serial.zip"
//available from Seeeduino Stalker v2.0's Wiki Page
#include <Wire.h>
float convertedtemp; // We then need to multiply our two bytes by a scaling factor, mentioned in the datasheet.
int tmp102_val; // an int is capable of storing two bytes, this is where we "chuck" the two bytes together.
SoftwareSerial GPRS_Serial(7, 8);
void setup()
{
GPRS_Serial.begin(19200); //GPRS Shield baud rate
Serial.begin(19200);
tmp102_init();
setup_start:
Serial.println("Turn on GPRS Modem and wait for 1 minute.");
Serial.println("and then press a key");
Serial.println("Press c for power on configuration");
Serial.println("press any other key for uploading");
Serial.flush();
while(Serial.available() == 0);
if(Serial.read()=='c')
{
Serial.println("Executing AT Commands for one time power on configuration");
GPRS_Serial.flush();
GPRS_Serial.println("ATE0"); //Command echo off
Serial.println("ATE0 Sent");
if(GPRS_Serial_wait_for_bytes(4,10) == 0)
{
Serial.println("Timeout");
goto setup_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}
GPRS_Serial.println("AT+CIPMUX=0"); //We only want a single IP Connection at a time.
Serial.println("AT+CIPMUX=0 Sent");
if(GPRS_Serial_wait_for_bytes(4,10) == 0)
{
Serial.println("Timeout");
goto setup_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}
GPRS_Serial.println("AT+CIPMODE=0"); //Selecting "Normal Mode" and NOT "Transparent Mode" as the TCP/IP Application Mode
Serial.println("AT+CIPMODE=0 Sent!");
if(GPRS_Serial_wait_for_bytes(4,10) == 0)
{
Serial.println("Timeout");
goto setup_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}
GPRS_Serial.println("AT+CGDCONT=1,\"IP\",\"mms.free.fr\",\"212.27.40.240\",0,0"); //Defining the Packet Data
//Protocol Context - i.e. the Protocol Type, Access Point Name and IP Address
Serial.println("AT+CGDCONT=1,\"IP\",\"mms.free.fr\",\"212.27.40.240\",0,0 Sent!");
if(GPRS_Serial_wait_for_bytes(4,10) == 0)
{
Serial.println("Timeout");
goto setup_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}
GPRS_Serial.println("AT+CSTT=\"mms.free.fr\""); //Start Task and set Access Point Name (and username and password if any)
Serial.println("AT+CSTT=\"mms.free.fr\" Sent!");
if(GPRS_Serial_wait_for_bytes(4,10) == 0)
{
Serial.println("Timeout");
goto setup_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}
GPRS_Serial.println("AT+CIPSHUT"); //Close any GPRS Connection if open
Serial.println("AT+CIPSHUT Sent!");
if(GPRS_Serial_wait_for_bytes(7,10) == 0)
{
Serial.println("Timeout");
goto setup_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}
}
}
void loop()
{
loop_start:
Serial.println("Press a key to read temperature and upload it");
Serial.flush();
while(Serial.available() == 0);
Serial.read();
getTemp102();
Serial.print("TMP102 Temperature = ");
Serial.println(convertedtemp);
GPRS_Serial.println("AT+CIPSTART=\"TCP\",\"api.pachube.com\",\"80\""); //Open a connection to Pachube.com
Serial.println("AT+CIPSTART=\"TCP\",\"api.pachube.com\",\"80\" Sent!");
if(GPRS_Serial_wait_for_bytes(12,255) == 0)
{
Serial.println("Timeout");
goto loop_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}
GPRS_Serial.flush();
GPRS_Serial.println("AT+CIPSEND"); //Start data through TCP connection
Serial.println("AT+CIPSEND Sent!");
if(GPRS_Serial_wait_for_bytes(1,100) == 0)
{
Serial.println("Timeout");
goto loop_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}
GPRS_Serial.flush();
//Emulate HTTP and use PUT command to upload temperature datapoint using Comma Seperate Value Method
GPRS_Serial.print("PUT /v2/feeds/24300.csv HTTP/1.1\r\n");
Serial.println("PUT /v2/feeds/24300.csv HTTP/1.1 Sent!");
delay(300);
GPRS_Serial.print("Host: api.pachube.com\r\n");
Serial.println("Host: api.pachube.com Sent!");
delay(300);
GPRS_Serial.print("X-PachubeApiKey: RVMgKHUNaiYFXVcQPxjL0m94aKGSAKxzRmpteWdXVlRRMD0g\r\n"); //REPLACE THIS KEY WITH YOUR OWN PACHUBE API KEY
Serial.println("X-PachubeApiKey: RVMgKHUNaiYFXVcQPxjL0m94aKGSAKxzRmpteWdXVlRRMD0g Sent!"); //REPLACE THIS KEY WITH YOUR OWN PACHUBE API KEY
delay(300);
GPRS_Serial.print("Content-Length: 12\r\n");
Serial.print("Content-Length: 12 Sent!");
delay(300);
GPRS_Serial.print("Connection: close\r\n\r\n");
Serial.print("Connection: close Sent!");
delay(300);
GPRS_Serial.print("TMP102,"); //You may replace the stream name "TMP102" to any other string that you have choosen.
delay(300);
GPRS_Serial.print(convertedtemp);
delay(300);
GPRS_Serial.print("\r\n");
delay(300);
GPRS_Serial.print("\r\n");
delay(300);
GPRS_Serial.write((byte)0x1A);
delay(300); //Send End Of Line Character to send all the data and close connection
if(GPRS_Serial_wait_for_bytes(20,255) == 0)
{
Serial.println("Timeout");
goto loop_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}
GPRS_Serial.flush();
GPRS_Serial.println("AT+CIPSHUT"); //Close the GPRS Connection
Serial.println("AT+CIPSHUT Sent!");
if(GPRS_Serial_wait_for_bytes(4,100) == 0)
{
Serial.println("Timeout");
goto loop_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}
}
char GPRS_Serial_wait_for_bytes(char no_of_bytes, int timeout)
{
while(GPRS_Serial.available() < no_of_bytes)
{
delay(200);
timeout-=1;
if(timeout == 0)
{
return 0;
}
}
return 1;
}
le prog semble fonctionner mais je vois rien sur mon compte sur cosm.com
quelqu'un aurait il déjà utilisé ce système ?
merci