Start a new topic
Not Taken

make gauge start at bottom.

i having problem to make the gauge start at bottom, it always left. i have attach the gauge model i want to create. anyone can help ;(
jpeg

1 person likes this idea

 http://wiki.iteadstudio.com/images/3/3a/Nextion_3.2_Example.zip

arduino example:.

.

.

.

.

.

 void loop() {
getValue = analogRead(A0);
if (getValue==oldValue)
{

}
else
{
oldValue=getValue;
value=getValue;
if(value <= 172) value2 = map(value, 0, 172, 315, 359);
else value2 = map(value, 172, 1023, 0, 223);

.

.

.

.

.


I am now reviewing all of the Feature Requests, this will take some time, patience please.

Wherever the gauge starts will always create change request by others.

This needs to be handled in user code to suit the needs for each project.


I would also like this.  Or at least the ability to start at ~7 O clock.

programming wise it can be done already ...

we don't bloat the limited firmware space to do user coding

The code is already provided above

I tried that and its not working smooth.  I will experiment more.


What I have is a current sensor and I want to display the current with the needle as well as numbers below so I am trying to get it to display correctly.  


Oh BTW  I have a bidirectional current sensor and at 2.5v it reads 0 amps SO I need to figure out the math to make it read 0 at 2.5v but have tghe gauge at about 8 oclock when its at 0 as well.  Anyone is welcome to look at my code.   Here is what I have working for voltage measurement with precharge for my electric car so far and I display the total voltage for the traction pack as well as the system battery.  But now I need to add current then speed with current being the hard one speed will also need to read 0 at about 7 oclock   here is my code so far.   

#include <SoftwareSerial.h>
#include <Nextion.h>
SoftwareSerial nextion(2, 3);// Nextion TX to pin 2 and RX to pin 3 of Arduino

Nextion myNextion(nextion, 9600); //create a Nextion object named myNextion using the nextion serial port @ 9600bps
int old_sensor_value = 0;
void setup() {
 
Serial.begin(9600); // initialize serial communication at 9600 bits per second:
myNextion.init();
pinMode(12, OUTPUT);//
digitalWrite(1, LOW);//Makes contactor outout LOW initially (zero)
int contactorstatus = 000;
   


}


// the loop routine runs over and over again forever:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
// read the input on analog pin 0:
  float Packvolt = (analogRead(A0)/2.048);//Outputs values from 0-1023, so 2.048 will make the maximum voltage 500V.  Set appropriate voltage divider!
  float Prechargevolt = (analogRead(A1)/2.048);//
  float Systemvolt = (analogRead(A2)/63.94);//Outputs values from 0-1023 so 63.94 is 16v with a 5v input
  float BatteryAmp = (analogRead(A3)*1.85-511.5);// Bidirectional current sensor 2.5v at middle
  int contactorstatus = 000;
  int value = Prechargevolt;
  float z1 = (analogRead(A3));
  {
   int value2;
   if(z1 <=172) value2 = map(value, 0, 172, 315, 359);
  else value2 = map(value, 172, 1023, 0, 223);
}
  
  int (speed[0]);
  if  (Packvolt>340&&Packvolt<480&&Packvolt*0.965<=Prechargevolt)// 95% precharge, change 0.95 to whatever to get you want your precharge to be
{
  digitalWrite(12, HIGH);
  int contactorstatus = 111;
}
    
   myNextion.setComponentText("t12", String(Prechargevolt));  // update text using original sensor value
   myNextion.setComponentValue("z2", speed);
   myNextion.setComponentText("t13", String(Systemvolt));  //12v battery gauge
   myNextion.setComponentValue("n0", BatteryAmp);
   myNextion.setComponentValue("z1", z1);
   delay(200);        // delay in between reads for stability
}

 

jpg

Perhaps review other like threads:


Gauge to work from center of bottom

http://support.iteadstudio.com/support/discussions/topics/11000009181


That thread proves that code can deliver a very smooth gauge.


I am not willing to represent a gauge feature request when it can be

done via code without bloating the firmware.


Coding questions do not belong in Feature Requests

Please ask coding questions in the Free Chat section of the Forum

Login or Signup to post a comment