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

I think the solution is to use Wi-Fi rather than Bluetooth.

Also, a word of advice for the future…
When you start a new topic the template you are presented with asks you to include quite a bit of background information. If you’d mentioned Bluetooth in that first post the answer would have been forthcoming much quicker.

Pete.

That would make my life so much simpler but unfortunately the design criteria for this project requires me to use Bluetooth :sweat_smile:

@PeteKnight @Gunner

In an attempt to find an alternate solution this problem i would like to know if there a way for Blynk to continuously send a command, in this case the PB sends an ON or OFF state, to the hardware and only stops sending this command when an acknowledgment is sent back from the hardware ? This would be simple enough to program on the hardware side but i am not sure how to force this behavior on Blynk’s side.

I’m not aware of any way to do that.
However, I don’t see how this is a potential solution to your desire to use Bluetooth and sleep mode. Can you explain a bit more about what you’re thinking?

Pete.

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