Frustrated that I cannot get a simple analogRead sketch to run (Adafruit Feather with a 3 wire pressure transducer )

OK, I am 73 but I should be able to get this! All the examples I can find do not run even though I program them exactly as shown so I'm asking for assistance on my specific try. I have an Adafruit Feather M0 Bluefruit LE with a 3 wire pressure transducer connected to Pin#A0. I am using the measured pressure to calculate the height of water in a tank. My code is:

/* Rev 1.3 */
float zeroTank = 6.39; //560 = 4.5" 720=6.3"
float tankHeight = 5.1; //total height of tank
float totalGal= 39.0 ; //total capacity of tank
float maxInch = 8.0; //calibration point
int calMin = 111; //0 pressure at sensor, .34V=106 (5V system was 128)
int calMax = 837; //850=8.0" (was 895 for 5V)
float tankZero = 3.0; //# inches tank bottom is from sensor
float heightinTank;

// the setup routine runs once when you press reset:
void setup() {

// initialize serial communication at 9600 bits per second:

// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 3.3V):
float voltage = sensorValue * (3.3 / 1023.0);
float absHeight = ((sensorValue-calMin) maxInch )/(calMax-calMin);
heightinTank = absHeight-zeroTank;
if (heightinTank <0) { heightinTank = 0;
float gallons = heightinTank

// print out the value you read:

/Serial.print(" ");
Serial.print(" ");
Serial.print("V ");
Serial.print(" in ");
Serial.print(" in ");
Serial.println(" gal ");


My App Invertor Blocks are:

These blocks allow me to connect to the board but just shows 0 as the output..

Thanks for any help!


Here is a link that might be helpful

SteveJG: Thanks for the reply. I had seen that project and this one did work on my device. But it is like most that I've found where the Android controls the device rather than the device sending data to the Android. That one is above my pay grade so I haven't been able to figure out how to insert my code to read the data on A0.

Thanks again


Hello Doug

I'm not here now but if I was I would tell you that you have mixed Serial Output (usually Classic Bluetooth) and Characteristic Output (BLE). So you first need to decide what to work with.

Now, your Sketch is sending either floats or text (should not send decoration, just values, BT packets are small by default), yet your App thinks it is going to receive integers.........

On top of all of that, Adafruit boards are different to the norm (such as Arduino) so you must use their Sketch libraries.

ChrisWard: Thanks for the feedback. That will point me in the correct direction.