My arduinos bytes are not being received by the app

so, basically im using seeed nrf52840 connected to a button with the help of a breadboard.

#include <bluefruit.h>

// BLE Settings
const char* DEVICE_NAME = "SafetyPendant";
#define SERVICE_UUID    "19B10000-E8F2-537E-4F6C-D104768A1214"
#define CHAR_UUID       "19B10001-E8F2-537E-4F6C-D104768A1214"

BLEService safetyService(SERVICE_UUID);
BLECharacteristic emergencyChar(CHAR_UUID);

const int BUTTON_PIN = D2;    // Button with 10KΩ resistor to GND
const int LED_PIN = LED_BUILTIN; // Built-in LED
bool lastButtonState = HIGH;

void setup() {
  Serial.begin(115200);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW);

  // BLE Setup
  Bluefruit.begin();
  Bluefruit.setName(DEVICE_NAME);
  
  safetyService.begin();
  emergencyChar.setProperties(CHR_PROPS_NOTIFY);
  emergencyChar.setPermission(SECMODE_OPEN, SECMODE_OPEN);
  emergencyChar.setFixedLen(1);
  emergencyChar.begin();

  // Start advertising
  Bluefruit.Advertising.addService(safetyService);
  Bluefruit.Advertising.addName();
  Bluefruit.Advertising.start(0);

  Serial.println("Ready! Press the button to trigger alerts.");
}

void loop() {
  bool currentState = digitalRead(BUTTON_PIN);
  
  // Send alert on button press (with debounce and LED feedback)
  if (currentState == LOW && lastButtonState == HIGH) {
    uint8_t alert = 1;
    
    digitalWrite(LED_PIN, HIGH);   // Visual feedback
    emergencyChar.notify(&alert, 1);
    Serial.println("SOS signal sent!");
    delay(100);                   // LED on for 100ms
    digitalWrite(LED_PIN, LOW);
    
    delay(300);                   // Debounce delay
  }
  lastButtonState = currentState;
}

this is the code im running on arduino ide to send bytes when the button is pressed.
image
and well, the button certainly works properly BUT the information from my arduino to the app is kinda not going as i want it to?

when i press the button, it SHOULD update the label, but unfortunately due some reason, it just doesnt. what do i do? help me out peeps:_(
Thanks in advance:3

image

byteValues is a list, so you have to select item 1 from it to get something you can test.

Just display what arrives, so we can proceed from there without guessing.

1 Like

Screenshot 2025-06-23 174938
should it be like this? if so, i dont think its working still
theres no change in my label

if (currentState == LOW && lastButtonState == HIGH) {
uint8_t alert = 1; this code SHOULD put the value as 1 in index one, but it still doesnt work

Remove the if/then test.

Assign byteValues into Label1.Text

Show us what arrived.

1 Like

image


no change obtained in the label anw abg:_(
the physical button works well, so thats still not the issue, idk what is @ABG

That Unknown Characteristic message looks ominous.

So do the empty sockets in your blocks.

Factor out your app for the moment by trying to connect from the free nrfConnect app, just to see if you are working with a good device.

Also,
(Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.

export_and_upload_aia

1 Like

can i send you the aia file personally here? im not really comfy sharing the whole app kinda if thats cool w you? and well as bad as unknown characterisitcs label looks, its a different label in and of itself, the label saying "the location is:" is the one that shoudve changed lol

Best I can do for you is point you to other threads for that device:

https://community.appinventor.mit.edu/search?expanded=true&q=nrf52840%20

it did not help lol
heres the aia file
prototype_1_0_0_copy (2).aia (201.7 KB)

the device is perfectly good as i could connect it with nrfconnect app too

okay so updates, after surfing a bit, i thought of adding the list to csv thingy and
Screenshot 2025-06-23 225301

prototype_1_0_0_copy_1.aia (202.7 KB)

okay so updates, after surfing a bit, i thought of adding the list to csv thingy and now im getting this error when i press the button.
it makes it at least clear that the mit application is indeed sending the information over but my app cant read the information due whatever reason, i have to find a way for the app to convert whatevers the arduino is sending and convert into something that the app can read

Here are my suggested corrections (old,new):

blocks
(empty sockets forbidden)


...

unnecessary and not allowed for same reason

...

The byteList is a list of simple data items, not a table (list of lists)

(alternatively, rename global VALUES to FIRSTVALUE and just do the select item 1.)

1 Like

i understood all your corrections except for the last line. the whole app and the system itself is working perfectly when its like this(couldnt understand the select item 1 part because its working flawlessly even without it)


the label did get updated to 1 and the notifier also brought up 1 for the FIRSTVALUE.

now, all im stuck at, is the last part

Now, for the last part, If the value i receive is 1, i want the app to PERFORM a function, be it anything(like something on the last image) but somehow the if statements ive made using the logic equal function, or the math equal function do not seem to work (as in this case, its not sending an sms at all.) please help me out with this one too

and well thank you for your patience and time abg, i really appreciate it

See those quotes around the 1?
image
Global FIRSTVALUE has three characters in it (",1,"), not 1 character.

They are an artifact of the csv conversion.

They might be interfering with the comparison "1" to 1

If you do a Select item 1 from List instead of the csv conversion, they should not be there, and the comparison should work.

Alternatively, try using a blue math 1 in the comparison, to see if AI2 will regard this as a math comparison instead of a text comparison.

P.S. Good instrumentation. It's helpful to see what's going on in the data.

1 Like

ABG MY GUY
when you said these, "Global FIRSTVALUE has three characters in it (",1,"), not 1 character.

They are an artifact of the csv conversion.

They might be interfering with the comparison "1" to 1"
i understood that the upper quotes were a part of the FIRS6TVALUE itself, so i did this

and well, it works now?
another update, like you said, i used the select item 1 instead of doing the csv conversion and well, im getting the 1 without the quotes and the system is functional too

both the ways, the code is running, the latter being better as its what i wanted
anyways, thank you once again for following me through my errors and helping me rectify it, i really appreciate it. you da best :man_cook:

1 Like