FOURNET Olivier / Mbed 2 deprecated WIZwiki-W7500_ADC

Dependencies:   SDFileSystem STATIC_COLORS WIZnetInterface mbed

Files at this revision

API Documentation at this revision

Comitter:
Fo170
Date:
Wed Jul 13 17:39:47 2016 +0000
Parent:
6:d68dd410b141
Commit message:
modification du code pour prise en compte plus rapide des changement dans thing speak

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r d68dd410b141 -r c2acbe486cf2 main.cpp
--- a/main.cpp	Mon Jul 11 17:12:01 2016 +0000
+++ b/main.cpp	Wed Jul 13 17:39:47 2016 +0000
@@ -54,6 +54,7 @@
 //------ THING_SPEAK ------------------
 
 #define THRESHOLD_V   0.01
+float adc_v = 0.0;
 float adc_v_moy = 0.0;
 float adc_v_moy_old = 0.0;
 int ret;
@@ -82,11 +83,7 @@
   int length;
   char buffer_th[64];
   char data_entry[64]; 
-  float adc_v;
- // récupération du dernier samples de la liste et convertion en volts       
- adc_v = adc_samples[NB_SAMPLES-1] * 0.001;
- // moyenne sur 10 valeurs
- adc_v_moy = 0.1 * (9.0 * adc_v_moy + adc_v);
+  
  // active l'envoi sur THING SPEAK si l'évolution moyenne est supérieure au seuil désiré
  if((abs(adc_v_moy - adc_v_moy_old) >= THRESHOLD_V))
  {
@@ -189,8 +186,12 @@
  
  // mesures ADC
     meas = ain0.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
+    // valeur instantanée pour Thing Speak   
+    adc_v = meas * 3.3;
     meas = meas * 3300.0; // Change the value to be in the 0 to 3300 range
-    
+    // moyenne sur 10 valeurs
+    adc_v_moy = 0.1 * (9.0 * adc_v_moy + adc_v);
+ 
     x_min = x_max = Seconds;
     y_min = y_max = meas;