Hello everyone, I am currently working on a project in which I need to measure the analog voltage of a sensor, and for that, I have created the following functions, I would like to get the sensor value updated constantly on the screen, but I do not know how to do it, I thought about transforming the value to type “char”, to be able to print it in each program cycle, how can I do that?
The model of my screen is the following:https://articulo.mercadolibre.com.mx/MLM-613677029-kuman-arduino-uno-r3-de-35-pulgadas-de-pantalla-tactil-tft-_JM
This is my Sketch that I have done so far, it throws me an error when compiling, it throws me the following error:
no matching function for call to ‘MCUFRIEND_kbv :: print (char [4], int, int)’
My Sketch:
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#include <FreeDefaultFonts.h> //SmallFont, BigFont, SevenSegFont
#include <Fonts/FreeSerif12pt7b.h> //Free Font that comes with GFX
#include <Fonts/FreeSansBoldOblique24pt7b.h> //Free Font that comes with GFX
#define BLACK 0x0000 /* 0, 0, 0 */
#define DARKGREEN 0x03E0 /* 0, 128, 0 */
#define BLUE 0x001F /* 0, 0, 255 */
#define GREEN 0x07E0 /* 0, 255, 0 */
#define RED 0xF800 /* 255, 0, 0 */
#define MAGENTA 0xF81F /* 255, 0, 255 */
#define YELLOW 0xFFE0 /* 255, 255, 0 */
#define WHITE 0xFFFF /* 255, 255, 255 */
#define GREENYELLOW 0xAFE5 /* 173, 255, 47 */
const int Vpin = A8; //Entrada Analógica del sensor de voltaje
int led = 10; //Pin PWM donde va conectado el LED
int ValorVsignal;
float vrms = 0;
float ValorVfloat;
float suma = 0;
char vrms_1[4];
//Define el ancho y largo de la pantalla en pixeles
int x_size = 480; int y_size = 320;
bool settscrsize (int w, int h)
{
if ((w <= 0) || (h <= 0)) return false;
x_size = w; y_size = h;
return true;
}
void setup()
{
uint16_t ID = tft.readID();
tft.begin(ID);
tft.setRotation(1);
tft.fillScreen(WHITE);
}
void loop()
{
Parametros_CFE();
Leer_Voltage();
Imprimir_Voltage_CFE();
}
void Parametros_CFE() {
LogoCFE(180, 80);
tft.setFont(&FreeBigFont);
tft.setTextColor(BLACK);
tft.setCursor(100,130);
tft.print("PARAMETROS DE RED");
tft.setCursor(30,160);
tft.print("VOLTAJE:");
tft.setTextColor(RED);
tft.print(vrms_1, 190, 120);
tft.setCursor(270,160);
tft.print("V");
}
void LogoCFE(int x1, int y1) {
tft.setFont(&FreeSansBoldOblique24pt7b);
tft.setTextColor(DARKGREEN);
tft.setCursor(x1,y1);
tft.print("CFE");
}
void Leer_Voltage() {
for (int i = 0; i <= 1666; i++) {
ValorVsignal = analogRead(Vpin);
ValorVfloat = map(ValorVsignal, 0, 1023, -268, 268);
suma = suma + (pow(ValorVfloat, 2));
delayMicroseconds(10);
}
vrms = sqrt((suma / 1666));
suma = 0;
}
void Imprimir_Voltage_CFE() {
tft.setTextColor(RED);
String ValorV = String(vrms);
ValorV.toCharArray(vrms_1,4);
tft.print(vrms_1, 190, 120);
}