Nucleo STM32F303K8 DHT22 AM2302 Virtual PIN no value (empty)

Hello,
I’m using Arduino UNO with Ethernet2 Shield and uploaded the DHT Blynk example code.
The AM2302 sensor works well because I can see the value of temperature and humidity on the serial monitor but not on Gauge in the App.
I read virtual pin V5 and V6 but they don’t show nothing, buttons and switches works well.
I tried IOS and Android App but it’s the same.
I’m using the Blynk Cloud server and Blynk Library version 0.5.4

If I upload other sketches using virtual pins like terminal or if I read analog inputs it works.

Some one can help me please?

Thank you

Don’t show nothing (grammar cop alert :stuck_out_tongue_winking_eye: ) or do show incorrect value? Perhaps something like %3f

You are not using any ESP based devices in this issue, so this might not be the cause, but have you installed the ESP Core for Arduino by any chance?

Only other thing i can think of based on the limited info provided is that you might not have your display/gauge widget set to PUSH (should be set automatically, but check it anyhow). Edit - I tested and it shouldn’t actually matter.

Try using a Value Display or Labeled Display widget as well.

I thing you need to post your code (correctly formatted with backticks), as the standard DHT11 sketch from the Sketch Builder doesn’t write any temperature and humidity data to the serial monitor, so from what you’ve said about…

I’m assuming that you’ve modified the code in some way, or those temp and humidity readings were seen when using a different sketch.

A screenshot of your app setup, in Stopped mode would also be handy.

Pete.

1 Like

Hi guys,
First, thank you for your reply and interest.
Second, I’m sorry for my english…
I changed the topic title because my board is not a genuine Arduino but an STM32 board and I use the STM32 Core to compile the sketch. (I have the ESP Core installed too.)
I tested the same code on a clone of Arduino Nano board with the same configuration and it works well.

So the problem is on the STM32 board.
I would like to discover why it dosen’t work properly on that board…
I tested some widget on the App (Gauge, Value Display, Labeled Value…) but none show the value like if you choose a unused Virtual Pin.

My code is the following:

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************

  This example shows how value can be pushed from Arduino to
  the Blynk App.

  WARNING :
  For this example you'll need Adafruit DHT sensor libraries:
    https://github.com/adafruit/Adafruit_Sensor
    https://github.com/adafruit/DHT-sensor-library

  App project setup:
    Value Display widget attached to V5
    Value Display widget attached to V6
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <SPI.h>
#include <Ethernet2.h>
#include <BlynkSimpleEthernet2.h>
#include <DHT.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "XXXXXXXXXXXXXXXXXXXXXXXXXXX";

#define DHTPIN 9          // What digital pin we're connected to

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11     // DHT 11
#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);

  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.println(" *C");
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth);

  dht.begin();

  // Setup a function to be called every second
  timer.setInterval(2000L, sendSensor);
}

void loop()
{
  Blynk.run();
  timer.run(); 
}

Thank You,

Ezio

OK I guess you mean completely blank displays? - AKA NO value whatsoever?

Reason I asked about the ESP core is that there was a resurgence in an old float display issue (values would show as %3f, instead of proper value), requiring updating the ESP core to 2.4.1+

Yes, completely blank display not a wrong value.
The ESP Core is updated to 2.4.2

Hmmm… I am experimenting with a unique BLE board that also refuses to display any widget data,… probably completely different issue, but some of my suggestions might confirm if yours is just the device to App communication or all around communication issue (even though seemingly connected)

Try to control an LED on the board, both via direct GPIO pin control in a button widget (if an option in the App devices), as well as via virtual pin control with another button widget and a BLYNK_WRITE() function. Does that work?

I did some tests on the STM32 board and discovered that the Blynk.virtualWrite(V5, h) function fail with floating point numbers.
Instead it works with integers and strings.

Somebody know which library is involved with this function?

Ezio