Arduino+esp01s l+max30100 is it possible to connect!?
I'm using esp01s as wifi and I can transmit the data but with esp I'm getting 0 BPM 0 spo2.
In serial monitor I can see the 0 readings..
With out esp code it's working fine
are you using SoftwareSerial to communicate with the ESP-01
what baudrate are you using?
you could try AltSoftSerial
- upload the code using code tags (select < CODE/ > and paste text where it says โtype or paste code hereโ)
- upload a schematic showing the wiring and how devices are powered
remember that the Nano using 5V logic the ESP-01 3.3V - make sure you have a potential divider on the ESP-01 Rx line
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#define REPORTING_PERIOD_MS 1000
// Create a PulseOximeter object
PulseOximeter pox;
// Time at which the last beat occurred
uint32_t tsLastReport = 0;
#include <SoftwareSerial.h>
#define RX 2 // TX of esp8266 in connected with Arduino pin 2
#define TX 3 // RX of esp8266 in connected with Arduino pin 3
#define sensorPower 10 // for the water level sensor
#define sensorPin A1
// Value for storing water level
int val = 0;
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 9, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
String WIFI_SSID = "abhi";// WIFI NAME
String WIFI_PASS = "11334455"; // WIFI PASSWORD
String API = "xxxxxxxxxxxxxxxxx";// Write API KEY
String HOST = "api.thingspeak.com";
String PORT = "80";
int countTrueCommand;
int countTimeCommand;
boolean found = false;
SoftwareSerial esp8266(RX, TX);
void setup() {
pinMode(sensorPower, OUTPUT);
digitalWrite(sensorPower, LOW);
Serial.begin(9600);
esp8266.begin(115200);
Serial.print("Initializing pulse oximeter..");
// Initialize sensor
if (!pox.begin()) {
Serial.println("FAILED");
} else {
Serial.println("SUCCESS");
}
// Configure sensor to use 7.6mA for LED drive
pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("IoT HEALTH MONITERING");
sendCommand("AT", 5, "OK");
sendCommand("AT+CWMODE=1", 5, "OK");
sendCommand("AT+CWJAP=\"" + WIFI_SSID + "\",\"" + WIFI_PASS + "\"", 20, "OK");
}
void loop() {
int adcData = analogRead(A0);
// Convert that ADC Data into voltage
float voltage = adcData * (5.0 / 1024.0);
// Convert the voltage into temperature
float temperature = voltage * 100;
// Print the temperature data
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println("*C");
int level = readSensor();
level = map (level, 0, 1023, 0 , 100);
Serial.print("Water level: ");
Serial.print(level);
Serial.println("%");
pox.update();
// Grab the updated heart rate and SpO2 levels
if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
Serial.print("Heart rate:");
Serial.print(pox.getHeartRate());
Serial.print("bpm / SpO2:");
Serial.print(pox.getSpO2());
Serial.println("%");
tsLastReport = millis();
}
int bpm = pox.getHeartRate();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp");
lcd.setCursor(6, 0);
lcd.print(temperature);
lcd.setCursor(10, 0);
lcd.print("*C");
lcd.setCursor(0, 1);
lcd.print("BPM");
lcd.setCursor(5, 1);
lcd.print(pox.getSpO2());
lcd.setCursor(8, 1);
lcd.print("GCL");
lcd.setCursor(12, 1);
lcd.print(level);
String getData = "GET /update?api_key=" + API + "&field1=" + temperature +
"&field2=" + bpm + "&field3=" + level;
sendCommand("AT+CIPMUX=1", 5, "OK");
sendCommand("AT+CIPSTART=0,\"TCP\",\"" + HOST + "\"," + PORT, 15, "OK");
sendCommand("AT+CIPSEND=0," + String(getData.length() + 4), 4, ">");
esp8266.println(getData);
delay(1500);
countTrueCommand++;
sendCommand("AT+CIPCLOSE=0", 5, "OK");
}
int readSensor() {
digitalWrite(sensorPower, HIGH); // Turn the sensor ON
delay(10); // wait 10 milliseconds
val = analogRead(sensorPin); // Read the analog value form sensor
digitalWrite(sensorPower, LOW); // Turn the sensor OFF
return val; // send current reading
}
void sendCommand(String command, int maxTime, char readReplay[]) {
Serial.print(countTrueCommand);
Serial.print(". at command => ");
Serial.print(command);
Serial.print(" ");
while (countTimeCommand < (maxTime * 1))
{
esp8266.println(command);//at+cipsend
if (esp8266.find(readReplay)) //ok
{
found = true;
break;
}
countTimeCommand++;
}
if (found == true)
{
Serial.println("OK");
countTrueCommand++;
countTimeCommand = 0;
}
if (found == false)
{
Serial.println("Fail");
countTrueCommand = 0;
countTimeCommand = 0;
}
found = false;
}
I don't think Nano's 3.3v is up for powering the ESP01
as @Nick_Pyner suggests it is probably a power supply problem
you have a lot of devices connected to the nano which is probably overloading the power supply
if you remove the LCD does the rest of the system work?
try an external power supply
Actually, I suspect the ESP is too much for Nano's 3.3v even if there are no other peripherals. ESPs are not renowned for their frugality, and Arduinos are not renowned for their largesse at the 3.3v pin. You need to check this as I believe Nano is much the same as Uno.
Everything is working fine.. all sensors generated data successfully received by thingspeak.. except max30100 values.. it's LED glowing but it's reading is 0 every time..
After that I removed esp code for the same circuit and absolutely working fine..
Incoherent, but it sounds like you are redefining the meaning of "everthing", and your power problem is unsolved.
You may have merely demonstrated the difference between the active and quiescent current in the ESP.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.