EDIT : I don't know why but now it works ! To improve the code, I replaced getUint16() by getFloat32() in JS and sentInt() by sentFloat() in arduino and now I have my tension with a good precision. 
Hi,
So I tried to change your code and Marc's one, but something is going wrong and I can't figure out what is the problem. Here is my arduino code :
Code: Select all
#include <RFduinoBLE.h>
// le potentiomètre, branché sur la broche analogique 0
const int potar = 2;
const int led = 6;
//variable pour stocker la valeur lue après conversion
int valeurLue;
//on convertit cette valeur en une tension
int tension;
void setup()
{
    pinMode(led, OUTPUT);
    RFduinoBLE.begin();
}
void loop()
{
    //on convertit en nombre binaire la tension lue en sortie du potentiomètre
    valeurLue = analogRead(potar);
    
    //on traduit la valeur brute en tension (produit en croix)
    tension = valeurLue * 3.0 / 1024;
    
    if (tension < 2)
    {
    digitalWrite(led, LOW);
    
    }
    else
    {
    digitalWrite(led, HIGH);
    }
    RFduinoBLE.sendInt(tension);
    delay(500);
}This one works alone. Now I want to get the value of 'tension' in my evothings app, so I changed the 'RFduino LED ON/OFF' example by adding a button :
Code: Select all
<button id="readcounter" type="button" class="green" onclick="app.readCount()">and this script :
Code: Select all
app.readCount = function()
   {
      app.device.readCharacteristic(
         '00002221-0000-1000-8000-00805f9b34fb',
         function(data){
            app.showMessage([new DataView(data).getUint16(0, true)]);
         },
         function(errorCode)
         {
            app.showMessage("Connect error: " + errorCode);
         }
      );   
   };   But nothing happens. Have you any idea why ?