Hi everyone,
I'm using Evothings to link a RFduino with my phone, and I just want to send a numeric data via BLE. So I write rfduinoble.send(myNumber); in Arduino but I don't know what to write in javascript to get this number...
I'm a newbie, can you please help me ?
Thanks you !
RFduino to Javascript
Re: RFduino to Javascript
I'm afraid you're out of luck for the moment; the rfduino library does not have a "read" or "onIncomingData" function yet.
Such a function could probably be added, but it will require some skill with Javascript and BLE.
Such a function could probably be added, but it will require some skill with Javascript and BLE.
Re: RFduino to Javascript
Hmmm, I had written a response to this but must have forgoten to hit Submit...
Check out the work done by marc.graham in this thread.
In that thread I note that I had also successfully read data from the RFduino by modifying the the Arduino BLE example app (based on the RedBearLabs BLE Shield, not the RFduino), but I would check out Marc's library first.
Don
Check out the work done by marc.graham in this thread.
In that thread I note that I had also successfully read data from the RFduino by modifying the the Arduino BLE example app (based on the RedBearLabs BLE Shield, not the RFduino), but I would check out Marc's library first.
Don
Re: RFduino to Javascript
Thank you very much DonPancoe, your work seems really interesting. I'll try this out this week-end and I'll give you a feedback !
Re: RFduino to Javascript
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 :
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 :
and this script :
But nothing happens. Have you any idea why ?
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 ?
Return to “Questions and answers”
Who is online
Users browsing this forum: No registered users and 37 guests