Requesting the state of a PB widget from code on the controller

Hello @PeteKnight

If a command is pressed/sent whilst the hardware is in sleep mode, it would be missed. However, if the command is continuously transmitted then once the hardware returns from sleep mode the command will be received by the hardware and an acknowledgement can be sent to Blynk, from the hardware, to stop any further transmission of the command by Blynk.

No, I can’t see any way of doing that.
You’ve said previously that communication has to be via Bluetooth. Is there anyway that you can use a stand-alone system like this:

Pete.

1 Like

Okay thanks Pete. unfortunately this late in the design stage, i will not be able to change my hardware. I guess its back to the drawing board.:slightly_frowning_face:

Maybe you should forget the deepsleep and simply add a bigger battery, or a solar charger to the setup.

Pete.

Hello Pete

Is there anyway to ‘view’ that state of the Push button widget from the hardware? For example when the Push button is pressed, it changes state from ‘On’ to ‘Off’. Visually you see the widget has turned ‘On’/‘Off’. Is there someway to ‘see’ this state from the hardware ?

The simplest way is to print the state to the serial monitor, but this obviously needs the device to be connected to your PC.

You could add a physical LED to one of your pins and switch this on/off to mimic the on/off state that is toggled via the momentary switch, but this would obviously impact on power consumption.

Pete.

Okay sorry let me clarify why i am asking. It is in relation to the topic of detecting if a Push button has changed state and was missed due to the fact that the hardware was asleep. So to reiterate: The Push button is pressed, the hardware is asleep, it misses the change in parameter but the Push Button widget on the app has changed state, visually. It shows on the app that it is now e.g. ‘On’. Is there any for me to request the state of the Push button, since it has changed state, and get some value back from it, presumably a 1 or a 0, which my hardware can use to ‘see’ if it missed a change in state.

If you’re using Wi-Fi or Ethernet then yes, you can do a Blynk.sync(VPin) to force a BLYNK_WRITE(VPin) that pulls the current widget value from the server.
I don’t think this is possible using Bluetooth, but you’d need to experiment.

Pete.

Okay this topic is in relation to a BLE connection. The Blynk.sync(VPin) does not seem to work. You mentioned in an early post that there is

I think the answer is that it doesn’t, as I don’t believe there is currently any pass-through between the BLE connection to the device and the Wi-Fi/Cellular data connection from your phone to the Blynk server.

I think you are right, however through the superchart widget there appears to be work around this because it seems the data that i send to the superchart is being stored on Blynk servers: I am able to scroll back and see past data even though my hardware is connecting to blynk via bluetooth. This should imply that the superchart widget takes the data from hardware via BLE and stores it on the server?
I do not under the mechanism it uses but is there a way to exploit it to obtain the state of a PB ?

What data is being stored on superchart?
When the button is pressed or data from your hardware device?

Data from my hardware. I am actually testing to see if the push button change of state can be viewed on the superchart

It is being mapped to the Superchart. Each time i press the PB it’s change in state is displayed on the superchart. Even if there is no functionality programmed into the hardware for the PB, simply because the state of the PB is changing from ‘On’/‘Off’ is captured by the Superchart. I am wondering is there is a way to exploit this somehow.

I am not sure about that as I’ve never used superchart.

But as a workaround, could you not use an interrupt to wake the device and trigger what you like.

Also are you trying sync all or syncing a specific virtual pin?

If it was a physical button then yes, but this is a widget button.

I still think that using Wi-Fi, or forgetting about sleep and going for a bigger battery is the better option.

Pete.

Thanks @JustBertC
I am not sure how to use Blynk’s virtual pins to wakeup or trigger an interrupt. Is that possible?

If i could use those commands that would make things a lot easier, unfortunately it does not seem to work over bluetooth.:disappointed:

@Gunner @PeteKnight

I am trying this command and it should work since my app/cellphone is connected to Blynk’s servers, it is the communication between my hardware and app that is bluetooth:

BLYNK_APP_DISCONNECTED()

But it seems this does not work for some reason

I still think that using Wi-Fi, or forgetting about sleep and going for a bigger battery is the better option.

I wish i could but these are not an option for me.:frowning_face:

As you’re using BLE then you’re using an app to device connectIon, I would have thought that the Blynk app will be disconnected from your device every time the device goes to sleep.
Having said that, I’ve never used BLE, or an Android device, so have no practical experience.

Pete.

What about the option of adding a solar panel to top-up the battery a little?

Pete.

That is my thoughts as well !! I am trying to exploit this but the command does not run when i disconnect my hardware from the app.