Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data transmission over Wifi #1

Open
FrancoisCosta opened this issue Apr 7, 2019 · 11 comments
Open

Data transmission over Wifi #1

FrancoisCosta opened this issue Apr 7, 2019 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@FrancoisCosta
Copy link

Hi Paul!

As I briefly mentioned in the Python version's issues, my project involves monitoring heart rate (& HRV) during sleep with real-time analysis.
To avoid disrupting sleep (and reducing the risk of my laptop getting thrown off the bed in the middle of the night...) I aim to log data throughout the night without a serial connection between the arduino board (Feather 32u4) and laptop.

However, on the documentation I see either a USB or SD version (which would not allow real time analysis). Is there a wireless option (Wi-Fi/BT)?

The data (RR-intervals) should be transferred over Wi-Fi or BT to firstly my computer, and then, as the project progresses, directly to a raspberry Pi.

Thanks! :)

@paulvangentcom paulvangentcom self-assigned this Apr 8, 2019
@paulvangentcom paulvangentcom added the enhancement New feature or request label Apr 8, 2019
@paulvangentcom
Copy link
Owner

I'll have a look into wireless protocols and see if I can expand the module.

@FrancoisCosta
Copy link
Author

Perfect! Thanks Paul.

@FrancoisCosta
Copy link
Author

Hi Paul,
Any update on the wireless implementation? As I'm attempting real-time analysis using a wearable, data transfer over wifi is critical..

Thanks! :)
Francois

@paulvangentcom
Copy link
Owner

Hi Francois,

Not yet I'm afraid. I need to find the time to fit heartpy work in between my phd work so it doesn't always work out...

I hope this weekend I can have a look.

-Paul

@FrancoisCosta
Copy link
Author

Of course, I understand. This weekend would be perfect! thanks :)

@FrancoisCosta
Copy link
Author

Hi Paul, any luck with this?

Sorry to keep asking - this functionality is somewhat critical to advancing my project.

Thanks! :)

@paulvangentcom
Copy link
Owner

If you're in a hurry I suggest you look at Xbee, they have some wireless data transfer capabilities that are Arduino compatible. You may need to set up a buffer and send the data in batches.

The wifi capability is on my radar but has no ETA right now. Other things take precedent in my planning at the moment.

-Paul

@FrancoisCosta
Copy link
Author

Ok! Thanks, I'll give that a go in the next couple of days and let you know how it goes.

Francois

@FrancoisCosta
Copy link
Author

Hi Paul,

I'm currently working on a WiFi script for the Feather Huzzah ESP32 board.
However the timerInterrupt function used for the ATmega16U4/32U4/328p boards in the script provided does not work on the ESP32.

I have separate scripts working for both the WiFi transfer and a 1ms interrupt on the ESP32. However, I don't understand the SimpleLogger_Scaling_AVR_USB.ino sketch well enough to be able to implement the new interrupt while still logging the pulse sensor values, let alone send these values over Wi-Fi.

The line by line breakdown of the timer interrupt script I am using can be found here:
https://techtutorialsx.com/2017/10/07/esp32-arduino-timer-interrupts/

Would you be able to implement this interrupt within the original sketch? Once I'm able to receive the sensor values I'll keep working on the Wi-Fi data transfer.

interrupt sketch code below

volatile int interruptCounter;
int totalInterruptCounter;

hw_timer_t * timer = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;

void IRAM_ATTR onTimer() {
portENTER_CRITICAL_ISR(&timerMux);
interruptCounter++;
portEXIT_CRITICAL_ISR(&timerMux);

}

void setup() {

Serial.begin(115200);

timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &onTimer, true);
timerAlarmWrite(timer, 1000000, true);
timerAlarmEnable(timer);

}

void loop() {

if (interruptCounter > 0) {

portENTER_CRITICAL(&timerMux);
interruptCounter--;
portEXIT_CRITICAL(&timerMux);

totalInterruptCounter++;

Serial.print("An interrupt as occurred. Total number: ");
Serial.println(totalInterruptCounter);

}
}

@paulvangentcom
Copy link
Owner

As the tutorial states, you need to replace

totalInterruptCounter++;

Serial.print("An interrupt as occurred. Total number: ");
Serial.println(totalInterruptCounter);

with what you want to call in the interrupt function. This is the function readSensors(dataBuf); in the original sketch.

Also see here for an alternative way of setting a hardware timer in that environment: http://www.iotsharing.com/2017/06/how-to-use-interrupt-timer-in-arduino-esp32.html

Make sure you set the timer to the correct interval so you get the sampling rate you want.

@FrancoisCosta
Copy link
Author

cool! Will give this a go, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants