ESP32 value on iPhone

Hi
Why value is showing on serial monitor but not on iPhone ?
On iPhone is all the time zero 0


// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__WIFI_POINT

#include <WiFi.h>

// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "RemoteXY"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_SERVER_PORT 6377

#include <RemoteXY.h>
int sensorPin = 33;
// RemoteXY GUI configuration
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =   // 28 bytes
{ 255, 0, 0, 1, 0, 21, 0, 19, 0, 0, 0, 0, 31, 1, 106, 200, 1, 1, 1, 0,
  67, 30, 55, 40, 10, 94, 2, 26
};

// this structure defines all the variables and events of your control interface
struct {

  // output variables
  int8_t value_01; // -128 .. 127
  char text_1[11];  // string UTF8 end zero
  // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)

void setup()
{
  RemoteXY_Init ();
Serial.begin(115200);
}

void loop()
{
  RemoteXY_Handler ();
 dtostrf(analogRead(sensorPin), 0, 1, RemoteXY.text_1);
  Serial.print("   V = ");
  Serial.println(analogRead(sensorPin));
}

Hi @tom321. I see that the RemoteXY library has a debug output feature:

https://remotexy.com/en/help/code/review/#:~:text=commented%20line%20//-,%23define%20REMOTEXY__DEBUGLOG,-.%20If%20you%20uncomment

The example also contains a commented line //#define REMOTEXY__DEBUGLOG . If you uncomment it, the RemoteXY.h library will be configured to output debug information to the Serial port at a speed of 115200.

The debug output might give some insight into what is going wrong. Try this:

  1. Add the following line to the top of your sketch:
    #define REMOTEXY__DEBUGLOG
    
  2. Comment out these lines in your sketch:
    Serial.print("   V = ");
    Serial.println(analogRead(sensorPin));
    
    The reason for doing this is that, since this code is configured to print to Serial on every single execution of loop, it will flood the Serial Monitor with output and make it difficult to see the debug output from the RemoteXY library.
  3. If it is not already open, open the Arduino IDE Serial Monitor.
  4. Upload the sketch to the ESP32 board.

Then watch Serial Monitor for any useful information.

I don't use RemoteXY but I see you print to the Serial monitor by directly reading the value again instead of looking at the actual value you stored with dtostrf().

try printing RemoteXY.text_1 instead to see what was set.


Also what does not work - value_01 or text_1 ?

Sometime on serial monitor are some numbers, but on
iPhone is all the time zero 0



// you can enable debug logging to Serial at 115200
#define REMOTEXY__DEBUGLOG

// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__WIFI_POINT

#include <WiFi.h>

// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "RemoteXY"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_SERVER_PORT 6377

#include <RemoteXY.h>
int sensorPin = 33;
// RemoteXY GUI configuration
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =   // 28 bytes
{ 255, 0, 0, 1, 0, 21, 0, 19, 0, 0, 0, 0, 31, 1, 106, 200, 1, 1, 1, 0,
  67, 30, 55, 40, 10, 94, 2, 26
};

// this structure defines all the variables and events of your control interface
struct {

  // output variables
  int8_t value_01; // -128 .. 127
  char text_1[11];  // string UTF8 end zero
  // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)

void setup()
{
  RemoteXY_Init ();
  Serial.begin(115200);
}

void loop()
{
  RemoteXY_Handler ();
  dtostrf(analogRead(sensorPin), 0, 1, RemoteXY.text_1);
  /*
  //Serial.println(analogRead(sensorPin));
  Serial.print("   V = ");
  //Serial.print(value_01);
  Serial.print("   text = ");
  Serial.println(RemoteXY.text_1);
  */
  delay(100);
}
![ser2|412x500](upload://wk8CtDjQXe1NhstRKsD0ZCRMAO7.png)

I'm guessing the "sometime" is the cause of the problem. The loop function is typically executed many times per second. If the value is 0 the majority of the time, then you won't even see the non-zero values in the display on the iPhone.

Please provide details about your project. What exactly is the sensor you have connected to pin 33 of the Arduino board? Is it expected that the sensor will mostly output 0 V, and only briefly and occasionally output higher voltage?

Do you understand the code you have and what a struct is?

for this error

you need to print the attribute of your structure

Serial.print(RemoteXY.value_01);

Exactly as you did for the text_1 attribute (weird names by the way - why not simply value and text) ?

Also if the values are integers, don't use dtostrf() - you can just use snprintf() or itoa() and the likes

Now screen on the iphone is alive but the numbers are much different than on serial port. Serial port = 0 - 3300
iPhone = 50 to 100 and jump 12 500 to 14 400

// you can enable debug logging to Serial at 115200
//#define REMOTEXY__DEBUGLOG

// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__WIFI_POINT

#include <WiFi.h>

// RemoteXY connection settings
#define REMOTEXY_WIFI_SSID "RemoteXY"
#define REMOTEXY_WIFI_PASSWORD "12345678"
#define REMOTEXY_SERVER_PORT 6377


#include <RemoteXY.h>

// RemoteXY GUI configuration
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =   // 28 bytes
{ 255, 0, 0, 2, 0, 21, 0, 19, 0, 0, 0, 0, 31, 1, 106, 200, 1, 1, 1, 0,
  67, 30, 55, 40, 10, 118, 135, 1
};

// this structure defines all the variables and events of your control interface
struct {

  // output variables
  //int16_t value_01; // -32768 .. +32767
  char text_V[11];
  signed char level_V;

  // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
//#pragma pack(pop)

void setup()
{
  RemoteXY_Init ();
  Serial.begin(115200);
}

void loop()
{
  RemoteXY_Handler ();
  int val = analogRead(33);
  dtostrf(val, 0, 0 , RemoteXY.text_V);

  Serial.print("   val = ");
  //Serial.println(analogRead(33));  // value
  // Serial.println(val * 0.0008);   // Volt
  Serial.print(val * 0.8);        // mVolt

  Serial.print("  RemoteXY  = "  );
  Serial.println(RemoteXY.text_V);
}