Hi there,
I'm attempting to connect my Arduino Nano 33 IOT to my mobile phone using a BLE extension. I am able to connect to my Nano using LightBlue, and do the basic LED example (turning it on when writing a number other then 0). However, I can't seem to find the Arduino using the App that I have made. The final idea is to be able to plot the readings from a load cell connected to the Arduino. I can get a reading using a different piece of code, just unable to send it over to my phone.
#include <ArduinoBLE.h>
// Arduino With Load Cell
// Put 2 loads on load cell that that have a known mass, take the readings from both loads
float aR = 353;
float aL = 0; // kg
float bR = 1023;
float bL = 50; // kg
BLEService weightService("415a09a2-b4f1-4175-9cbc-d60171a4b178"); // BLE weight Service
// BLE weight Characteristic - custom 128-bit UUID, read and writable by central
BLEByteCharacteristic weightCharacteristic("415a09a3-b4f1-4175-9cbc-d60171a4b178", BLERead | BLEWrite);
// Arduino With Load Cell
long time = 0; // Set time to 0
int interval = 100; // Take a reading every 100 ms
void setup() {
Serial.begin(9600);
while (!Serial);
// begin initialization
if (!BLE.begin()) {
Serial.println("starting BLE failed!");
while (1);
}
// set advertised local name and service UUID:
BLE.setLocalName("Arduino");
BLE.setAdvertisedService(weightService);
// add the characteristic to the service
weightService.addCharacteristic(weightCharacteristic);
// add service
BLE.addService(weightService);
// set the initial value for the characeristic:
weightCharacteristic.writeValue(0);
// start advertising
BLE.advertise();
Serial.println("BLE Active");
}
void loop() {
float curReading = analogRead(0); // Take reading of analog pin 0 of Arduino
float load = ((bL - aL)/(bR - aR)) * (curReading - aR) + aL;
// using serial.print, we can send the data in a 'text' format
Serial.print(load);
delay(100);
}
If anyone has any idea, I'd very much appreciate the help. I've looked at similar projects but none that I've found I can use to help my problem.
Thanks! Any questions, just ask.