BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Create txt or csv file from blynk virtual pins


#1

is it possible to create a txt or csv file on a local server directory,
containing the data of a value widget by the action of a widget button ?
I tried reports button , but we can only generate a mail…
I would like to export data to an ERP software.


#2

But email contains CSV, isn’t it?
As additional option you can add DB and do export of data from it.


#3

yes but ERP software can only import TXT or CSV files automatically from windows directory,
with a sql request.(not postgressql)
so it’s not a good solution to open mail and save CSV, no more to export data from DB.


#4

if somebody needs to transfert data from blynk to PC or PC to blynk, this is the solution :

you need to use Windows powershell
open PS console and put your code

to write to multiple virtual PINs

Invoke-WebRequest http://[blynk local server IP:port]/[ Blynk Auth ]/update/V1?value="6.800"
Invoke-WebRequest http://[blynk local server IP:port]/[ Blynk Auth ]/update/V2?value="6.920"
Invoke-WebRequest http://[blynk local server IP:port]/[ Blynk Auth ]/update/V3?value="7.200"

to read from multiple virtual PINs

$V1 = Invoke-WebRequest http://[blynk local server IP:port]/[ Blynk Auth ]/get/V1?
$V2 = Invoke-WebRequest http://[blynk local server IP:port]/[ Blynk Auth ]/get/V2?
$V3 = Invoke-WebRequest http://[blynk local server IP:port]/[ Blynk Auth ]/get/V3?
$V1.content+
$V2.content+
$V3.content

result
["6.800"]["6.920"]["7.200"]

you can send output to a csv file using

$V1.content+$V2.content+$V3.content | Out-File -FilePath C:\blynk\data.csv

enjoy :wink:


#6

if you need a clean csv and add coma for Excel, this is the cleaning code

$V1=$V1.content.Replace('[','').Replace(']',',').Replace('"','')
$V2=$V2.content.Replace('[','').Replace(']',',').Replace('"','')
$V3=$V3.content.Replace('[','').Replace(']','').Replace('"','')

$V1+$V2+$V3 | Out-File -FilePath C:\blynk\data.csv

01-024928


#7

if you need Header row :
01-024929

$Header="V1,V2,V3"+ "`n"

$Header+$V1+$V2+$V3 | Out-File -FilePath C:\blynk\data.csv