Blynk with Raspberry Pi - power on and off

Can anybody help with explaining the rules for:

Turning the Pi on and off, how does the blynk server respond? does it re load the previous instructions?

What happens when the blynk app is turned off and on?

Not unless you have configured it to do so with crontab or similar.

Do you mean Pi as a local Blynk server, or a client or both?

I have crontab loading Blynk on power up, that works ok.

Its the rules when I power down Blynk app by logging out or closing app. What should happen?

And …

I use blynk on the Pi in client mode.

As a rule, you should always safely shutdown the RPi, not just pull the plug!! Since it is a small computer and not just a simple MCU, rapid power loss could scramble data.

Blynk as a client on an RPi can probably be shutdown or restarted anyway you like (just as on any MCU) as it just simply starts running the script as normal on bootup (assuming the script is called via Crontab or similar, as per @Costas).

Blynk as a Server on the RPi, as any server, what being the heart of something, may also lose some data or possibly corrupt if rapidly losing power instead of a proper shutdown.

Basicly the power ON and OFF issue with an RPi is the same regardless of Blynk or any other programs running on it… Shutdown properly before losing power, or risk data corruption!![quote=“Johnuready, post:1, topic:16795”]
how does the blynk server respond? does it re load the previous instructions?

The server may keep sending info out (if the App is also sending info) however, if the client is offline, then the data goes nowhere. Upon reboot the client will simply pickup any new data from the time it goes online.

At client sketch boot, you can use Blynk.syncAll() to grab whatever the last vPin settings where, but only the last settings, not picking up from where it left off.

Thanks, It was the Server / App bit I was not sure about, You mentioned Blynk.syncALL(), is that designed to reload the Digital or Virtual pin information?

How would I use Blynk.syncALL()? do you have any examples?

Check out the link in my last post. For sure on vPins… But I am not quite sure what it does with Digital/Analog pins since I almost never use direct pin manipulation in the App.

Just simply run the command… it is usually used to restore last sent vPin state after disconnection, but it can be ran any time… just no real reason to do so otherwise.

Thanks for the update, think I’m getting there. The Blynk.syncALL(), am I right that this could be added to the Blynk start up script that I load in crontab on boot?

It will reload the last held information held on the Blynk server when my Pi is rebooted?


Are you able to paste a copy of this?

I load in crontab:

cd ~/blynk-library/linux && sudo ./blynk --token=XXXXXXXXXXXXXXX

I think he ment paste a copy of your script

@Johnuready all the Blynk commands, including syncAll(), have to go in a script, you can’t simply try to slip them in crontab.

I did, but I suspect he may not have one other than the default.

Yes its the default as lifted from a Youtube example.

It work fine with the app. I switch 3 no. digital pins with my Python program watching the for a change of state of the GPIO’s and switching mosfets / relays.

1 Like

Anybody have ideas on how I can use the “syncAll()” command when I use the default login?

@Johnuready take a look at this syncAll() example

Thanks for the syncAll() link.

I have never coded in JS, only just got back to programming with Python after a 38 year break from Basic. Getting on OK with Python now, booked on an intermediate training course next week.

As I’m just starting with JS can anybody just note what each line is doing on the above example.


Maybe we turn that around and you tell us what you think they are doing.