LCD 16x2 to Nokia LCD5110

Hi
I want to use Nokia LCD instead 16x2 LCD, this is original program

#include <LiquidCrystal.h>
LiquidCrystal lcd(PA0, PA1, PA2, PA3, PA4, PA5);
const int sensorIn = PA7;
int mVperAmp = 2400; // use 100 for 20A Module and 66 for 30A Module
 
double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;
 
void setup(){ 
 Serial.begin(9600);
  lcd.begin(16, 2);
}
 
void loop(){
 
 Voltage = getVPP();
 VRMS = (Voltage/2.0) *0.707;  //root 2 is 0.707
 AmpsRMS = (VRMS * 1000)/mVperAmp;
 Serial.print(AmpsRMS);
 Serial.println(" Amps RMS");
   lcd.setCursor(0, 1);
  lcd.print("U=");
  lcd.print(AmpsRMS);
 
}
 
float getVPP()
{
  float result;
  int readValue;             //value read from the sensor
  int maxValue = 0;          // store max value here
 //int minValue = 1024;          // store min value here, 4095.0
  int minValue = 4095.0;
  
   uint32_t start_time = millis();
   while((millis()-start_time) < 100) //sample for 1 Sec
   {
       readValue = analogRead(sensorIn);
       // see if you have a new maxValue
       if (readValue > maxValue) 
       {
           /*record the maximum sensor value*/
           maxValue = readValue;
       }
       if (readValue < minValue) 
       {
           /*record the minimum sensor value*/
           minValue = readValue;
       }
   }
   
   // Subtract min from max
   result = ((maxValue - minValue) * 5.0)/1024.0;
      
   return result;
 }

and modified


#include <LCD5110_Graph.h> // THE LIBRARY I AM USING IS THIS: 
LCD5110 lcd(PA4, PA3, PA2, PA0, PA1);
const int sensorIn = PA7;
int mVperAmp = 2400; // use 100 for 20A Module and 66 for 30A Module
 
double Voltage3 = 0;
double VRMS = 0;
double AmpsRMS = 0;

extern unsigned char SmallFont[];
extern unsigned char MediumNumbers[];
extern uint8_t ui[];

/////////
String voltageString3 = "0.0";
int stringLength3 = 0;
float UzValue = 0;
float voltage3 = 0.0;         //DC3
float vout3 = 0.0;
///////////


void setup(){ 
 Serial.begin(9600);
  lcd.InitLCD();
  lcd.update();
}
 
void loop(){
 
 Voltage3 = getVPP();
 VRMS = (Voltage3/2.0) *0.707;  //root 2 is 0.707
 AmpsRMS = (VRMS * 1000)/mVperAmp;
 Serial.print(AmpsRMS);
 Serial.println(" Amps RMS");

 //+++++++++++++++++++++++++++++++++++++++++++++++
//   lcd.setCursor(0, 1);
 // lcd.print("U=");
 // lcd.print(AmpsRMS);
  lcd.print(voltageString3, 0, 40);   
//  lcd.print(AmpsRMS, 0, 40);   
//+++++++++++++++++++++++++++++++++++++++++++++++
 
}
 
float getVPP()
{
  float result;
  int readValue;             //value read from the sensor
  int maxValue = 0;          // store max value here
 //int minValue = 1024;          // store min value here, 4095.0
  int minValue = 4095.0;
  
   uint32_t start_time = millis();
   while((millis()-start_time) < 100) //sample for 1 Sec
   {
       readValue = analogRead(sensorIn);
       // see if you have a new maxValue
       if (readValue > maxValue) 
       {
           /*record the maximum sensor value*/
           maxValue = readValue;
       }
       if (readValue < minValue) 
       {
           /*record the minimum sensor value*/
           minValue = readValue;
       }
   }
   
   // Subtract min from max
   result = ((maxValue - minValue) * 5.0)/1024.0;
      
   return result;
 }

Nokia screen is blank because I don't know how to link

(AmpsRMS);

with

voltageString3

Why all the Strings?

https://www.instructables.com/DIY-Voltmeter-With-Arduino-and-a-Nokia-5110-Displa/

I modify code from here

Why do you need the result in a String?

(Instructables don't have a great reputation here)

strings or no strings any solution welcome

What's wrong with

lcd.print (AmpsRMS);

?

Or explain what it is you want to do.

Also strings and Strings are not the same thing at all.

Did you get the 5110 display to work with the LCD5110_Graph library examples before adding in the rest of the stuff?

I am modifying Nokia DC voltmeter which is working ok

No it isn't.

Incomprehensible and possibly untrue. You have not responded to reply #7. Have you succeeded in getting a simple "hello world" to work? There are minor variations in the connections for 5110.

Look post #8 , DC voltmeter is working ok.

Problem solved

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