Data transmission over Wifi
FrancoisCosta opened this issue · comments
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! :)
I'll have a look into wireless protocols and see if I can expand the module.
Perfect! Thanks Paul.
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
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
Of course, I understand. This weekend would be perfect! thanks :)
Hi Paul, any luck with this?
Sorry to keep asking - this functionality is somewhat critical to advancing my project.
Thanks! :)
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
Ok! Thanks, I'll give that a go in the next couple of days and let you know how it goes.
Francois
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);
}
}
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.
cool! Will give this a go, thanks :)