I'm trying to make a health monitoring project in which I've used a MAX30102 and a ds18b20 temperature sensor I'm viewing the data on an oled display I want to send the data to my blynk account as well but I'm facing some problem in my code I'm sharing my code can someone please help me out with it, I kind of have almost no coding knowledge.
My code:
#include <Wire.h>
#include "MAX30105.h"
#include "spo2_algorithm.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
MAX30105 particleSensor;
TwoWire max30102Wire(1);
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
uint32_t irBuffer[100];
uint32_t redBuffer[100];
int32_t bufferLength;
int32_t spo2;
int8_t validSPO2;
int32_t heartRate;
int8_t validHeartRate;
OneWire oneWire(5);
DallasTemperature sensors(&oneWire);
char auth[] = "YourAuthToken";
char ssid[] = "YourNetworkSSID";
char pass[] = "YourNetworkPassword";
BlynkTimer timer;
void sendSensorDataToBlynk() {
sensors.requestTemperatures();
float tempFahrenheit = sensors.getTempFByIndex(0);
Serial.print("Heart Rate: ");
Serial.println(heartRate);
Serial.print("SpO2: ");
Serial.println(spo2);
Serial.print("Temperature: ");
Serial.print(tempFahrenheit);
Serial.println(" °F");
Blynk.virtualWrite(V0, heartRate);
Blynk.virtualWrite(V1, spo2);
Blynk.virtualWrite(V2, tempFahrenheit);
}
void setup() {
Serial.begin(115200);
Wire.begin();
max30102Wire.begin(18, 19);
if (!particleSensor.begin(max30102Wire, I2C_SPEED_FAST)) {
Serial.println(F("MAX30105 was not found. Please check wiring/power."));
while (1);
}
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;);
}
display.clearDisplay();
display.display();
delay(2000);
display.clearDisplay();
sensors.begin();
Blynk.begin(auth, ssid, pass);
timer.setInterval(5000L, sendSensorDataToBlynk);
}
void loop() {
bufferLength = 100;
for (byte i = 0; i < bufferLength; i++) {
while (particleSensor.available() == false)
particleSensor.check();
redBuffer[i] = particleSensor.getRed();
irBuffer[i] = particleSensor.getIR();
particleSensor.nextSample();
}
maxim_heart_rate_and_oxygen_saturation(irBuffer, bufferLength, redBuffer, &spo2, &validSPO2, &heartRate, &validHeartRate);
sensors.requestTemperatures();
float tempFahrenheit = sensors.getTempFByIndex(0);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.print(F("Heart Rate: "));
display.println(heartRate);
display.print(F("SpO2: "));
display.print(spo2);
display.println(F("%"));
display.print(F("Temp: "));
display.print(tempFahrenheit);
display.println(F("°F"));
display.display();
Serial.println("--- New Iteration ---");
Blynk.run();
timer.run();
}
And this is the error message I'm getting:
//
In file included from C:\Users\DELL\AppData\Local\Temp.arduinoIDE-unsaved20231111-9528-1p0chj0.2qq7\sketch_dec11a\sketch_dec11a.ino:10:
c:\Users\DELL\Documents\Arduino\libraries\Blynk\src/BlynkSimpleEsp32.h: In member function 'void BlynkWifi::connectWiFi(const char*, const char*)':
c:\Users\DELL\Documents\Arduino\libraries\Blynk\src/BlynkSimpleEsp32.h:39:14: error: 'class WiFiClass' has no member named 'mode'
WiFi.mode(WIFI_STA);
^~~~
c:\Users\DELL\Documents\Arduino\libraries\Blynk\src/BlynkSimpleEsp32.h:39:19: error: 'WIFI_STA' was not declared in this scope
WiFi.mode(WIFI_STA);
^~~~~~~~
exit status 1
Compilation error: exit status 1
//
#include <Wire.h>
#include "MAX30105.h"
#include "spo2_algorithm.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
MAX30105 particleSensor;
TwoWire max30102Wire(1);
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 32
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
uint32_t irBuffer[100];
uint32_t redBuffer[100];
int32_t bufferLength;
int32_t spo2;
int8_t validSPO2;
int32_t heartRate;
int8_t validHeartRate;
OneWire oneWire(5);
DallasTemperature sensors(&oneWire);
char auth[] = "YourAuthToken";
char ssid[] = "YourNetworkSSID";
char pass[] = "YourNetworkPassword";
BlynkTimer timer;
void sendSensorDataToBlynk() {
sensors.requestTemperatures();
float tempFahrenheit = sensors.getTempFByIndex(0);
Serial.print("Heart Rate: ");
Serial.println(heartRate);
Serial.print("SpO2: ");
Serial.println(spo2);
Serial.print("Temperature: ");
Serial.print(tempFahrenheit);
Serial.println(" °F");
Blynk.virtualWrite(V0, heartRate);
Blynk.virtualWrite(V1, spo2);
Blynk.virtualWrite(V2, tempFahrenheit);
}
void setup() {
Serial.begin(115200);
Wire.begin();
max30102Wire.begin(18, 19);
if (!particleSensor.begin(max30102Wire, I2C_SPEED_FAST)) {
Serial.println(F("MAX30105 was not found. Please check wiring/power."));
while (1);
}
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for (;;);
}
display.clearDisplay();
display.display();
delay(2000);
display.clearDisplay();
sensors.begin();
Blynk.begin(auth, ssid, pass);
timer.setInterval(5000L, sendSensorDataToBlynk);
}
void loop() {
bufferLength = 100;
for (byte i = 0; i < bufferLength; i++) {
while (particleSensor.available() == false)
particleSensor.check();
redBuffer[i] = particleSensor.getRed();
irBuffer[i] = particleSensor.getIR();
particleSensor.nextSample();
}
maxim_heart_rate_and_oxygen_saturation(irBuffer, bufferLength, redBuffer, &spo2, &validSPO2, &heartRate, &validHeartRate);
sensors.requestTemperatures();
float tempFahrenheit = sensors.getTempFByIndex(0);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.print(F("Heart Rate: "));
display.println(heartRate);
display.print(F("SpO2: "));
display.print(spo2);
display.println(F("%"));
display.print(F("Temp: "));
display.print(tempFahrenheit);
display.println(F("°F"));
display.display();
Serial.println("--- New Iteration ---");
Blynk.run();
timer.run();
}
This is my code to view the data on serial monitor and oled display
and this is the example code to send data to Blynk account
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
// WiFi credentials
char ssid[] = "YourSSID";
char pass[] = "YourPassword";
char auth[] = "YourAuthToken";
// Timer interval for Blynk data transmission
#define SEND_INTERVAL 5000 // 5 seconds
unsigned long lastMillis = 0;
void setup() {
Serial.begin(115200);
// Connect to Wi-Fi
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
Blynk.begin(auth, ssid, pass);
}
void loop() {
Blynk.run();
unsigned long currentMillis = millis();
if (currentMillis - lastMillis >= SEND_INTERVAL) {
lastMillis = currentMillis;
// Your sensor readings and Blynk.virtualWrite() calls here
float sensorValue = analogRead(A0); // Example sensor reading
Blynk.virtualWrite(V1, sensorValue); // Send sensor value to V1 in Blynk app
}
}
abdulmoizs502:
sketch_dec11a.ino
You should save your sketch with a meaningful name
How would you ever determine in two weeks what the file "sketch_dec11a " does??
For the error-message
The Arduino-IDE can be configured to log only a few = too few things about the compiling-process and errors or very much details
So as the next step you should adjust the arduino-IDE to printout each and every detail about the compiling process like described in this tutorial
Hi newcomer,
the Arduino-Forum community can be of great help.
If the community is able to support you in a way that helps solving your problems depends on
detailed information that you should provide.
trying to be quick by posting a too short posting is just
slowing down
finding the solution. Because all that happends is that you are asked for the detailed information and have to provide it anyway. Only difference the answer and the solution comes later
The most important thing is to pos…
best regards Stefan
xfpd
December 12, 2023, 7:20am
4
What problem are you facing?
Also put some effort on making your post more readable. Punctuate! It's frustrating to read, if one has to guess the punctuation. I usually stop reading, if the writer doesn't care for such details.
1 Like
system
Closed
June 9, 2024, 8:52am
8
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.