Widget display doesn't receive and display any thing

hi all,

i am trying to build a system to control a led and display a voltage using hc-05 and arduino uno…

i add a button(to control a led) and level display (to display a voltage)…

when i press the button the led turned on and off depending on its state :slight_smile:

but the level display does not display the voltage on pin A0 :slight_smile:

thanks in advanced ^^

Did you provide any code for obtaining the voltage from A0?

No.
I have just uploaded the hc-05 example ^^

You mean this?

#define BLYNK_USE_DIRECT_CONNECT

#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX

#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleSerialBLE.h>

char auth[] = "YourAuthToken";

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

  // Blynk will work through Serial
  // 9600 is for HC-06. For HC-05 default speed is 38400
  // Do not read or write this serial manually in your sketch
  Serial.begin(38400);
  Blynk.begin(Serial, auth);
}

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

Ask Google how to read voltage on an Uno and add that to your sketch with BlynkTimer like in the PUSH_DATA example

i have tried this and the problem still exist ^^

 *************************************************************/

#define BLYNK_USE_DIRECT_CONNECT

// You could use a spare Hardware Serial on boards that have it (like Mega)
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX

#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleSerialBLE.h>

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

void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
   Blynk.virtualWrite(V0,analogRead(A0)*5.0/1023.0);
}


void setup()
{
  // Debug console
  DebugSerial.begin(9600);
  pinMode(A0,INPUT);

  // Blynk will work through Serial
  // 9600 is for HC-06. For HC-05 default speed is 38400
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(Serial, auth);
  timer.setInterval(1000L, myTimerEvent);
}

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

:frowning:

Are you using a USB2TTL adaptor with the Uno i.e. for DebugSerial()?

If you are add this as the first line of myTimerEvent() and paste your full Serial Monitor output:

Serial.println(analogRead(A0)*5.0/1023.0);

You shouldn’t need this at all… the ADC pins are by design, inputs… setting this may affect how it normally works?

PS, My experience with BT has been sketchy for even simple things like reading analog pins… not sure if it is an issue in the library or not, but I sometimes add in this line to disable direct App/pin manipulation and rely strictly on virtual pins.

#define BLYNK_NO_BUILTIN  // Disable built-in analog & digital pin operations

I believe Blynk sets all the normal pinMode() entries for physical pins tied to widgets.

this what i got on debug terminal (pin 3)

[1] ___ __ __ / _ )/ /_ _____ / /__ / _ / / // / _ / '/ ///_, /////_\ /__/ v0.4.8 on Arduino Uno
[152] Connecting…
[6152] Connecting…
[12152] Connecting…
[18152] Connecting…
[24152] Connecting…
[30152] Connecting…
[36152] Connecting…

and nothing received on terminal connected with Tx pin(pin 1) of the arduino ^^

This shows that you got connected

But then…

This says you didn’t… so what changed?

Besides… your code is incorrect for both connecting to a BT module (via Softserial) and watching the IDE Serial monitor (via primary UART)

Try loading this current example:

Then add in your timer and void myTimerEvent()