Analog values on serial monitor using bluetooth

Hello to everyone! I am a totally newbie, but for a project I need to record an analog value (heart rate, and then calculating BPM), so that I can pick this value when needed using Matlab.
I use and Arduino Uno and have already done both the scripts:

  • The Arduino script simply record the analog values from 3 electrodes, and then calculates the BPM value, writing it on the serial monitor each 100ms;
    -The Matlab code is automatized so that, in some specific windows, it read the values on the Arduino's serial monitor and then store them in a variable to send specific stimuli.

They works properly, but for safety reasons I need to power the Arduino using batteries, and not through the USB port (I know that the disconnecting the laptop from the AC would solve the problem, but I need to use the hardware even with powered computers). This raise the issue of how to communicate the BPM values to Matlab (it's a must, for the experiment!).
I thought that the bluetooth may help solving the problem (I got an ESP32 at home), so I would like to connect the electrodes to the ESP32, and then power it using batteries or a power bank. Then, when powered, it should write values on the Arduino's serial monitor so that Matlab can read them... I've never done anything similar before, so I'm in search of suggestions on how to do it.
I'm also open to other kind of solutions!
Thanks in advance!

it you are powering from batteries you won't have the serial monitor
However, using Bluetooth Classic you can set up serial communications between a ESP32 and a PC

  1. set Tools>Board to ESP32 Dev Module
  2. then select File>Examples>BluetoothSerial>SerialToSerialBT
  3. compile and upload the program
  4. it creates a Bluettoth Classic device 'ESP32test' which your PC can pair too
  5. when paired a couple of COM ports are created
    image
    COM10 is the ESP32 serial monitor
    COM11 and COM12 are the Bluetooth Ports
  6. connect Matlab to COM11 (or equivalent)

ESP32 Serial monitor output

The device started, now you can pair it with bluetooth!
hello
test from PC 1234567

Terminal emulator on PC connected to COM11 (local echo enabled)

hello
test from ESP31
test from PC 1234567
test 2 from ESP32 1234567890
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.