How to send int and float data from Arduino UNO to ESP8266

Hi,
I'm working on a project based on Arduino UNO and ESP8266. My aim is to push the values which I got into arduino UNO on a mobile app. For that purpose I'm using ESP. I'm getting the values in serial monitor as shown:


I want these two values to show in the app like:

for the context, I've made the app for random values which is pushed by the ESP board into firebase and the app is getting the firebase values
So, shortly I can say that:
Electoronic circuit --> Arduino--> ESP8266 --> Firebase -->app

  1. in this the bolded partis completed for pushing random values and showing in the app

  2. and the italic part is completed and ready to give the values at serail monitor.
    I want the arduino values on ESP board so that the whole cycle can be completed.

These two values are int and float nature, and I want to pass it in the ESP
my subcode for ESP is:

Firebase.RTDB.setInt(&fbdo, "test/bpm", 60 + random(0, 40));
Firebase.RTDB.setFloat(&fbdo, "test/sp", 95.0 + random(0, 5.0));

by this I'm getting these two values on the app. I want the real values from arduino in a variable in the ESP8266 so that I can push them into firebase.

Thanks in advance.
Aniket

do you really need the UNO at all?

Every time someone comes up with this proposal, the immediate answer is this.

You have a substantially more capable processor in the ESP8266 - why would you want to complicate matters trying to figure out/ invent communication with an unnecessary UNO (poor choice in itself for any project unless you actually use a "shied" which matches it)? :roll_eyes:

I need UNO for some reasons, which are:

  1. I need to provide at least 5 V to the LED so they can glow much after the resistors which are used for power limiting. 3.3 V can't provide much power to glow the LEDs.

  2. also all other operations are being done in the UNO already, I'm using the ESP as transmitter of the values.

I know the use of ESP would be better, due to time constraints and my code I've less time to make a fresh long code for ESP exclusively.

UPDATE
I've achieved the values on the ESP card after some time of trying and searching. Thanks to all for the kind suggestions and their time.

UNO code:

SoftwareSerial espSerial(5, 6);
void setup() {
  Serial.begin(115200);
  espSerial.begin(115200);
  delay(2000);
//========= some other project reated commands=======//
 void loop{
//========= some other project reated commands=======//

espSerial.write(spo);
espSerial.write(heart_rate);

//========= some other project reated commands=======//

}

ESP code:


#include <Arduino.h>
#if defined(ESP32)
#include <WiFi.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#endif
#include <Firebase_ESP_Client.h>

//Provide the token generation process info.
#include "addons/TokenHelper.h"
//Provide the RTDB payload printing info and other helper functions.
#include "addons/RTDBHelper.h"

// Insert your network credentials
#define WIFI_SSID "********8"
#define WIFI_PASSWORD "*************"

// Insert Firebase project API Key
#define API_KEY "************************"

// Insert RTDB URLefine the RTDB URL */
#define DATABASE_URL "*************************/"

//Define Firebase Data object
FirebaseData fbdo;

FirebaseAuth auth;
FirebaseConfig config;

//unsigned long sendDataPrevMillis = 0;
int count = 0;
bool signupOK = false;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("Connecting to Wi-Fi");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(300);
  }
  Serial.println();
  Serial.print("Connected with IP: ");
  Serial.println(WiFi.localIP());
  Serial.println();

  /* Assign the api key (required) */
  config.api_key = API_KEY;

  /* Assign the RTDB URL (required) */
  config.database_url = DATABASE_URL;

  /* Sign up */
  if (Firebase.signUp(&config, &auth, "", "")) {
    Serial.println("ok");
    signupOK = true;
  }
  else {
    Serial.printf("%s\n", config.signer.signupError.message.c_str());
  }

  /* Assign the callback function for the long running token generation task */
  config.token_status_callback = tokenStatusCallback; //see addons/TokenHelper.h

  Firebase.begin(&config, &auth);
  Firebase.reconnectWiFi(true);
}
void loop() { // run over and over
  double saturation;
  float rate_heart;

  if (Serial.available()) {
    saturation = Serial.read();
    Firebase.RTDB.setInt(&fbdo, "test/sp", saturation);
  }
  Serial.print("saturation =  ");
  Serial.print(saturation);
  Serial.print("    ");
  delay(1000);
  if (Serial.available()) {
    rate_heart = Serial.read();
    Firebase.RTDB.setFloat(&fbdo, "test/bpm", rate_heart);
  }
  Serial.print("heart rate =  ");
  Serial.println(rate_heart);
  delay(1000);
}

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