I would like to send and receive data to/from nrf52832 pins over BLE using android phone. I would like to capture and display output of Force Sensing resistor and control digital potentiometers for a custom board. I am able to communicate via UART and do OTA upgrades.
This is a really strange posting.
you are rising a mega-global and unprecise question
and you are telling only a very small information about your project.
Do you expect somebody writes down a 200 pages long universal "how to use nrf52832-chips with arduino?"-tutorial?
Do you expect that somebody has a glas-sphere and can look into it what exactly
means?
best regards Stefan
My apologies.The beginning of my question did not post. My question was:
I would like to send and receive data to/from nrf52832 pins over BLE using android phone. I would like to capture and display output of Force Sensing resistor and control digital potentiometers for a custom board. I am able to communicate via UART and do OTA upgrades.
Thanks for any help.
I hope this makes more sense.
Craig H.
Might be an idea to tell the forum which part of your code, or hardware, you want help with.
I was told my original post was incomplete. Simply trying to get some help with a question. Not trying to disrupt the forum.
And so you thought posting the very exact same question would lead to a different outcome?
why don't you add more info?
like is the nrf52832 naked or is it a module ? how did you configure it , what's your setup etc...
I was replying to this response:
This is a really strange posting.
you are rising a mega-global and unprecise question
and you are telling only a very small information about your project.
Do you expect somebody writes down a 200 pages long universal "how to use nrf52832-chips with arduino?"-tutorial?
Do you expect that somebody has a glas-sphere and can look into it what exactly
I am able to communicate via UART and do OTA upgrades
means?
it's your opportunity to course correct.
read the forum's recommended practice for posting questions and document exactly what you have and what you want to do... help us help you.. or your question won't get any answer as it's too cryptic and the volunteers answering here will go help elsewhere where the OP has provided sufficient context to not waste their precious hours in guesswork...
so start there:
Thank you for your recommendation. I will resend in a more concise manner. Best regards.
don't create a new post, continue here.
I am working to access the pins on the Nordic nRF52832 using Bluetooth Low Energy for bidirectional communication on an Android Smartphone. I want to receive analog data to be displayed as numerical output and a corresponding moving graph if possible. I also want to control digital potentiometers with a slider and display the value sent to the slider on the smartphone. The unit currently connects to the Android phone and I am able to do OTA upgrades.
The code is as follows:
//#include <arduino-timer.h>
#include <bluefruit.h>
#include <Adafruit_LittleFS.h>
#include <InternalFileSystem.h>
#include <SimpleKalmanFilter.h>
#include <math.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_MCP4725.h>
//#include <elapsedMillis.h> //load the library
//elapsedMillis timeElapsed;//Create an Instance
Adafruit_MCP4725 dac;
#define DAC_RESOLUTION (7)
#define VBAT_MV_PER_LSB (0.73242188F)
// 2M + 0.806M voltage divider on VBAT = (2M / (0.806M + 2M))
#define VBAT_DIVIDER (0.71275837F)
// BLE Service
BLEDfu bledfu; // OTA DFU service
BLEDis bledis; // device information
BLEUart bleuart; // uart over ble
BLEBas blebas; // battery
// Compensation factor for the VBAT divider
#define VBAT_DIVIDER_COMP (1.403F)
SimpleKalmanFilter simpleKalmanFilter(2, 2, 0.01);
char inputString[20 + 1] = { 0 }; // a String to hold incoming data
bool stringComplete = false; // whether the string is complete
unsigned long elapsedTime = 0;
unsigned long interval = 0;
int zeroedValue = 0;
int level = 0;
unsigned int batValue = 0;
unsigned int sensorValue = 0;
unsigned int startValue = 0;
unsigned long currentMillis = 0;
unsigned long previousMillis = 0;
unsigned long currentMillis3 = 0UL;
unsigned long previousMillis3 = 0UL;
unsigned long interval3 = 0UL;
unsigned long subtract = 0UL;
int avgSensorValue;
byte address1 = 0x11;
byte address2 = 0x11;
const int CS1 = 16; //Sensitivity
const int CS2 = 15; //Intensity//
//int zeroedValue = 0;
int sensorMin = 4095; // minimum sensor value
int sensorMax = 0;
unsigned int sensorPreLoad = 0;
//int calSensorValue = 0;
//int calibrationRead = 0;
//int calLoad = 0;
//int timeStart = 0;
//boolean intenseFlag = true;
boolean calib = false;
unsigned long t_start, t_diff;
const unsigned long ULONG_MAX = pow(2, 32) - 1;
bool led_state = 0;
const PROGMEM uint16_t DACLookup_FullSine_7Bit[128] = //////this is the new 7 bit lookup table.
{
2048, 2148, 2248, 2348, 2447, 2545, 2642, 2737,
2831, 2923, 3013, 3100, 3185, 3267, 3346, 3423,
3495, 3565, 3630, 3692, 3750, 3804, 3853, 3898,
3939, 3975, 4007, 4034, 4056, 4073, 4085, 4093,
4095, 4093, 4085, 4073, 4056, 4034, 4007, 3975,
3939, 3898, 3853, 3804, 3750, 3692, 3630, 3565,
3495, 3423, 3346, 3267, 3185, 3100, 3013, 2923,
2831, 2737, 2642, 2545, 2447, 2348, 2248, 2148,
2048, 1947, 1847, 1747, 1648, 1550, 1453, 1358,
1264, 1172, 1082, 995, 910, 828, 749, 672,
600, 530, 465, 403, 345, 291, 242, 197,
156, 120, 88, 61, 39, 22, 10, 2,
0, 2, 10, 22, 39, 61, 88, 120,
156, 197, 242, 291, 345, 403, 465, 530,
600, 672, 749, 828, 910, 995, 1082, 1172,
1264, 1358, 1453, 1550, 1648, 1747, 1847, 1947
};
int pwmOut = 3; // the PWM pin the sensor is attached to 3
int outputValue;
int analogInPin = A0; // Analog input pin A0 that the sensor is attached to
int batPin = A4;
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Sensitivity/Intensity Adjustments^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
const int numReadings = 100;
//const int readings[numReadings]; // the readings from the analog input
int readings[numReadings];
int readIndex = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average
int range = 0;
int testCounter = 0;
int averagePreLoad = 0;
//int pwmOut = 3; // the PWM pin the sensor is attached to 3
int fsr = 0;
int sensorResistor = 0;
const int ledPin1 = 17;
const long interval1 = 400; //interval 1 blinking red LED
int ledState1 = LOW;
//int blinkFlag = LOW;
//int calFlag = LOW;
unsigned long currentMillis1 = 0;
unsigned long previousMillis1 = 0;
const int calButtonPin = 11; // calibration pushbutton pin ************************
int calButtonState = HIGH;
const int intenButtonPin = 7; // intensity pushbutton pin**************************
int value2 [] = {80, 150};
int cs2count = 0;
int intenButtonState = 0;
int intenButtonDebounce;
int lastSwitchState = HIGH;
int lastSwitchDebounce = LOW;
int counter = 0;
int value1;
int testing = 0;
int preLoad = 0;
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 10;
unsigned long pulsePreviousTime = 0;
unsigned long pulseEventTime = 0;
void printOutput()
{ Serial.print("intenButtonState =");
Serial.print("\t");
Serial.print(intenButtonState);
Serial.print("\t");
Serial.print("value2[cs2count] =");
Serial.print("\t");
Serial.print(value2[cs2count]);
Serial.print("\t");
Serial.print("zeroedValue =");
Serial.print("\t");
Serial.print(zeroedValue);
Serial.print("\t");
Serial.print(" interval3 = ");
Serial.print("\t");
Serial.println(interval3);
}
void digitalPotIntense() //Intensity Subroutine *****************************************
{
int currentSwitch = digitalRead(intenButtonPin);
if (currentSwitch != lastSwitchDebounce)
{
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay)
{
if (currentSwitch != lastSwitchState)
{
if (currentSwitch == LOW)
{
cs2count = cs2count + 1;
if (cs2count > 1)
{
cs2count = 0;
}
cs2count = cs2count;
}
}
lastSwitchState = currentSwitch;
}
lastSwitchDebounce = currentSwitch;
digitalWrite(CS2, LOW);
SPI.transfer(address2);
SPI.transfer(value2[cs2count]);
digitalWrite(CS2, HIGH);
}
void redBlink() //**********************************************************
{
unsigned long currentMillis1 = millis();
if (currentMillis1 - previousMillis1 >= interval1)
{
// save the last time you blinked the LED
previousMillis1 = currentMillis1;
if (ledState1 == LOW) {
ledState1 = HIGH;
} else {
ledState1 = LOW;
}
digitalWrite(ledPin1, ledState1);
return;
}
}
void sinewaveOut()
{
uint16_t i;
for (i = 0; i < 128; i++)
dac.setVoltage(pgm_read_word(&(DACLookup_FullSine_7Bit[i])), false);
return;
}
void timedWait()
{
// check to see if the interval time is passed.
redBlink();
// timeElapsed = 0; // reset the counter to 0 so the counting starts over...
unsigned long currentMillis1 = millis();
if (((currentMillis3 - previousMillis3) >= interval3))
{
previousMillis3 = currentMillis3;
// timeElapsed = 0; // reset the counter to 0 so the counting starts over...
sinewaveOut();
}
}
void senseMode() //********************************************************************************
//********************************************************************************
//********************************************************************************
{
digitalPotIntense();
sensorValue = analogRead(analogInPin); // read the analog in value;
sensorValue = simpleKalmanFilter.updateEstimate(sensorValue);
sensorValue = map(sensorValue, sensorPreLoad, 4095, 0, 4095);
zeroedValue = sensorValue;
int sensorCalibrated = sensorValue;
if (sensorValue > 4095)
{
sensorValue = 0;
}
/*
if ( zeroedValue > (sensorPreLoad -50))
{
interval3 = 2000; // 0.5 cycles/second
timedWait();
}
else if ( zeroedValue > 201 && zeroedValue <= 400)
{
interval3 = 1000; // 1 cycles/second
timedWait();
}
else if ( zeroedValue > 401 && zeroedValue <= 600)
{
interval3 = 500; // 2 cycles/second
timedWait();
}
else if ( zeroedValue > 651 && zeroedValue <= 800)
{
interval3 = 330; // 3 cycles/second
timedWait();
}
else if ( zeroedValue > 801 && zeroedValue <= 1000)
{
interval3 = 250; // 4 cycles/second
timedWait();
}
else if ( zeroedValue > 1001 && zeroedValue <= 1200)
{
interval3 = 200; // 5 cycles/second
timedWait();
}
else if ( zeroedValue > 1201 && zeroedValue <= 1400)
{
interval3 = 165; // 6 cycles/second
timedWait();
}
else if ( zeroedValue > 1401 && zeroedValue <= 1600)
{
interval3 = 143; // 7 cycles/second
timedWait();
}
else if ( zeroedValue > 1601 && zeroedValue <= 1800)
{
interval3 = 125; // 8 cycles/second
timedWait();
}
else if ( zeroedValue > 1801 && zeroedValue <= 2000)
{
interval3 = 111; // 9 cycles/second
timedWait();
}
else if ( zeroedValue > 2001 && zeroedValue <= 2200)
{
interval3 = 100; // 10 cycles/second
timedWait();
}
else if (zeroedValue > 2201 && zeroedValue <= 2400)
{
interval3 = 77; // 13 cycles/second
timedWait();
}
else if (zeroedValue > 2401 && zeroedValue <= 2600)
{
interval3 = 66; // 15 cycles/second
timedWait();
}
else if (zeroedValue > 2601 && zeroedValue <= 2800)
{
interval3 = 55; // 18 cycles/second
timedWait();
}
else if (zeroedValue > 2801 && zeroedValue <= 3000)
{
interval3 = 47; // 21 cycles/second
timedWait();
}
else if (zeroedValue > 3001 && zeroedValue <= 3200)
{
interval3 = 41; // 24 cycles/second
timedWait();
}
else if (zeroedValue > 3201 && zeroedValue <= 3400)
{
interval3 = 37; // 27 cycles/second
timedWait();
}
else if (zeroedValue > 3401 && zeroedValue <= 3600)
{
interval3 = 33; // 30 cycles/second
timedWait();
}
else if (zeroedValue > 3601 && zeroedValue <= 4000)
{
interval3 = 25; // 40 cycles/second
timedWait();
}
// else if (zeroedValue > 3801 && zeroedValue <= 4000)
// {
// interval3 = 20; // 50 cycles/second
// timedWait();
// }
else if (zeroedValue > 4001)
{
interval3 = 2; // 67 cycles/second
timedWait();
}
*/
if ( zeroedValue > 201 && zeroedValue <= 600)
{
interval3 = 1000; // 1 cycles/second
timedWait();
// Serial.println("Interval 1000");
}
else if ( zeroedValue > 601 && zeroedValue <= 1000)
{
interval3 = 500; // 2 cycles/second
timedWait();
}
else if ( zeroedValue > 1001 && zeroedValue <= 1400)
{
interval3 = 330; // 3 cycles/second
timedWait();
}
else if ( zeroedValue > 1401 && zeroedValue <= 1800)
{
interval3 = 200; // 4 cycles/second
timedWait();
}
else if ( zeroedValue > 1801 && zeroedValue <= 2200)
{
interval3 = 100; // 5 cycles/second
timedWait();
}
else if ( zeroedValue > 2201 && zeroedValue <= 2600)
{
interval3 = 66; // 6 cycles/second
timedWait();
}
else if ( zeroedValue > 2601 && zeroedValue <= 3000)
{
interval3 = 47; // 6 cycles/second
timedWait();
}
else if ( zeroedValue > 3001 && zeroedValue <= 3400)
{
interval3 = 30; // 6 cycles/second
timedWait();
}
/*
else if ( zeroedValue > 3401 && zeroedValue <= 3800)
{
interval3 = 23; // 6 cycles/second
timedWait();
}
*/
else if ( zeroedValue > 3401)
{
interval3 = 2; // 6 cycles/second
timedWait();
}
}
/*
void calComplete()
{
digitalWrite(ledPin1, HIGH);
cs2count = 0;
sensorValue = 0;
elapsedTime = 0;
sensorMin = 0;
sensorPreLoad = 0;
total = 0;
readIndex = 0;
int range = 0;
average = 0;
// blinkFlag == HIGH;
senseMode(); //go to sensing routine
}
*/
void calRoutine() /// Calibrate Sensor for pre-loading due to PFM force at rest**************
{
//Serial.println("Made it to calRoutine");
//sensorPreLoad = 123;
total = 0;
sensorValue = 0;
zeroedValue = 0;
elapsedTime = 0;
sensorMin = 0;
sensorPreLoad = 0;
int elapsedTime = 0;
int total = 0;
int readIndex = 0;
int averagePreLoad = 0;
int interval1 = 100;
for (elapsedTime = interval1; elapsedTime >= 0; elapsedTime-- )
{
redBlink();
readIndex = readIndex + 1; // advance to the next position in the array:
readings[readIndex] = analogRead(analogInPin); // read from the sensor:
total = total + readings[readIndex]; // add the reading to the total:
averagePreLoad = total / readIndex; // calculate the average:
sensorPreLoad = averagePreLoad;
// calComplete();
Serial.print(" elapsedTime = ");
Serial.print(elapsedTime);
Serial.print("\t");
Serial.print(" total = ");
Serial.print(total);
Serial.print("\t");
Serial.print(" readIndex = ");
Serial.print(readIndex);
Serial.print("\t");
Serial.print(" sensorPreLoad = ");
Serial.println(sensorPreLoad);
}
if (readIndex >= numReadings)
{
digitalWrite(ledPin1, HIGH);
readIndex = 0;
calib = true;
total = 0;
senseMode();
}
}
uint8_t mvToPercent(float mvolts) {
uint8_t battery_level;
if (mvolts >= 3000) {
battery_level = 100;
} else if (mvolts > 2900) {
battery_level = 100 - ((3000 - mvolts) * 58) / 100;
} else if (mvolts > 2740) {
battery_level = 42 - ((2900 - mvolts) * 24) / 160;
} else if (mvolts > 2440) {
battery_level = 18 - ((2740 - mvolts) * 12) / 300;
} else if (mvolts > 2100) {
battery_level = 6 - ((2440 - mvolts) * 6) / 340;
} else {
battery_level = 0;
}
return battery_level;
}
void testMode()
{
digitalPotIntense();
//sensorValue = analogRead(analogInPin); // read the analog in value;
if (testCounter % 1000 == 0)
{ sensorValue = sensorValue + 200;
sensorValue = sensorValue % 4100;
zeroedValue = sensorValue;
Serial.println(sensorValue);
testCounter = 0;
}
if ( zeroedValue > 0 && zeroedValue <= 200)
{
interval3 = 2000; // 0.5 cycles/second
timedWait();
}
else if ( zeroedValue > 201 && zeroedValue <= 400)
{
interval3 = 1000; // 1 cycles/second
timedWait();
}
else if ( zeroedValue > 401 && zeroedValue <= 600)
{
interval3 = 500; // 2 cycles/second
timedWait();
}
else if ( zeroedValue > 651 && zeroedValue <= 800)
{
interval3 = 330; // 3 cycles/second
timedWait();
}
else if ( zeroedValue > 801 && zeroedValue <= 1000)
{
interval3 = 250; // 4 cycles/second
timedWait();
}
else if ( zeroedValue > 1001 && zeroedValue <= 1200)
{
interval3 = 200; // 5 cycles/second
timedWait();
}
else if ( zeroedValue > 1201 && zeroedValue <= 1400)
{
interval3 = 165; // 6 cycles/second
timedWait();
}
else if ( zeroedValue > 1401 && zeroedValue <= 1600)
{
interval3 = 143; // 7 cycles/second
timedWait();
}
else if ( zeroedValue > 1601 && zeroedValue <= 1800)
{
interval3 = 125; // 8 cycles/second
timedWait();
}
else if ( zeroedValue > 1801 && zeroedValue <= 2000)
{
interval3 = 111; // 9 cycles/second
timedWait();
}
else if ( zeroedValue > 2001 && zeroedValue <= 2200)
{
interval3 = 100; // 10 cycles/second
timedWait();
}
else if (zeroedValue > 2201 && zeroedValue <= 2400)
{
interval3 = 77; // 13 cycles/second
timedWait();
}
else if (zeroedValue > 2401 && zeroedValue <= 2600)
{
interval3 = 66; // 15 cycles/second
timedWait();
}
else if (zeroedValue > 2601 && zeroedValue <= 2800)
{
interval3 = 55; // 18 cycles/second
timedWait();
}
else if (zeroedValue > 2801 && zeroedValue <= 3000)
{
interval3 = 47; // 21 cycles/second
timedWait();
}
else if (zeroedValue > 3001 && zeroedValue <= 3200)
{
interval3 = 41; // 24 cycles/second
timedWait();
}
else if (zeroedValue > 3201 && zeroedValue <= 3400)
{
interval3 = 37; // 27 cycles/second
timedWait();
}
else if (zeroedValue > 3401 && zeroedValue <= 3600)
{
interval3 = 33; // 30 cycles/second
timedWait();
}
else if (zeroedValue > 3601 && zeroedValue <= 3800)
{
interval3 = 30; // 33 cycles/second
timedWait();
}
else if (zeroedValue > 3801 && zeroedValue <= 4000)
{
interval3 = 27; // 36 cycles/second
timedWait();
}
else if (zeroedValue > 4001 && zeroedValue <= 4095)
{
interval3 = 2; // 67 cycles/second
timedWait();
}
testCounter++;
}
void setup(void)
{
Serial.begin(9600);
dac.begin(0x62); // For MCP4725A0 the address is 0x62
Serial.print( F("Compiled: "));
Serial.print( F(__DATE__));
Serial.print( F(", "));
Serial.println( F(__TIME__));
analogReference(AR_INTERNAL_3_0); //Allows for full 4095 analog out
analogReadResolution(12);
analogWriteResolution(10);
digitalWrite(ledPin1, HIGH);
Wire.begin();
pinMode(intenButtonPin, INPUT_PULLUP); //intensity calibration pin
//pinMode(30, INPUT_PULLUP); // timeout shutdown pin
pinMode(calButtonPin, INPUT_PULLUP); //force calibration pin
//pinMode(calButtonState, INPUT_PULLUP); //input button II
//pinMode(intenButtonState, INPUT_PULLUP); //input button III
pinMode(ledPin1, OUTPUT);
pinMode(CS1, OUTPUT); //Sensitivity Subroutine
pinMode(CS2, OUTPUT); //Intensity Subroutine
pinMode(3, OUTPUT); //FSR PWM Sensitivity Pin
digitalWrite(ledPin1, HIGH);
SPI.begin();
// Setup the BLE LED to be enabled on CONNECT
// Note: This is actually the default behaviour, but provided
// here in case you want to control this LED manually via PIN 19
Bluefruit.autoConnLed(true);
// Config the peripheral connection with maximum bandwidth
// more SRAM required by SoftDevice
// Note: All config***() function must be called before begin()
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
Bluefruit.begin();
Bluefruit.setTxPower(4); // Check bluefruit.h for supported values
Bluefruit.setName("V-Toner");
//Bluefruit.setName(getMcuUniqueID()); // useful testing with multiple central connections
Bluefruit.Periph.setConnectCallback(connect_callback);
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
// To be consistent OTA DFU should be added first if it exists
bledfu.begin();
// Configure and Start Device Information Service
bledis.setManufacturer("Adafruit Industries");
bledis.setModel("Bluefruit Feather52");
bledis.begin();
// Configure and Start BLE Uart Service
bleuart.begin();
bleuart.setRxCallback(prph_bleuart_rx_callback);
// Start BLE Battery Service
blebas.begin();
blebas.write(100);
// Set up and start advertising
startAdv();
//inputString.reserve(20);
}
void startAdv(void)
{
// Advertising packet
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
Bluefruit.Advertising.addTxPower();
// Include bleuart 128-bit uuid
Bluefruit.Advertising.addService(bleuart);
// Secondary Scan Response packet (optional)
// Since there is no room for 'Name' in Advertising packet
Bluefruit.ScanResponse.addName();
/* Start Advertising
- Enable auto advertising if disconnected
- Interval: fast mode = 20 ms, slow mode = 152.5 ms
- Timeout for fast mode is 30 seconds
- Start(timeout) with timeout = 0 will advertise forever (until connected)
For recommended advertising interval
https://developer.apple.com/library/content/qa/qa1931/_index.html
*/
Bluefruit.Advertising.restartOnDisconnect(true);
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
}
void loop()
{
if (stringComplete) { //If ble "OTA received, go into OTA mode"
if (inputString[0] == 'O' && inputString[1] == 'T' && inputString[2] == 'A')
{
Serial.print("OTA mode");
delay(100);
enterOTADfu();
}
else if (inputString[0] == 'D' && inputString[1] == 'F' && inputString[2] == 'U')
{
Serial.print("DFU mode");
delay(100);
enterSerialDfu();
}
// clear the string:
for ( int i = 0; i < sizeof(inputString); ++i )
inputString[i] = (char)0;
stringComplete = false;
}
/*
digitalPotIntense();
analogWrite (3, fsr);//fsr establishes PWM on pin 3 used to calculate top end of PFM contraction
currentMillis3 = millis();
calButtonState = digitalRead(calButtonPin);
intenButtonState = digitalRead(intenButtonPin);
sensorValue = analogRead(analogInPin); // read the analog in value;
Serial.print(" sensorValue = ");
Serial.print(sensorValue);
Serial.print("\t");
Serial.print(" calButtonState = ");
Serial.println(calButtonState);
*/
/*
if (sensorValue < 75 && calButtonState == HIGH)
{
return;
}
else if (sensorValue > 75 && calButtonState == LOW)
{
calib = false;
sensorPreLoad = 0;
calRoutine();
}
else if (sensorValue > 75 && calButtonState == HIGH)
{
senseMode();
}
*/
//88888888888888888888888888888888888888888 Sensor Calibration Adjustment Variables
int fsr = 3000; ///
int sensorResisistor = 245;
digitalWrite(CS1, LOW); //sensitivity resistor setting (220 - 254) 15kohm - 100kohm
SPI.transfer(address1);
SPI.transfer(sensorResisistor);
digitalWrite(CS1, HIGH);
digitalPotIntense();
sensorValue = analogRead(analogInPin); // read the analog in value;
//Serial.println(sensorValue);
// sensorValue = analogRead(analogInPin); // read the analog in value;
analogWrite (3, fsr);//fsr establishes PWM on pin 3 used to calculate top end of PFM contraction
currentMillis3 = millis();
calButtonState = digitalRead(calButtonPin);
intenButtonState = digitalRead(intenButtonPin);
batValue = analogRead(batPin);
batValue = mvToPercent(batValue * VBAT_MV_PER_LSB);
blebas.write(batValue);
if (testing == 0)
{
sensorValue = analogRead(analogInPin);
/*char nl ='\n';
Serial.println(uint8_t((sensorValue*255)/4095));
bleuart.write(uint8_t((sensorValue*255)/4095));
bleuart.write(nl);
delay(10);*/
//Serial.print("\t");
//Serial.println(sensorValue);
if (batValue < 20)
{
digitalWrite(ledPin1, HIGH);
}
if (sensorValue > 55 && calButtonState == LOW)
{
calib = false;
sensorPreLoad = 0;
calRoutine();
}
if (sensorValue >= sensorPreLoad)
{
sensorValue = map(sensorValue, sensorPreLoad, 4095, 0, 4095);
sensorValue = simpleKalmanFilter.updateEstimate(sensorValue);
}
else
{
sensorValue = 0;
}
if (intenButtonState == LOW)
{
digitalPotIntense();
}
else if (sensorValue >= 75 && calib == true)
{
senseMode();
}
else if (sensorValue < 75 && calButtonState == HIGH)
{
return;
}
else if (sensorValue >= 75 && calib == HIGH)
{
senseMode();
}
if (intenButtonState == LOW && calButtonState == LOW)
{
Serial.println("Test Mode Activated");
testMode();
testing = 1;
sensorValue = 0;
}
}
else
testMode();
}
void prph_bleuart_rx_callback(uint16_t conn_handle)
{
(void) conn_handle;
// Forward data from Mobile to our peripheral
//char str[20+1] = { 0 };
bleuart.read(inputString, 20);
Serial.print("[Prph] RX: ");
Serial.println(inputString);
//inputString=str;
stringComplete = true;
}
void connect_callback(uint16_t conn_handle)
{
// Get the reference to current connection
BLEConnection* connection = Bluefruit.Connection(conn_handle);
char central_name[32] = { 0 };
connection->getPeerName(central_name, sizeof(central_name));
Serial.print("Connected to ");
Serial.println(central_name);
}
/**
Callback invoked when a connection is dropped
@param conn_handle connection where this event happens
@param reason is a BLE_HCI_STATUS_CODE which can be found in ble_hci.h
*/
void disconnect_callback(uint16_t conn_handle, uint8_t reason)
{
(void) conn_handle;
(void) reason;
Serial.println();
Serial.print("Disconnected, reason = 0x"); Serial.println(reason, HEX);
}
The schematic is as follows:
Schematic-12 - Confidential.pdf (213.4 KB)
Any Insight will be appreciated.
You still don't get the point what you have to provide to get help.
Now I have the impression everything is working fine.
You have a schematic you have code that seems to work.
Point to that exact point where you have a question about!
write a SPECIFIC question!
I will SURELY NOT analyse your complete code just to find out what does not work.
YOU YOU YOU are the one that has the system build
YOU YOU YOU are the one that knows how the system should behave IN DETAIL
And YOU YOU YOU are the one that experienced a difference between what your system shall do and what it really does actually.
So it is YOU who can describe this difference and ASK a SPECIFIC question.
@the moderator: recently I looked up a thread in the italian section. Somebody asked a foggy question.
The moderator locked this user out with the words
Go reading "how to get the best out of this forum and if you have posted sended me a posting that fulfills the requirements described there I will unlock your account again.
This guy here needs such a treatment to REALLY make him read
This is a Civilized Place for Public Discussion
Please treat this discussion forum with the same respect you would a public park. We, too, are a shared community resource — a place to share skills, knowledge and interests through ongoing conversation.
These are not hard and fast rules, merely guidelines to aid the human judgment of our community and keep this a clean and well-lighted place for civilized public discourse.
Improve the Discussion
Help us make this a great place for discussion by always working to improve the discussion in some way, however small. If you are not sure your post adds to the conversation, think over what you want to say and try again later.
The topics discussed here matter to us, and we want you to act as if they matter to you, too. Be respectful of the topics and the people discussing them, even if you disagree with some of what is being said.
One way to improve the discussion is by discovering ones that are already happening. Spend time browsing the topics here before replying or starting your own, and you’ll have a better chance of meeting others who share your interests.
Be Agreeable, Even When You Disagree
You may wish to respond to something by disagreeing with it. That’s fine. But remember to criticize ideas, not people. Please avoid:
- Name-calling
- Ad hominem attacks
- Responding to a post’s tone instead of its actual content
- Knee-jerk contradiction
Instead, provide reasoned counter-arguments that improve the conversation.
Your Participation Counts
The conversations we have here set the tone for every new arrival. Help us influence the future of this community by choosing to engage in discussions that make this forum an interesting place to be — and avoiding those that do not.
Discourse provides tools that enable the community to collectively identify the best (and worst) contributions: bookmarks, likes, flags, replies, edits, and so forth. Use these tools to improve your own experience, and everyone else’s, too.
Let’s leave our community better than we found it.
If You See a Problem, Flag It
Moderators have special authority; they are responsible for this forum. But so are you. With your help, moderators can be community facilitators, not just janitors or police.
When you see bad behavior, don’t reply. It encourages the bad behavior by acknowledging it, consumes your energy, and wastes everyone’s time. Just flag it. If enough flags accrue, action will be taken, either automatically or by moderator intervention.
In order to maintain our community, moderators reserve the right to remove any content and any user account for any reason at any time. Moderators do not preview new posts; the moderators and site operators take no responsibility for any content posted by the community.
Always Be Civil
Nothing sabotages a healthy conversation like rudeness:
- Be civil. Don’t post anything that a reasonable person would consider offensive, abusive, or hate speech.
- Keep it clean. Don’t post anything obscene or sexually explicit.
- Respect each other. Don’t harass or grief anyone, impersonate people, or expose their private information.
- Respect our forum. Don’t post spam or otherwise vandalize the forum.
These are not concrete terms with precise definitions — avoid even the appearance of any of these things. If you’re unsure, ask yourself how you would feel if your post was featured on the front page of the New York Times.
This is a public forum, and search engines index these discussions. Keep the language, links, and images safe for family and friends.
Keep It Tidy
Make the effort to put things in the right place, so that we can spend more time discussing and less cleaning up. So:
- Don’t start a topic in the wrong category.
- Don’t cross-post the same thing in multiple topics.
- Don’t post no-content replies.
- Don’t divert a topic by changing it midstream.
- Don’t sign your posts — every post has your profile information attached to it.
Rather than posting “+1” or “Agreed”, use the Like button. Rather than taking an existing topic in a radically different direction, use Reply as a Linked Topic.
Post Only Your Own Stuff
You may not post anything digital that belongs to someone else without permission. You may not post descriptions of, links to, or methods for stealing someone’s intellectual property (software, video, audio, images), or for breaking any other law.
Powered by You
This site is operated by your friendly local staff and you, the community. If you have any further questions about how things should work here, open a new topic in the site feedback category and let’s discuss! If there’s a critical or urgent issue that can’t be handled by a meta topic or flag, contact us via the staff page.
Terms of Service
Yes, legalese is boring, but we must protect ourselves – and by extension, you and your data – against unfriendly folks. We have a Terms of Service describing your (and our) behavior and rights related to content, privacy, and laws. To use this service, you must agree to abide by our TOS.
Back to top
FOLLOW US
© 2020 Arduino
- Terms of Service
- Privacy Policy
- Security
- Cookie Settings
These guidelines are well written.
To me they are missing one point:
ignorance.
ignorance about
I want to re-edit this sentence:
If you are not sure your post fullfils the requirement of describing in detail what you do and has a specific question, think over how you can improve your posting
save the post as a draft and try again later.
Well at least your post created an idea how I can emphasise in a different way on "describe in detail what you do and ask a specific question".
best regards Stefan
Well this has been fun! I'll look for help on a more forgiving forum. best regards!!!
@StefanL38 that seems extreme
OP did provide way more information si that’s going in the right direction.
I’m on my iPhone but I’ll have a look tomorrow
Thank You.
can you clarify which Arduino (embedding the Nordic nRF52832) you are using? is it a Bluefruit nRF52 Feather?
ideally you should write a minimal example connecting to your phone to understand how Roles, Services and Characteristics work and once this is working integrate that in your larger code.
they have the BLE Pin I/O (Firmata) example that is driving IO
My free pfodDesigner Android app (from Google play) will let you design menus to turn pins on/off or show their state. It also lets you design charts to plot data. Then you choose the board you want to use WiFi, Bluetooth, BLE or SMS and it will generate a complete sketch. For BLE it uses, for most boards, the nordic UART connection.
The menu and charts are designed to be displayed on my (paid) pfodApp (from Google play). The chart data is also logged to a file for later use.
However since it uses the Nordic UART connection you can use other apps the connect that way to run the code.
See Bluetooth Low Energy (BLE) made simple with pfodApp for numerous examples on various boards