Ajout d'inclusion conditionnelle de l'object LoRaRadio
This commit is contained in:
parent
f33ed415a8
commit
e7919dfee5
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Cet exemple correspond à l'application de test de la bibliothèque MeasureUnit qui
|
* Cet exemple correspond à l'application de test de la bibliothèque MeasureUnit qui
|
||||||
* permet de calculer la température mesurée par une matrice de thermistance
|
* permet de calculer la température qui est fonction de la résistance d'une matrice de thermistance
|
||||||
*
|
*
|
||||||
* Anatole SCHRAMM-HENRY
|
* Anatole SCHRAMM-HENRY
|
||||||
* 17/12/2019
|
* 17/12/2019
|
||||||
@ -9,31 +9,62 @@
|
|||||||
#include "MeasureUnit.h"
|
#include "MeasureUnit.h"
|
||||||
#include "PayloadFormatter.h"
|
#include "PayloadFormatter.h"
|
||||||
#include "Ads1115.h"
|
#include "Ads1115.h"
|
||||||
|
#include "LoRaRadio.h"
|
||||||
|
|
||||||
|
//#define RADIO_ENABLED
|
||||||
|
|
||||||
uint8_t analogInput[] = {0,1,2,3,4,5,6,7};
|
uint8_t analogInput[] = {0,1,2,3,4,5,6,7};
|
||||||
double *tempArray = NULL;
|
double *tempArray = NULL;
|
||||||
|
|
||||||
//Objet de calcule de la temperature
|
//Objet de calcule de la temperature
|
||||||
ThermistorSetting thermistorSetting(3380, 10000);
|
//ThermistorSetting thermistorSetting(3380, 10000);
|
||||||
|
ThermistorSetting thermistorSetting(3650, 470);
|
||||||
//AdcSetting adcSetting(3300.0, 12, 310, 3);
|
//AdcSetting adcSetting(3300.0, 12, 310, 3);
|
||||||
AdcSetting adcSetting(3410.0, 15, 6, 10);//6, 10);
|
AdcSetting adcSetting(3298.13, 15, 6, 10);//6, 10);
|
||||||
Ads1115 adc;
|
Ads1115 adc;
|
||||||
MeasureUnit measureUnit(analogInput, 8, 990, thermistorSetting, adc);
|
//MeasureUnit measureUnit(analogInput, 8, 990, thermistorSetting, adc);
|
||||||
|
MeasureUnit measureUnit(analogInput, 8, 99, thermistorSetting, adc);
|
||||||
//Objet de création des trames LoRa
|
//Objet de création des trames LoRa
|
||||||
PayloadFormatter payloadFormatter(2,4);
|
PayloadFormatter payloadFormatter(2,4);
|
||||||
DateTime payloadDate(2020,12,26,8,42);
|
DateTime payloadDate(2020,12,26,8,42);
|
||||||
|
|
||||||
boolean data(false);
|
boolean data(false);
|
||||||
uint8_t *payload(NULL);
|
uint8_t *payload(NULL), _timeCounter(0), size(0), _channel(0);
|
||||||
boolean calibrer(false);
|
boolean calibrer(false);
|
||||||
unsigned long _time(millis());
|
unsigned long _time(0);
|
||||||
|
/*
|
||||||
|
* Radio Part
|
||||||
|
*/
|
||||||
|
void os_getArtEui (u1_t* buf) { }
|
||||||
|
void os_getDevEui (u1_t* buf) { }
|
||||||
|
void os_getDevKey (u1_t* buf) { }
|
||||||
|
void onEvent(ev_t ev)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static u1_t NWKSKEY[16] = { 0x1F, 0x9E, 0xE2, 0x7A, 0xC8, 0xBA, 0xE8, 0xEA, 0xF5, 0xC2, 0x5E, 0x47, 0x5D, 0xE0, 0x77, 0x55 };
|
||||||
|
static u1_t APPSKEY[16] = { 0x3B, 0x89, 0x86, 0x96, 0xBB, 0xAA, 0x38, 0x1E, 0x1F, 0xC4, 0xAD, 0x03, 0xEF, 0x3F, 0x56, 0x12 };
|
||||||
|
static u4_t DEVADDR = 0x260113D3;//0x03FF0001 ; // <-- Change this address for every node!
|
||||||
|
|
||||||
|
u1_t dio[3] = {26,33,32};
|
||||||
|
PinMap pinMap(18, LMIC_UNUSED_PIN, 14, dio);
|
||||||
|
LoRaRadio radio(pinMap);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
Serial.println("Start setup");
|
Serial.println("Start setup");
|
||||||
|
//Radio init
|
||||||
|
#ifdef RADIO_ENABLED
|
||||||
|
radio.init();
|
||||||
|
radio.setTTNSession(0x1, DEVADDR, NWKSKEY, APPSKEY);
|
||||||
|
radio.setRadioEUChannels();
|
||||||
|
#endif
|
||||||
|
//Adc init
|
||||||
adc.setAdcSetting(adcSetting);
|
adc.setAdcSetting(adcSetting);
|
||||||
//measureUnit.setGlobalTempOffset(-17);
|
//measureUnit.setGlobalTempOffset(-17);
|
||||||
|
_time = millis();
|
||||||
Serial.println("End setup");
|
Serial.println("End setup");
|
||||||
|
|
||||||
Serial.println("| T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 |");
|
Serial.println("| T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 |");
|
||||||
@ -41,14 +72,16 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
//Version synchrone
|
//Version synchrone (bloquante)
|
||||||
//tempArray = measureUnit.getTemperatures();
|
//tempArray = measureUnit.getTemperatures();
|
||||||
|
|
||||||
//Version asynchrone :
|
//Version asynchrone :
|
||||||
measureUnit.startTemperatureMeasurement();
|
measureUnit.startTemperatureMeasurement();
|
||||||
|
|
||||||
//On peut tester si la conversion est terminée avec :
|
//On peut tester si la conversion est terminée avec :
|
||||||
//if(measureUnit.isMeasurementReady())
|
//if(measureUnit.isMeasurementReady())
|
||||||
|
|
||||||
|
//measureUnit.getAsyncTemperatures() renvoie NULL si la recupération de la température n'est pas terminée
|
||||||
tempArray = measureUnit.getAsyncTemperatures();
|
tempArray = measureUnit.getAsyncTemperatures();
|
||||||
|
|
||||||
if(tempArray != NULL)
|
if(tempArray != NULL)
|
||||||
@ -68,7 +101,7 @@ void loop() {
|
|||||||
|
|
||||||
//On affiche la trame associée:
|
//On affiche la trame associée:
|
||||||
payloadFormatter.startSession(1);
|
payloadFormatter.startSession(1);
|
||||||
uint8_t size = payloadFormatter.buildPayload(&payload, &payloadDate,tempArray);
|
size = payloadFormatter.buildPayload(&payload, &payloadDate,tempArray);
|
||||||
if(size != 0)
|
if(size != 0)
|
||||||
{
|
{
|
||||||
//Serial.print("LoRa packet --> ");Serial.print("size : ");Serial.print(size);Serial.println(" bytes");
|
//Serial.print("LoRa packet --> ");Serial.print("size : ");Serial.print(size);Serial.println(" bytes");
|
||||||
@ -80,26 +113,30 @@ void loop() {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
Serial.print("Failed to build LoRa packet");
|
Serial.print("Failed to build LoRa packet");
|
||||||
/*if(payloadFormatter.endSession())
|
//if(payloadFormatter.endSession())
|
||||||
Serial.println("Session ended successfully");*/
|
//Serial.println("Session ended successfully");
|
||||||
|
|
||||||
|
#ifdef RADIO_ENABLED
|
||||||
|
if(_timeCounter == 30 && size != 0)
|
||||||
|
{
|
||||||
|
_timeCounter = 0;
|
||||||
|
Serial.printf("Sending data\n");
|
||||||
|
radio.send(1, payload, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
_timeCounter++;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//On effectue la calibration
|
//On effectue la calibration
|
||||||
if(millis() - _time > 5000 && !calibrer)
|
/*if(millis() - _time > 5000 && !calibrer)
|
||||||
{
|
{
|
||||||
Serial.println("********************Starting calibration********************");
|
Serial.println("********************Starting calibration********************");
|
||||||
measureUnit.levelAsyncTemperaturesOff();
|
measureUnit.levelAsyncTemperaturesOff();
|
||||||
Serial.println("********************Ending calibration********************");
|
Serial.println("********************Ending calibration********************");
|
||||||
calibrer = true;
|
calibrer = true;
|
||||||
}
|
}*/
|
||||||
|
#ifdef RADIO_ENABLED
|
||||||
if(Serial.available())
|
radio.run();
|
||||||
{
|
#endif
|
||||||
if(Serial.read() == 'c')
|
|
||||||
{
|
|
||||||
//Serial.println("********************Starting calibration********************");
|
|
||||||
measureUnit.levelAsyncTemperaturesOff();
|
|
||||||
//Serial.println("********************Ending calibration********************");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user