Bonjour !
En fait, pour que tout fonctionne il faudrait être connecté en permanence à Blynk (la fonction Blynk.run() permet cela lorsqu'elle est exécutée en boucle dans void loop) et n'établir une connexion à Pushingbox uniquement en cas d’intrusion (soit en théorie très rarement, soit dans le cas d'une effraction, soit si le signal de désactivation d'une télécommande 433 n'est pas reçu par l'arduino ou tout bêtement un oubli...)
J'ai également remarqué que lorsque
if (client.connect("api.pushingbox.com",80) {
client.print("POST /pushingbox?devid=v000000000000");
client.stop()
}
est exécuté, dans le moniteur série s'affiche " Getting IP from DHCP " puis "Bynk connected Ready "etc (exactement comme lors du démarrage), et évidemment aucune notification de la part de Pushingbox n'est reçue...
Par ailleurs, merci beaucoup pour le temps que vous consacrez à m'aider...
PS: Je joint quelques photos du projet ainsi que le code complet, si ça peut servir à quelqu'un...
(Le schéma a pas mal évolué au fil de l'avancement du projet, au départ l'arduino ne devait pas gérer l'activation de l'alarme mais carrément être allumé et éteint par un relais 433, la LED a été remplacée par un afficheur 4*7segment visible en photo, le garage n'a plus son propre relais 433 mais un commandé par arduino au même titre que les sirènes et l'extracteur d'air
- Dans le code, j'ai inclus le DS3231 dont la pile, commandée en Chine, ne m'arrivera que dans 1 mois, car je souhaiterais que l'alarme surveille automatiquement toute la cave pendant la nuit, je vais rajouter ça dans le code prochainement...
#include <EtherCard.h>
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
#include <Wire.h>
#include <DS3231.h>
DS3231 clock;
RTCDateTime dt;
#define VCC_PIN 5 // source 5V up to 40mA
#define GND_PIN 2 // ground up to 40mA
#define DATA_PIN 3 // data 433 In
#define SIREN_PIN A1 // Relay of 12V sirens
#define GARAGE_PIN A2 // Relay of Garage trigger
#define THIRD_RELAY_PIN A3 // Relay of... nothing yet
#define Remote_Cmd 5529424
#define Door_Cuisine 1392005
#define Win_Bureau 1197077
#define Door_Chaufferie 1397855
#define Win_Abri_Bois 1797842
#define PIR_Garage A0
#define PIR_Abri_Bois A1
char IdDoorCuisine[] = "v*/*/*/*/*/*//*//*/";
char IdWinBureau[] = "v*/*/*/*/*/*//*//*/";
char IdDoorChaufferie[] = "v*/*/*/*/*/*//*//*/";
char IdWinAbriBois[] = "v*/*/*/*/*/*//*//*/";
char IdPIRGarage[] = "v*/*/*/*/*/*//*//*/";
static byte mymac[] = {0x24,0x99,0x42,0xAD,0x30,0x32}; // Be sure this address is unique in your network
const char website[] PROGMEM = "api.pushingbox.com";
byte Ethernet::buffer[700];
Stash stash;
boolean DEBUG = true;
void setup()
{
Serial.begin(9600);
pinMode(SIREN_PIN, OUTPUT);
pinMode(GARAGE_PIN, OUTPUT);
pinMode(THIRD_RELAY_PIN, OUTPUT);
digitalWrite(SIREN_PIN, HIGH);
digitalWrite(GARAGE_PIN, HIGH);
digitalWrite(THIRD_RELAY_PIN, HIGH);
pinMode(DATA_PIN, INPUT);
pinMode(GND_PIN, OUTPUT);
pinMode(VCC_PIN, OUTPUT);
digitalWrite(GND_PIN, LOW);
digitalWrite(VCC_PIN, HIGH);
if(DEBUG){Serial.println("\n[getDHCPandDNS]");}
//
//***Depending of your Shield, you may have to try this line instead of the second***//
//if(ether.begin(sizeof Ethernet::buffer, mymac) == 0)
if(ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0)
if(DEBUG){Serial.println( "Failed to access Ethernet controller");}
// Wait until we have an IP from the DHCP
while(!ether.dhcpSetup()){
if(DEBUG){Serial.println("Error: DHCP failed. Can't get an IP address, let's retry...");}
}
if(DEBUG){
ether.printIp("My IP: ", ether.myip);
ether.printIp("Netmask: ", ether.netmask);
ether.printIp("GW IP: ", ether.gwip);
ether.printIp("DNS IP: ", ether.dnsip);
}
if (!ether.dnsLookup(website))
if(DEBUG){Serial.println("DNS failed");}
if(DEBUG){ether.printIp("Server: ", ether.hisip);}
mySwitch.enableReceive(1); // Receiver on interrupt 1 => that is pin D3
}
void loop()
{
ether.packetLoop(ether.packetReceive());
if (mySwitch.available())
{
int value = mySwitch.getReceivedValue();
if ( mySwitch.getReceivedValue() == Door_Cuisine ) {
ether.browseUrl(PSTR("/pushingbox?devid="), IdDoorCuisine, website, my_callback);
digitalWrite(SIREN_PIN, LOW); }
if ( mySwitch.getReceivedValue() == Win_Bureau ) {
ether.browseUrl(PSTR("/pushingbox?devid="), IdWinBureau, website, my_callback);
digitalWrite(SIREN_PIN, LOW); }
if ( mySwitch.getReceivedValue() == Door_Chaufferie ) {
ether.browseUrl(PSTR("/pushingbox?devid="), IdDoorChaufferie, website, my_callback);
digitalWrite(SIREN_PIN, LOW); }
mySwitch.resetAvailable();
delay(500);
}
if ( analogRead(A0) > 500 ) {
Serial.println("A0 Garage detected. Starting eth transmission");
ether.browseUrl(PSTR("/pushingbox?devid="), IdPIRGarage, website, my_callback);
Serial.println("A0 Garage detected. Ending eth transmission");
digitalWrite(SIREN_PIN, LOW);
delay(10000); }
if ( analogRead(A1) > 500 ) {
Serial.println("A1 Abri Bois detected. Starting eth transmission");
ether.browseUrl(PSTR("/pushingbox?devid="), IdPIRGarage, website, my_callback);
Serial.println("A1 Abri Bois detected. Ending eth transmission");
digitalWrite(SIREN_PIN, LOW);
delay(10000); }
}
// 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("...");
}
Code fonctionnel avec Blynk uniquement :
#define BLYNK_PRINT Serial
#include <UIPEthernet.h>
#include <BlynkSimpleUIPEthernet.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "*/*/*/*/*/*/*/*/*/*/*/*/*/*/";
EthernetClient client;
int state = 0;
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth);
// You can also specify server:
//Blynk.begin(auth, "blynk-cloud.com", 8442);
//Blynk.begin(auth, IPAddress(192,168,1,100), 8442);
}
void loop()
{
Blynk.run();
}
BLYNK_WRITE(V1) // Canal de modification de l'état
{
int V1Data = param.asInt();
Blynk.virtualWrite(V0,"CONTROL");
delay(1000);
if (V1Data == 0) state = 0;
if (V1Data == 1) state = 1;
if (V1Data == 2) state = 2;
}
BLYNK_WRITE(V2) // Canal d'actualisation de l'état
{
int V2Data = param.asInt();
Blynk.virtualWrite(V0,"REFRESH");
delay(500);
if (state == 0) {
Blynk.virtualWrite(V0,"Off (Veille)");
Blynk.virtualWrite(V1,0);
Blynk.virtualWrite(V4,"Ready");
Blynk.virtualWrite(V11,0);
Blynk.virtualWrite(V12,0);
}
if (state == 1) {
Blynk.virtualWrite(V0,"Mode Complet");
Blynk.virtualWrite(V1,1);
Blynk.virtualWrite(V4,"OK");
Blynk.virtualWrite(V11,255);
Blynk.virtualWrite(V12,0);
}
if (state == 2) {
Blynk.virtualWrite(V0,"Mode Partiel");
Blynk.virtualWrite(V1,2);
Blynk.virtualWrite(V4,"OK");
Blynk.virtualWrite(V11,0);
Blynk.virtualWrite(V12,255);
}
if (state == 3) {
Blynk.virtualWrite(V0,"Mode Nuit");
Blynk.virtualWrite(V1,0);
Blynk.virtualWrite(V4,"OK");
Blynk.virtualWrite(V11,0);
Blynk.virtualWrite(V12,0);
}
}
BLYNK_WRITE(V3) // Canal de programmation de nuit
{
int V3Data = param.asInt();
if (V3Data == 0) state = 0;
if (V3Data == 1) state = 3;
}

