Hello,
I have little program that will output number 7, 11 or 15 (depend on source).
Currently the Serial Monitor on my computer can display TEXT like FLOAT or BOOT or EQUALIZATION but not on my Blynk App.
How to display a TEXT on Blynk App?
If the output is 7 then I want Bylink app will show FLOAT
If the output is 11 then I want Bylink app will show BOOST
If the output is 15 then I want Bylink app will show EQUALIZATION
Here is the code:
#include <ArduinoOTA.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <ModbusMaster.h>
#include <ESP8266WiFi.h>
#include "settings.h"
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
int CStatus, Boost, Float, Equalization;
float ChargingStatus;
// this is to check if we can write since rs485 is half duplex
bool rs485DataReceived = true;
// a list of the regisities to query in order
typedef void (*RegistryList[])();
RegistryList Registries = {
AddressRegistry_3201,
};
// keep log of where we are
uint8_t currentRegistryNumber = 0;
// function to switch to next registry
void nextRegistryNumber() {
currentRegistryNumber = (currentRegistryNumber + 1) % ARRAY_SIZE( Registries);
}
void updateBlynk() {
Blynk.virtualWrite(vPIN_BATT_CHARGING_STATUS, ChargingStatus);
}
void doRegistryNumber() {
Registries[currentRegistryNumber]();
}
// ========PROGRAM START HERE ==================
void AddressRegistry_3201() {
result = node.readInputRegisters(0x3201, 2);
if (result == node.ku8MBSuccess)
{
ChargingStatus = node.getResponseBuffer(0x00) / 1.0f;
if (ChargingStatus == 7) {
Serial.print("Charging Status: ");
Serial.println("Float");
} else if (ChargingStatus == 11) {
Serial.print("Charging Status: ");
Serial.println("Boost");
} else if (ChargingStatus == 15) {
Serial.print("Charging Status: ");
Serial.println("Equalization");
}
} else {
rs485DataReceived = false;
}
}
// ================================================
void loop()
{
Blynk.run();
ArduinoOTA.handle();
timer.run();
}
// ========= END PROGRAM =============================