Hello, I wanted to save the voltage data to an excel with the date and time, but they are stored in the same column, does anyone know how to separate them?
@Mariano welcome to the forum! So what have you tried so far?
If you create a small example flow that reproduces your issue and export it and paste it to a reply, it will make it easier for someone to help you.
In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```
)
```
code goes here
```
You can edit and correct your post by clicking the pencil icon.
See this post for more details - How to share code or flow json
Thanks for your time, I leave you my code so you can see it.
[
{
"id": "04c3f6fabe43a461",
"type": "function",
"z": "8f292025fe253f81",
"name": "Datos",
"func": "var d= new Date ();\nvar time= d.toLocaleTimeString();\nvar s= {'time':time,'sepam':sepam};\nvar sepam=msg.payloand\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 330,
"y": 300,
"wires": [
[
"2962396ed51da88c"
]
]
},
{
"id": "8a0cffa84df7cbc8",
"type": "function",
"z": "8f292025fe253f81",
"name": "fecha excel",
"func": "var d = new Date()\nvar date = d.getFullYear()+\"/\"+(d.getMonth()+1)+\"/\"+d.getDate()+\" \"+d.getHours()+\":\"+d.getMinutes()+\":\"+d.getSeconds();\nmsg.payload = date\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 350,
"y": 260,
"wires": [
[
"2962396ed51da88c"
]
]
},
{
"id": "ced8e6d520d9bc24",
"type": "debug",
"z": "8f292025fe253f81",
"name": "lectura",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 870,
"y": 280,
"wires": []
},
{
"id": "2962396ed51da88c",
"type": "file",
"z": "8f292025fe253f81",
"name": "",
"filename": "C:\\Lectura de datos\\Registro de datos.csv",
"filenameType": "str",
"appendNewline": true,
"createDir": false,
"overwriteFile": "false",
"encoding": "none",
"x": 640,
"y": 280,
"wires": [
[
"ced8e6d520d9bc24"
]
]
},
{
"id": "ada1cccb4917558c",
"type": "modbus-read",
"z": "8f292025fe253f81",
"name": "Sepam",
"topic": "",
"showStatusActivities": false,
"logIOActivities": false,
"showErrors": false,
"unitid": "",
"dataType": "HoldingRegister",
"adr": "286",
"quantity": "1",
"rate": "10",
"rateUnit": "s",
"delayOnStart": false,
"startDelayTime": "",
"server": "d91e649d.344078",
"useIOFile": false,
"ioFile": "",
"useIOForPayload": false,
"emptyMsgOnFail": false,
"x": 130,
"y": 280,
"wires": [
[
"8a0cffa84df7cbc8",
"04c3f6fabe43a461"
],
[]
]
},
{
"id": "d91e649d.344078",
"type": "modbus-client",
"name": "Medidor",
"clienttype": "tcp",
"bufferCommands": true,
"stateLogEnabled": false,
"queueLogEnabled": false,
"failureLogEnabled": false,
"tcpHost": "192.168.0.87",
"tcpPort": "502",
"tcpType": "DEFAULT",
"serialPort": "/dev/ttyUSB",
"serialType": "RTU-BUFFERD",
"serialBaudrate": "9600",
"serialDatabits": "8",
"serialStopbits": "1",
"serialParity": "none",
"serialConnectionDelay": "100",
"serialAsciiResponseStartDelimiter": "",
"unit_id": "1",
"commandDelay": "1",
"clientTimeout": "500",
"reconnectOnTimeout": false,
"reconnectTimeout": "500",
"parallelUnitIdsAllowed": true
}
]
I already tried to unite everything in the same function but I got an error
I am unable to import your flow.
You need to follow the instructions that @zenofmud posted above.
I suspect you did not use the three back ticks ```
- you did not post your code in a format that makes it importable - did you read the directions I posted?
- You did not create a flow with any input data that demonstrated the problem.
- why do you have two function nodes processing the data? the will each send a seperate msg to the file-write node. If you want the data on the same line you will need a
join
node or combine the twofunction
nodes into one. - your 'Datos'
function
does nothing, it gets a msg in and then sends the same msg out without changing the msg at all,
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.