MIT Code to receive and display bluetooth data I'm trying to connect my arduino bluetooth sensor to an MIT App Inventor app I made, and in doing so display the readings of two of my sensors. Whenever I test the sensors in the serial monitor, I get normal readings, but sending them to MIT APP Inventor makes them glitch out and give me the error "Select list item: Attempt to get item number 2 of a list of length 1". I've reviewed all of my code for both the Arduino and the MIT App Inventor, and I haven't been able to find anything that may be hindering me. The timer interval for the MIT App inventor code is correct.

My Arduino code is below; the MIT app inventor code is shown in the above image

#define USE_ARDUINO_INTERRUPTS true    // Set-up low-level interrupts for most acurate BPM math.
#include <PulseSensorPlayground.h>     // Includes the PulseSensorPlayground Library.   

//  Variables
const int PulseWire = A1;       // PulseSensor PURPLE WIRE connected to ANALOG PIN A1
int Threshold = 550;           // Determine which Signal to "count as a beat" and which to ignore.
                               // Use the "Gettting Started Project" to fine-tune Threshold Value beyond default setting.
                               // Otherwise leave the default "550" value. 
const int PIEZO_PIN = A0; // Piezo output

PulseSensorPlayground pulseSensor;  // Creates an instance of the PulseSensorPlayground object called "pulseSensor"

void setup() {   
  Serial.begin(9600);          // For Serial Monitor
  // Configure the PulseSensor object, by assigning our variables to it. 
void loop() {
  int piezoADC = analogRead(PIEZO_PIN); //Get the analog value of the Piezo sensor
  float piezoV = (piezoADC / 1023.0 * 5.0);  //Get the voltage of the Piezo sensor
  int myBPM = pulseSensor.getBeatsPerMinute(); //Get the BPM detected of the user

  Serial.print((double)piezoV); // Print Piezo voltage

  Serial.print("|"); //Use this character to separate the vibration from the heartbeat

  if (pulseSensor.getBeatsPerMinute() == 0){
  Serial.println((int)myBPM); //Print the BPM

  • the split text at "|" ... is that "|" or " | "? – Jaromanda X Feb 27 '19 at 0:43
  • The split text is |, not an capital i or a lowercase L. The thing where you click shift and the backslash key. – Adam Rouzky Feb 27 '19 at 0:45
  • start by writing a minimal sketch that sends a single fixed byte every 5 seconds or so. ..... write an app to receive that byte – jsotola Feb 27 '19 at 0:45
  • I'm not asking if it's "l" or "I" or "1" - I'm asking if it's "|" or " | " .... the difference being SPACES – Jaromanda X Feb 27 '19 at 0:50
  • Ah, I'm sorry. No spaces, its just "|" – Adam Rouzky Feb 27 '19 at 0:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.