05-05-2022, 07:50 PM
Hi there,
I am using the Nano 33 BLE board to receive accelerometer data to upload onto 3 separate channels. However I am unable to do so, because whenever I write code for the lsm9ds1 my phone cannot find my Arduino via bluetooth. It just doesn't show up. When I write my own code I am able to connect to my Arduino and display two separate channels. I have included my code below, if possible could someone help guide me towards the solution? Thank you so much
Code:
#include <phyphoxBle.h>
#include <Arduino_LSM9DS1.h>
void setup() {
Serial.begin(115200);
PhyphoxBLE:tart("Experiment");
//Experiment
PhyphoxBleExperiment Experiment; //generate experiment on Arduino which plot random values
Experiment.setTitle("Experiment");
Experiment.setCategory("Arduino Experiments");
//View
PhyphoxBleExperiment::View firstView;
firstView.setLabel("FirstView"); //Create a "view"
PhyphoxBleExperiment::View secondView;
secondView.setLabel("SecondView"); //Create a "view"
PhyphoxBleExperiment::View thirdView;
thirdView.setLabel("ThirdView"); //Create a "view"
//First Graph
PhyphoxBleExperiment::Graph xGraph; //Create graph which will plot random numbers over time
xGraph.setLabel("Graphing x-acceleration");
xGraph.setUnitX("s");
xGraph.setUnitY("m/s/s");
xGraph.setLabelX("time");
xGraph.setLabelY("x-acceleration");
xGraph.setColor("FF0000"); //Sets Color of line
/* Assign Channels, so which data is plotted on x or y axis
first parameter represents x-axis, second y-axis
Channel 0 means a timestamp is created after the BLE package arrives in phyphox
Channel 1 to N corresponding to the N-parameter which is written in server.write()
*/
xGraph.setChannel(0, 1);
//Second Graph
PhyphoxBleExperiment::Graph yGraph; //Create graph which will plot random numbers over time
yGraph.setLabel("Graphing y-acceleration");
yGraph.setUnitX("s");
yGraph.setUnitY("m/s/s");
yGraph.setLabelX("time");
yGraph.setLabelY("y-acceleration");
yGraph.setColor("00FF00"); //Sets Color of line
/* Assign Channels, so which data is plotted on x or y axis
first parameter represents x-axis, second y-axis
Channel 0 means a timestamp is created after the BLE package arrives in phyphox
Channel 1 to N corresponding to the N-parameter which is written in server.write()
*/
yGraph.setChannel(0, 2);
//Third Graph
PhyphoxBleExperiment::Graph zGraph; //Create graph which will plot random numbers over time
zGraph.setLabel("Graphing z-acceleration");
zGraph.setUnitX("s");
zGraph.setUnitY("m/s/s");
zGraph.setLabelX("time");
zGraph.setLabelY("z-acceleration");
zGraph.setColor("0000FF"); //Sets Color of line
/* Assign Channels, so which data is plotted on x or y axis
first parameter represents x-axis, second y-axis
Channel 0 means a timestamp is created after the BLE package arrives in phyphox
Channel 1 to N corresponding to the N-parameter which is written in server.write()
*/
zGraph.setChannel(0, 3);
//Info
PhyphoxBleExperiment::InfoField myInfo; //Creates an info-box.
myInfo.setInfo("In this view you can set a value between 1 and 10. The squared random value will be multiplied by this value and can be seen here.");
//myInfo.setColor("404040"); //Sets font color. Uses a 6 digit hexadecimal value in "quotation marks".
myInfo.setXMLAttribute("size=\"1.2\"");
//Separator
PhyphoxBleExperiment::Separator mySeparator; //Creates a line to separate elements.
mySeparator.setHeight(0.3); //Sets height of the separator.
mySeparator.setColor("404040"); //Sets color of the separator. Uses a 6 digit hexadecimal value in "quotation marks".
//Value
PhyphoxBleExperiment::Value myValue; //Creates a value-box.
myValue.setLabel("Number"); //Sets the label
myValue.setPrecision(2); //The amount of digits shown after the decimal point.
myValue.setUnit("u"); //The physical unit associated with the displayed value.
myValue.setColor("FFFFFF"); //Sets font color. Uses a 6 digit hexadecimal value in "quotation marks".
myValue.setChannel(3);
myValue.setXMLAttribute("size=\"2\"");
//Edit
PhyphoxBleExperiment::Edit myEdit;
myEdit.setLabel("Editfield");
myEdit.setUnit("u");
myEdit.setSigned(false);
myEdit.setDecimal(false);
myEdit.setChannel(1);
myEdit.setXMLAttribute("max=\"10\"");
//Export
PhyphoxBleExperiment::ExportSet mySet; //Provides exporting the data to excel etc.
mySet.setLabel("mySet");
PhyphoxBleExperiment::ExportData myData1;
myData1.setLabel("myData1");
myData1.setDatachannel(1);
PhyphoxBleExperiment::ExportData myData2;
myData2.setLabel("myData2");
myData2.setDatachannel(2);
PhyphoxBleExperiment::ExportData myData3;
myData3.setLabel("myData3");
myData3.setDatachannel(3);
//attach to experiment
firstView.addElement(xGraph); //attach graph to view
firstView.addElement(yGraph); //attach second graph to view
firstView.addElement(zGraph);
secondView.addElement(myInfo); //attach info to view
secondView.addElement(mySeparator); //attach separator to view
secondView.addElement(myValue); //attach value to view
secondView.addElement(myEdit); //attach editfield to view (Linked to value)
thirdView.addElement(myInfo); //attach info to view
thirdView.addElement(mySeparator); //attach separator to view
thirdView.addElement(myValue); //attach value to view
thirdView.addElement(myEdit); //attach editfield to view (Linked to value)
Experiment.addView(firstView); //attach view to experiment
Experiment.addView(secondView);
Experiment.addView(thirdView);
mySet.addElement(myData1); //attach data to exportSet
mySet.addElement(myData2); //attach data to exportSet
mySet.addElement(myData3);
Experiment.addExportSet(mySet); //attach exportSet to experiment
PhyphoxBLE::addExperiment(Experiment); //attach experiment to server
}
void loop() {
float x, y, z;
IMU.readAcceleration(x, y, z);
PhyphoxBLE::write(x, y, z);
delay(1);
}
I am using the Nano 33 BLE board to receive accelerometer data to upload onto 3 separate channels. However I am unable to do so, because whenever I write code for the lsm9ds1 my phone cannot find my Arduino via bluetooth. It just doesn't show up. When I write my own code I am able to connect to my Arduino and display two separate channels. I have included my code below, if possible could someone help guide me towards the solution? Thank you so much
Code:
#include <phyphoxBle.h>
#include <Arduino_LSM9DS1.h>
void setup() {
Serial.begin(115200);
PhyphoxBLE:tart("Experiment");
//Experiment
PhyphoxBleExperiment Experiment; //generate experiment on Arduino which plot random values
Experiment.setTitle("Experiment");
Experiment.setCategory("Arduino Experiments");
//View
PhyphoxBleExperiment::View firstView;
firstView.setLabel("FirstView"); //Create a "view"
PhyphoxBleExperiment::View secondView;
secondView.setLabel("SecondView"); //Create a "view"
PhyphoxBleExperiment::View thirdView;
thirdView.setLabel("ThirdView"); //Create a "view"
//First Graph
PhyphoxBleExperiment::Graph xGraph; //Create graph which will plot random numbers over time
xGraph.setLabel("Graphing x-acceleration");
xGraph.setUnitX("s");
xGraph.setUnitY("m/s/s");
xGraph.setLabelX("time");
xGraph.setLabelY("x-acceleration");
xGraph.setColor("FF0000"); //Sets Color of line
/* Assign Channels, so which data is plotted on x or y axis
first parameter represents x-axis, second y-axis
Channel 0 means a timestamp is created after the BLE package arrives in phyphox
Channel 1 to N corresponding to the N-parameter which is written in server.write()
*/
xGraph.setChannel(0, 1);
//Second Graph
PhyphoxBleExperiment::Graph yGraph; //Create graph which will plot random numbers over time
yGraph.setLabel("Graphing y-acceleration");
yGraph.setUnitX("s");
yGraph.setUnitY("m/s/s");
yGraph.setLabelX("time");
yGraph.setLabelY("y-acceleration");
yGraph.setColor("00FF00"); //Sets Color of line
/* Assign Channels, so which data is plotted on x or y axis
first parameter represents x-axis, second y-axis
Channel 0 means a timestamp is created after the BLE package arrives in phyphox
Channel 1 to N corresponding to the N-parameter which is written in server.write()
*/
yGraph.setChannel(0, 2);
//Third Graph
PhyphoxBleExperiment::Graph zGraph; //Create graph which will plot random numbers over time
zGraph.setLabel("Graphing z-acceleration");
zGraph.setUnitX("s");
zGraph.setUnitY("m/s/s");
zGraph.setLabelX("time");
zGraph.setLabelY("z-acceleration");
zGraph.setColor("0000FF"); //Sets Color of line
/* Assign Channels, so which data is plotted on x or y axis
first parameter represents x-axis, second y-axis
Channel 0 means a timestamp is created after the BLE package arrives in phyphox
Channel 1 to N corresponding to the N-parameter which is written in server.write()
*/
zGraph.setChannel(0, 3);
//Info
PhyphoxBleExperiment::InfoField myInfo; //Creates an info-box.
myInfo.setInfo("In this view you can set a value between 1 and 10. The squared random value will be multiplied by this value and can be seen here.");
//myInfo.setColor("404040"); //Sets font color. Uses a 6 digit hexadecimal value in "quotation marks".
myInfo.setXMLAttribute("size=\"1.2\"");
//Separator
PhyphoxBleExperiment::Separator mySeparator; //Creates a line to separate elements.
mySeparator.setHeight(0.3); //Sets height of the separator.
mySeparator.setColor("404040"); //Sets color of the separator. Uses a 6 digit hexadecimal value in "quotation marks".
//Value
PhyphoxBleExperiment::Value myValue; //Creates a value-box.
myValue.setLabel("Number"); //Sets the label
myValue.setPrecision(2); //The amount of digits shown after the decimal point.
myValue.setUnit("u"); //The physical unit associated with the displayed value.
myValue.setColor("FFFFFF"); //Sets font color. Uses a 6 digit hexadecimal value in "quotation marks".
myValue.setChannel(3);
myValue.setXMLAttribute("size=\"2\"");
//Edit
PhyphoxBleExperiment::Edit myEdit;
myEdit.setLabel("Editfield");
myEdit.setUnit("u");
myEdit.setSigned(false);
myEdit.setDecimal(false);
myEdit.setChannel(1);
myEdit.setXMLAttribute("max=\"10\"");
//Export
PhyphoxBleExperiment::ExportSet mySet; //Provides exporting the data to excel etc.
mySet.setLabel("mySet");
PhyphoxBleExperiment::ExportData myData1;
myData1.setLabel("myData1");
myData1.setDatachannel(1);
PhyphoxBleExperiment::ExportData myData2;
myData2.setLabel("myData2");
myData2.setDatachannel(2);
PhyphoxBleExperiment::ExportData myData3;
myData3.setLabel("myData3");
myData3.setDatachannel(3);
//attach to experiment
firstView.addElement(xGraph); //attach graph to view
firstView.addElement(yGraph); //attach second graph to view
firstView.addElement(zGraph);
secondView.addElement(myInfo); //attach info to view
secondView.addElement(mySeparator); //attach separator to view
secondView.addElement(myValue); //attach value to view
secondView.addElement(myEdit); //attach editfield to view (Linked to value)
thirdView.addElement(myInfo); //attach info to view
thirdView.addElement(mySeparator); //attach separator to view
thirdView.addElement(myValue); //attach value to view
thirdView.addElement(myEdit); //attach editfield to view (Linked to value)
Experiment.addView(firstView); //attach view to experiment
Experiment.addView(secondView);
Experiment.addView(thirdView);
mySet.addElement(myData1); //attach data to exportSet
mySet.addElement(myData2); //attach data to exportSet
mySet.addElement(myData3);
Experiment.addExportSet(mySet); //attach exportSet to experiment
PhyphoxBLE::addExperiment(Experiment); //attach experiment to server
}
void loop() {
float x, y, z;
IMU.readAcceleration(x, y, z);
PhyphoxBLE::write(x, y, z);
delay(1);
}