There is same problem..
This is the program I typed.
#include <Wire.h>
#include <TuyaWifi.h>
#include <pocketBME280.h>
TuyaWifi my_device;
pocketBME280 mySensor;
#define BME280_I2C_ADDR 0x76
#define DPID_PRESSURE 101
#define DPID_TEMPERATURE 102
#define DPID_HUMIDITY 103
#define DPID_BATTERY 104
#define DPID_CONNECTION 105
unsigned char led_state = 0;
int wifi_key_pin = 7;
int analogInPin = A0;
int connectionPin = 2;
const float batteryVoltageDividerRatio = 3.0;
const float batteryVoltageThreshold = 5.0;
int pressure = 0;
int pressure1 = 0;
int temperature = 0;
int humidity = 0;
int batteryLevel = 0;
int batteryVoltage = 0;
int connection = 0;
int connection1 = LOW;
float previousPressure = 0;
float previousTemperature = 0;
float previousHumidity = 0;
float previousBatteryLevel = 0;
float previousConnection = 0;
float previousConnection1 = 0;
unsigned char dp_array[][2] =
{
  {DPID_PRESSURE, DP_TYPE_VALUE},
  {DPID_TEMPERATURE, DP_TYPE_VALUE},
  {DPID_HUMIDITY, DP_TYPE_VALUE},
  {DPID_BATTERY, DP_TYPE_VALUE},
  {DPID_CONNECTION, DP_TYPE_ENUM},
};
unsigned char pid[] = {"xxxxxxxxxxxxxxxx"};
unsigned char mcu_ver[] = {"1.0.0"};
/* last time */
static unsigned long last_time = 0;
void setup()
{
  Serial.begin(9600);
  
  Wire.begin();
  //Initialize led port, turn off led.
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);
  //Initialize networking keys.
  pinMode(wifi_key_pin, INPUT_PULLUP);
  my_device.init(pid, mcu_ver);
  //incoming all DPs and their types array, DP numbers
  my_device.set_dp_cmd_total(dp_array, 6);
  //register DP download processing callback function
  my_device.dp_process_func_register(dp_process);
  //register upload all DP callback function
  my_device.dp_update_all_func_register(dp_update_all);
  
  last_time = millis();
}
void loop()
{
  my_device.uart_service();
  //Enter the connection network mode when Pin7 is pressed.
  if (digitalRead(wifi_key_pin) == LOW) {
    delay(80);
    if (digitalRead(wifi_key_pin) == LOW) {
      my_device.mcu_set_wifi_mode(SMART_CONFIG);
    }
  }
  /* LED blinks when network is being connected */
  if ((my_device.mcu_get_wifi_work_state() != WIFI_LOW_POWER) && (my_device.mcu_get_wifi_work_state() != WIFI_CONN_CLOUD) && (my_device.mcu_get_wifi_work_state() != WIFI_SATE_UNKNOW)) {
    if (millis()- last_time >= 500) {
      last_time = millis();
Code: Select all
  if (led_state == LOW) {
    led_state = HIGH;
  } else {
    led_state = LOW;
  }
  digitalWrite(LED_BUILTIN, led_state);
}
 
  }
  /* get the temperature and humidity */
  get_bme280_values(&pressure, &temperature, &humidity, &batteryLevel, &connection);
  /* report the temperature and humidity */
  if ((my_device.mcu_get_wifi_work_state() == WIFI_CONNECTED) || (my_device.mcu_get_wifi_work_state() == WIFI_CONN_CLOUD)) 
  {
    my_device.mcu_dp_update(DPID_PRESSURE, pressure, 1);
    my_device.mcu_dp_update(DPID_TEMPERATURE, temperature, 1);
    my_device.mcu_dp_update(DPID_HUMIDITY, humidity, 1);
    my_device.mcu_dp_update(DPID_BATTERY, batteryLevel, 1);
    my_device.mcu_dp_update(DPID_CONNECTION, connection, 1);
  }
  if (millis()- last_time >= 5000) {
  last_time = millis();
  }
}
void get_bme280_values(int *pressure_value, int *temperature_value, int *humidity_value, int *batteryLevel_value, int *connection_value)
{
  mySensor.startMeasurement();
  int32_t pressure1 = mySensor.getPressure(); // hPa
  pressure = map(pressure1, 92750, 124750, 0, 400);
  temperature = (mySensor.getTemperature() / 100);
  humidity = (mySensor.getHumidity() / 1024);
  batteryVoltage = analogRead(A0) * (5.0 / 1023.0) * batteryVoltageDividerRatio;
  batteryLevel = map(batteryVoltage, 5.0, 9.0, 1, 100);
  connection1 = digitalRead(connectionPin);
  previousPressure = pressure;
  previousTemperature = temperature;
  previousHumidity = humidity;
  previousBatteryLevel = batteryLevel;
  previousConnection = connection;
  
  if (pressure <= 0) pressure = 0;
  if (batteryLevel < 1) batteryLevel = 0;        
  if (connection1 == LOW) connection = 1;
  if (connection1 == HIGH) connection = 0;
  if (pressure != previousPressure  temperature != previousTemperature  humidity != previousHumidity  connection != previousConnection 
  abs(batteryLevel != map(previousBatteryLevel, 5.0, 9.0, 0, 100)) < 1 > 1) {  
  void dp_update_all(void);
  }
}
unsigned char dp_process(unsigned char dpid,const unsigned char value[], unsigned short length)
{
  /* all DP only report */
  return TY_SUCCESS;
}
void dp_update_all(void)
{
  my_device.mcu_dp_update(DPID_PRESSURE, pressure, 1);
  my_device.mcu_dp_update(DPID_TEMPERATURE, temperature, 1);
  my_device.mcu_dp_update(DPID_HUMIDITY, humidity, 1);
  my_device.mcu_dp_update(DPID_BATTERY, batteryLevel, 1);
  my_device.mcu_dp_update(DPID_CONNECTION, connection, 1);
}