non capiso, parli del codice di prova o della libreria?
Non faccio piu ca,.begin(velocità).
Analizzando l libreria faceva solo il begin della seriale.
Avevo provato anche a forzare il valore del hwSerial, ma non cambiava niente.
Quindi lo faccio nel nel mio esempio (che allego sotto):
#include <Keypad.h>
#include <stdlib.h>
#include <LiquidCrystal.h>
#include <SPI.h> //richiesta da Ethernet
#include <Ethernet.h>
#include <Adafruit_VC0706.h>
#include <SoftwareSerial.h>
String inputString = ""; // a string to hold incoming data
String inputStringTastierino = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
char TERMINATORE = '|';
int passo = 1;
long numeroTentato = 0;
long codiceUtente = 0;
String codiceUtenteS = "";
float calibrazione;
int DeltaEmpirico = 0;
int MASSIMO = 3000; //Valore massimo da indovinare
const byte ROWS = 4; // 4 righe
const byte COLS = 4; // 4 colonne
// Define the Keymap
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
// Dal pin piu a sinistra dove c'è l'asterisco i primi 4 (righe) pin quindi 1>7 2>6 3>5 4>4
byte rowPins[ROWS] = {
23,25,27,29};
// Dal 5 pin piu a sinistra (asterisco a sinistra) i successivi 4 (colonne) pin quindi 5>11 6>10 7>9 8>8
byte colPins[COLS] = {
31,33,35,37};
Keypad tastierino = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
#define ledpin 13
int NumeroCaso;
int speaker = 34;
LiquidCrystal lcd(22, 24, 26, 28, 30, 32);
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
Adafruit_VC0706 cam = Adafruit_VC0706(&Serial1);
//http://www.theshaker.org/test_nicola/image_upload.php
//char serverName[] = "www.theshaker.org";
char serverName[] = "php.ogilvy.it";
int32_t time = millis();
int32_t ritorno;
EthernetClient client;
// ********************************************** SETUP ******************************************************************
void setup() {
// initialize serial:
Serial.begin(38400);
ritorno = -1;
calibrazione = (2000.00 / 258.00);
DeltaEmpirico = -4;
delay(2000);
Serial.println("Seriale Connessa");
//COSA SERVONO STE DUE RIGHE SOTTO? Per la SD dicono
//pinMode(10, OUTPUT); // change this to 53 on a mega
//digitalWrite(10, HIGH); //NON E' VERO
//pinMode(53, OUTPUT); // change this to 53 on a mega
//digitalWrite(53, HIGH);
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;;)
;
}
// print your local IP address:
Serial.print("My IP address: ");
for (byte thisByte = 0; thisByte < 4; thisByte++) {
// print the value of each byte of the IP address:
Serial.print(Ethernet.localIP()[thisByte], DEC);
Serial.print(".");
}
Serial.println();
delay(1000);
// pinMode(53, OUTPUT); // change this to 53 on a mega
// digitalWrite(53, HIGH);
//115200 38400
//Serial1.begin(115200);
/*
if (cam.begin()) {
Serial.println("CAMERA TROVATA");
} else
{
Serial.println("CAMERA NON TROVATA");
return;
}
*/
Serial1.begin(38400);
setBaudMax(); //da provare da qualche parte
Serial1.end();
Serial1.begin(115200);
//UNA VOLTA ANDATO. PROVO A DIMINUIRE I TEMPI
delay(1000);
cam.reset();
delay(1000);
/*
char *reply = cam.getVersion();
if (reply == 0) {
Serial.print("Failed to get version");
} else {
Serial.println("-- Versione Cam --");
Serial.print(reply);
Serial.println("------------------");
}
*/
takefoto();
}
// ********************************************** SETUP FINE ******************************************************************
// ********************************************** LOOP ******************************************************************
void loop() {
}
// ********************************************** LOOP FINE ******************************************************************
int takefoto() {
Serial.println("Snap in 3 secs...");
uint8_t imgsize = cam.getImageSize();
Serial.print("Image size: ");
if (imgsize == VC0706_640x480) Serial.println("640x480");
if (imgsize == VC0706_320x240) Serial.println("320x240");
if (imgsize == VC0706_160x120) Serial.println("160x120");
delay(3000);
if (! cam.takePicture())
Serial.println("Failed to snap!");
else
Serial.println("Picture taken!");
Serial.println("Server connecting...");
client.stop();
if (client.connect(serverName, 80)) {
Serial.println("connected");
// Make a HTTP request:
// client.println("GET /ARDUINO/savepicture.cfm");
// client.println();
time = millis();
// Get the size of the image (frame) taken
uint16_t jpglen = cam.frameLength();
Serial.print("Storing ");
Serial.print(jpglen, DEC);
Serial.print(" byte image.");
uint32_t len = jpglen + 177; // 177 is the content without the image data
//client.println(F("POST /path/to/script.php HTTP/1.0"));
//client.println(F("POST /ARDUINO/savepicture.cfm HTTP/1.0"));
//http://www.theshaker.org/test_nicola/image_upload.php
//www.theshaker.org
//client.println(F("POST /test_nicola/image_upload.php HTTP/1.0"));
client.println(F("POST /arduino/progetto_peso/image_upload.php HTTP/1.0"));
client.println(F("Host: php.ogilvy.it"));
client.println(F("Content-type: multipart/form-data, boundary=UH3xBZZtzewr09oPP"));
client.print(F("Content-Length: "));
client.println(len);
client.println();
client.println(F("--UH3xBZZtzewr09oPP"));
//client.println(F("content-disposition: form-data; name=\"picture\"; filename=\"cam.jpg\""));
client.print(F("content-disposition: form-data; name=\"picture\"; filename=\""));
client.print(F("231_755.jpg"));
client.println(F("\""));
//Messo in 3 print FUNZIONA
client.println(F("Content-Type: image/jpeg"));
client.println(F("Content-Transfer-Encoding: binary"));
client.println();
pinMode(8, OUTPUT);
// Read all the data up to # bytes!
byte wCount = 0; // For counting # of writes
while (jpglen > 0) {
// read 32 bytes at a time;
uint8_t *buffer;
uint8_t bytesToRead = min(32, jpglen); // change 32 to 64 for a speedup but may not work with all setups!
buffer = cam.readPicture(bytesToRead);
//Scrittura
// imgFile.write(buffer, bytesToRead);
client.write(buffer, bytesToRead);
// Serial.write(buffer, HEX);
if(++wCount >= 64) { // Every 2K, give a little feedback so it doesn't appear locked up
Serial.print('.');
wCount = 0;
}
//Serial.print("Read "); Serial.print(bytesToRead, DEC); Serial.println(" bytes");
jpglen -= bytesToRead;
}
// imgFile.close();
client.println();
client.println(F("--UH3xBZZtzewr09oPP--"));
time = millis() - time;
Serial.println("done!");
Serial.print(time); Serial.println(" ms elapsed");
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.flush();
client.stop();
// do nothing forevermore:
while(true);
}
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
tone(speaker, 73,50);
delay(50);
tone(speaker, 50,150);
delay(150);
client.flush();
client.stop();
}
return time;
}
void setBaudMax() {
uint8_t ByteData[7]={0x56, 0x00, 0x24, 0x03, 0x01, 0x0D, 0xA6}; //String that sets baud to 115200
Serial1.write(ByteData,7); //Send string to camera
//Should really check for a suitable response here!
}