Décodage station météo LIDL AURIOL H13726A

Station météo LIDL Auriol h13726a-Ventus w155-HAMA EWS 1500 Etc…

Based on http://www.tfd.hu/tfdhu/files/wsprotocol/auriol_protocol_v20.pdf,

(Pas le choix, avec quelques erreurs mais le mérite d’avoir fait la démarche)

Matériel chez SeeedStudio (Très long 3 semaines d’attente pour chaque commande chinoise, autant grouper, mais souvent innovateurs) :

Platine complète, charge solaire/usb, liaisons grove (sans le proc) :

http://www.seeedstudio.com/depot/wireless-sensor-node-solar-kit-p-919.html

Choix d’une liaison Wifi (wishield lib modifiée), chère mais efficace, intègre le 328P :

http://www.seeedstudio.com/depot/wifi-bee-p-823.html?cPath=139_141

Choix le plus simple pour les trames 433Mhz (mais de mauvaise qualité, soudures à vomir et comme limité à 3.3V par la platine grove… efficace à 5m au mieux) :

http://www.seeedstudio.com/depot/grove-433mhz-simple-rf-link-kit-p-1062.html

Ce code diffère de tout les autres car j’utilise l’interruption (int1) sur laquelle est branché le récepteur 433, ainsi que certaines astuces… :

Qu’est-ce que pt.h ? Une librairie utilisée pour du pseudo multitâche sur un arduino

Qu’est-ce qu’un nibble ? un demi byte… 4 bits donc

#include "pt.h"

#define SET_NIBBLE(hi, lo) ((hi << 4) | lo)
/* -------------------------------------------------------- */
/* ---- 433 API ---- */
/* -------------------------------------------------------- */
/* Receiver pinmap */
const byte RF_RX_SIG = 3;
/* ISR routines variables */
unsigned long current_time, relative_time, last_time = 0;
byte ext = 36;
static struct pt pt1;
boolean trame_triggered;
volatile byte count = 0;
boolean lastA = false;
byte nobits = 0;
byte N[10];
byte ID;
byte n = 0;
byte stepper = 0;
boolean CHK_COMB, CHK_RAIN;
boolean Atemp, AwinA, AwinG, Arain = false;
/**
 * ISR RF frame decoding routine
 */
unsigned int LastAvg, LastGust, LastDir, LastRain = 0;
int LastTemp, LastHum = 0;
//void isr_decoding_routine(void) {
ISR(INT1_vect) {
 current_time = millis();
 relative_time = current_time - last_time;
 last_time = current_time;
trame_triggered = false;

 if (relative_time==9 || relative_time==10) {
 n = 0;
 //for(int i = 0; i < 10; i++) N[i] = 0x00;
 //memset(N,0x00,sizeof(N));// pas de memset sur un microcontrolleur
 //byte N[10] = {0};
 stepper = 0;
 nobits=0;
 lastA = true;
 return;
 }
if(lastA) {
 if (relative_time==2 || relative_time==3) {
 if (stepper == 4) {
 stepper=0;
 n++;
 }
 N[n] &= ~(1 << stepper++);
 nobits++;
 }
 else if (relative_time==4 || relative_time==5) {
 if (stepper == 4) {
 stepper=0;
 n++;
 }
 N[n] |= (1 << stepper++);
 nobits++;
 }
if (36 == nobits ) {
 //Serial.println("TRAME");
 lastA = false;
 ID = SET_NIBBLE(N[1], N[0]);
 //ID = N[0] + N[1]*16;
 if((N[8] == ((0x7 + N[0] + N[1] + N[2] + N[3] + N[4] + N[5] + N[6] + N[7]) & 0xF)) && ID == 134) {
 if (SET_NIBBLE(N[3], N[2]) & 0x36) {
 LastRain = (SET_NIBBLE(N[5], N[4]) + N[6]*256 + N[7]*4096);
 trame_triggered = true;
 return;
 }
 }
 else if ((N[8] == ((0xF - N[0] - N[1] - N[2] - N[3] - N[4] - N[5] - N[6] - N[7]) & 0xF)) && ID == 226) {
 if (6 ==(N[2] & 6) {
 if (N[3] == 1) {
 LastAvg = SET_NIBBLE(N[7], N[6]); //(N[6] + N[7]*16);
 //trame_triggered = true; //No, waiting for gust and dir
 }
 else if ((N[3] == 7) || (N[3] == 15)) { //246-118 0xF6-0x76
 LastGust = SET_NIBBLE(N[7], N[6]);
 LastDir = (N[4]*2 + N[5]*32 + bitRead(N[3], 3));
 trame_triggered = true;
 return;
 }
 }
 else {
 LastTemp = (SET_NIBBLE(N[4], N[3]) + N[5]*256);
 LastHum = (N[6] + N[7]*10);
 trame_triggered = true;
 return;
 }
 }
 }
 }
}

boolean sendstatus(char* URL) {
 Serial.print(F(" ID "));
 Serial.print(ID);
Serial.print(F(" WIND AVG "));
 Serial.print(LastAvg);
Serial.print(F(" GUST "));
 Serial.print(LastGust);
Serial.print(F(" DIR "));
 Serial.print(LastDir);
Serial.print(F(" TEMP "));
 Serial.print(LastTemp);
Serial.print(F(" HUM "));
 Serial.print(LastHum);
Serial.print(F(" RAIN "));
 Serial.println(LastRain);
}
static int thread1( struct pt *pt, boolean trigger ) {
PT_BEGIN( pt );
 //while(1) {
 PT_WAIT_UNTIL( pt, trigger && 36==nobits/* && frame_time > 100*/);
EIMSK&=~(1<<INT1); // mask Interrupt 1

 sendstatus("PT");
 nobits=0;
 frame_time = 0;
 trigger = false;

 EIMSK|=(1<<INT1); // unmask Interrupt 1
//}
PT_END( pt );
}
void setup()
{
 PT_INIT( &pt1 );
 Serial.begin(115200);
 Serial.println(F("PP 433 sniffer v10_NEWISR"));
 pinMode(RF_RX_SIG, INPUT_PULLUP);
// attachInterrupt(1, isr_decoding_routine, FALLING);
EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (FALLING << ISC10);
 EIMSK |= (1 << INT1);
}
void loop()
{
 thread1(&pt1, trame_triggered);
}

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *