Salve a tutti, nelle ultime settimane sono riuscito a collegare il mio arduino uno ad internet tramite libreria Blynk (link) e relativa app, sia con shield ethernet che tramite ESP8266-01.
Il programma base è favoloso, controllo tutte le uscite senza alcun problema e senza modificare il programma caricato su arduino. La risposta è abbastanza veloce (considerando che comunque passa per il server di Blynk).
Fino a qui tutto bene. Quando però tento di inviare dati tramite ESP improvvisamente la comunicazione rallenta moltissimo ed è quasi impossibile inviare dati (tipo per accendere un led).
Non riesco a capirne il motivo perchè sembra comunque (osservando il led dell'esp) che l'invio dei dati continui normalmente mentre la ricezione avvenga molto in ritardo (anche di oltre un minuto).
Ho provato a aggiungere alcuni delay ma il risultato sembra il medesimo, vi allego qui il mio codice senza token e password del wifi
/**************************************************************
* Blynk is a platform with iOS and Android apps to control
* Arduino, Raspberry Pi and the likes over the Internet.
* You can easily build graphic interfaces for all your
* projects by simply dragging and dropping widgets.
*
* Downloads, docs, tutorials: http://www.blynk.cc
* Blynk community: http://community.blynk.cc
* Social networks: http://www.fb.com/blynkapp
* http://twitter.com/blynk_app
*
* Blynk library is licensed under MIT license
* This example code is in public domain.
*
**************************************************************
*
* This example shows how to use ESP8266 Shield via Software Serial
* (on Uno, Nano...) to connect your project to Blynk.
*
* Note: Ensure a stable serial connection to ESP8266!
* Firmware version 1.0.0 (AT v0.22) or later is needed.
* Set ESP baud rate to 9600. Connect to AT console and call:
* AT+UART_DEF=9600,8,1,0,0
* In general, Soft Serial is unstable.
* It is highly recommended to switch to Hard Serial.
*
* Change WiFi ssid, pass, and Blynk auth token to run :)
* Feel free to apply it to any other example. It's simple!
*
**************************************************************/
//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266_SoftSer.h>
#include <BlynkSimpleShieldEsp8266_SoftSer.h>
// Set ESP8266 Serial object
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(8, 9); // RX, TX
#include <SFE_BMP180.h>
#include <Wire.h>
#include <SimpleTimer.h>
// You will need to create an SFE_BMP180 object, here called "pressure":
SFE_BMP180 pressure;
//#define ALTITUDE 36.0 //San Vito
#define ALTITUDE 12.0 //Padova
ESP8266 wifi(EspSerial);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = ""; //ESP8266 project
void setup()
{
// Set console baud rate
Serial.begin(9600);
pinMode( A0, INPUT);
// Initialize the sensor (it is important to get calibration values stored on the device).
if (pressure.begin())
Serial.println("BMP180 init success");
else
{
// Oops, something went wrong, this is usually a connection problem,
// see the comments at the top of this sketch for the proper connections.
Serial.println("BMP180 init fail\n\n");
while(1); // Pause forever.
}
delay(10);
// Set ESP8266 baud rate
// 9600 is recommended for Software Serial
EspSerial.begin(9600);
delay(10);
Blynk.begin(auth, wifi, "WI-FI Locale", "");
}
//METODI AUSILIARI
void sendV (){
int tempo=millis();
unsigned long L=1024- analogRead(A0);
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(4, L);
Serial.println(millis()-tempo);
}
void loop()
{
Blynk.run();
sendV();
delay(5000);
}
I tempi di completamento del ciclo di invio (quelli che stampo sul serial monitor) inizialmente sono di 1,2 millisecondi, poi passano attorno ai 250 per poi schizzare a 65746, 131324 e multipli. Secondo voi significa qualcosa che i tempi di risposta aumentino all'incirca di multipli di 65000?
Cosa posso fare per indagare il problema?
Grazie, arrivederci