Hello,
can someone give some tips to do the following
want to calculate the time the rpi-gpio in node vlaue 0 or 1 .
for every month , and put inside a table for eaxmple
januray vlaue 1 (300 hr) and vlaue 0 ( 420 hr )
There are many ways of doing that, but I would do that by writing each transition to an influxdb database and then getting the value you want by querying the database.
installed the influxdb and created the database . values are getting inside
but something weird , the gpio-in node have value 0 but the debug node keeps giving 0 1 0 1 0 1 all the time and also the values inside database are 0 1 0 1 0 1 0 1
Which debug node?
i connected the rpi-gpio in directly to debug to see the values
Show us a screenshot of some of the output in the debug pane please.
Also tell us what is connected to the input and how you have wired it up.
optocoupler 220v connected to the rpi-gpio in node . that value under test which is 0 is always correct when there is 220v the value is 0 and when 0v the value changed to 1 but dont know why on the debug the vlaue changes between 0 and 1 all the time .
10/18/2022, 9:41:29 AM[node: debug 2]gpio/5 : msg.payload : number
0
10/18/2022, 9:43:45 AM[node: debug 2]gpio/5 : msg.payload : number
1
10/18/2022, 9:43:46 AM[node: debug 2]gpio/5 : msg.payload : number
0
10/18/2022, 9:44:04 AM[node: debug 2]gpio/5 : msg.payload : number
1
10/18/2022, 9:44:05 AM[node: debug 2]gpio/5 : msg.payload : number
0
10/18/2022, 9:46:13 AM[node: debug 2]gpio/5 : msg.payload : number
1
10/18/2022, 9:46:14 AM[node: debug 2]gpio/5 : msg.payload : number
0
10/18/2022, 9:46:16 AM[node: debug 2]gpio/5 : msg.payload : number
1
10/18/2022, 9:46:16 AM[node: debug 2]gpio/5 : msg.payload : number
0
There is noise on the input signal. Show us the circuit for how you have connected it. Probably it needs a pullup resistor or something like that.
You may just need to enable the pullup in the GPIO node.
. optocoupler Out and vcc(5v) and ground directly to rpi pins . no resistor used in circuit but the value is correct under the node . and if we connect a led also it worked but when using influx to store the data i saw that values are changing all the time
If you are driving the photo coupler with 5v does that mean the output can go up to 5v? If so you may damage (or have damaged) the gpio pin on the pi. What opto couple is it? A link to the datasheet too please. You should probably connect it to 3.3v not 5v, but without knowing the details it is impossible to know.
if we connect a led also it worked
Can you show us how and where you connected the Led?
Channel Optocoupler Isolation Module
Product Introduction:
1.Function:test whether AC 220V is existed;when there is 220V,optocoupler can be conductive to ground;otherwise,it is not conductive
2.Output High/Low Level:can directly connect with SCM IO interface to test,voltage is 3-5V
3.Adaptive to connect with PLC,compatible to almost all PLC input
[
{
"id": "50ebba959cf35c38",
"type": "ui_led",
"z": "1575273d54101248",
"order": 1,
"group": "68a5855e.4266cc",
"width": 0,
"height": 0,
"label": "test",
"labelPlacement": "left",
"labelAlignment": "left",
"colorForValue": [
{
"color": "#ff0000",
"value": "1",
"valueType": "num"
},
{
"color": "#008000",
"value": "0",
"valueType": "num"
}
],
"allowColorForValueInMessage": false,
"shape": "circle",
"showGlow": true,
"name": "",
"x": 290,
"y": 160,
"wires": []
},
{
"id": "48b7ab0850a4cca1",
"type": "rpi-gpio in",
"z": "1575273d54101248",
"name": "",
"pin": "13",
"intype": "up",
"debounce": "25",
"read": true,
"bcm": true,
"x": 500,
"y": 160,
"wires": [
[
"ca571d44facb9126",
"50ebba959cf35c38"
]
]
},
{
"id": "68a5855e.4266cc",
"type": "ui_group",
"name": "RPI",
"tab": "e54128cb.58c8d8",
"order": 2,
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "e54128cb.58c8d8",
"type": "ui_tab",
"name": "RP",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
]
Oh OK, not a physical LED then (which would have involved adding a resistor).
Does the value keep changing when the 220 volts is connected, when it is not connected, or both?
Stop node red and start it again in a terminal and post the output here. If you installed using the recommended method you can do that using the commands
node-red-stop
node-red-start
i restarted node red. but i see that the problem happened only when 220v is connected.
maybe i should shift the vcc to 3v ?
because when no 220v only one value appeared which is 1
Please post the log I asked for.
value below from influxdb
time value
1666122203127000000 0
1666122230865000000 1
1666122230885000000 0
1666122253104000000 1
1666122253130000000 0
and the pictures attached are from node red
If you connect a wire from the gpio pin to 0v does the value stay at 0?
Also what hardware are you running on? Is it a PI?
i didnt get ur point
im using rpi 3 B+