Start a new topic

nextion and HC-SR04

Hi, i´m working with a  HC-SR04, and a Nextion Enhace 3.2, NX4024K032_011, i want to display in the screen the value of the sensor without press any button, i´m using arduino mega too, someone can help please!

The Nextion IO are digital 0,1 only for input modes.

The Nextion is also integer based (no floating point)

However, using your Mega and the IteadLib Arduino Nextion Library.

(please refer to the Nextion FAQs, link to IteadLib is there)


uint32_t sensorValue;

NexNumber sensorNumber NexNumber(0,1,"page0.n0");

// one your value from HC-SR04 is in sensorValue;

sensorNumber.setValue(sensorValue);



Hi Patrick thanks for your answer, but i have another problem that´s why i can probe your solution, when i compile the program in arduino i have this error : expected initializer before 'NexNumber',  i tested wiht others librieries and they give me another error; NexNumber does not name a type, do you have any idea?

ino

Two things come to mind quickly


1) the #include "Nextion.h" for the IteadLibrary will need to be at the top of the code file

    - NexInit() will need to be in the Setup() function

    - NexLoop() will need to be in the Loop() function


2) installing many libraries? in itself can create conflict

    - the compiler will probably grab the first it comes across - maybe not IteadLib.

Hi Patrick thanks for you answer, i had many libraries as you said, i already solvet, but i still have an error displaying the sensorValue on the screen, this is my funtion on the sketch

void Sonar(void)

void Sonar(void)

{

long duration, inches, cm;

    char buffer[33];

   char *strptr;

    digitalWrite(pingOut,LOW);

    delayMicroseconds(2);

    digitalWrite(pingOut,HIGH);

    delayMicroseconds(10);

    digitalWrite(pingOut,LOW);

    duration = pulseIn(pingIn,HIGH,30000);

    cm = duration / 29 / 2;

memset (buffer, 0, sizeof(buffer));

itoa(cm, buffer, 10);

sensorNumber.setValue(buffer);


}


i have an error and i can´t see it.

thanks for your time and patience

Please review NexNumber.h and NexNumber.cpp

- I have my doubts that setValue uses a string as a parameter

Login or Signup to post a comment