Comments (21)
The example should work. Something else must be going on - perhaps the network?
To see all socket transactions, including notifications, you can monitor them on a console by setting the node process environment variable PIGPIO=1
.
from pigpio-client.
I am not getting any response in console from notify, only after 30 seconds maybe
notification received: chunk size = 12
can't see any problems with network, I am on local network, If i check pin manually it all works fine, every second.
from pigpio-client.
This indicates that pigpio-client is not receiving any packets. The problem lies somewhere else. Perhaps in your setup.
from pigpio-client.
Any, idea how I could debug that? I don't have anything additional, just pi with node on WiFi local network.
from pigpio-client.
A volt meter to know that you are getting the proper levels when you think the pin should report 1 or 0.
from pigpio-client.
when I read it manually with button.read() , every second , get's values right.
from pigpio-client.
Please provide a test case that shows the failure.
from pigpio-client.
I do get reaction from notify
, but sometimes it takes 30 seconds and more, or it doesn't notify at all
const connectOptions = { host: config.slave.host, timeout: 0 } // timeout!
logger.info('Connecting to slave...')
const pigpio = client.pigpio(connectOptions) // start connecting
slave.PIR = pigpio.gpio(config.slave.pir)
slave.PIR.pullUpDown(1)
slave.PIR.modeSet('input')
slave.PIR.notify((level, tick) => {
console.log(`Button changed to ${level} at ${tick} usec`)
})
from pigpio-client.
You need to first connect the PIR input to something you know is providing transitions between valid pin levels, in other words, pulses.
You can create a pulses by writing to the same pin for which you want to receive notifications.
Disconnect any external circuitry to the input pin first!
For example, create a mock "PIR pulse":
await slave.PIR.write(1);
await sleep(1000); // wait one second
await slave.PIR.write(0);
Run this within an interval timer to get a repeating pulse train.
from pigpio-client.
I am doing it by hardware, switching PIR pin between 3v3 and GND, is that not the same?
from pigpio-client.
Ok, so demonstrate there is a problem with the library.
from pigpio-client.
I don't know if it's library, but I don't do anything complicated yet.
so I added that loop
slave.PIR.notify((level, tick) => {
console.log(`Button changed to ${level} at ${tick} usec`)
})
while (true) {
slave.PIR.read().then((read) => {
console.log(read)
})
await wait(2000)
}
and my console output is ( waiting for notify is actually longer than that, just didn't want to paste it all here):
0
0
1
1
1
1
1
1
Button changed to 1 at 193389531 usec
1
1
0
0
I am changing state by hardware ( jump wire from pin to either GND or 3V3 on PI ).
from pigpio-client.
```javascript
slave.PIR.read().then((err, read) => {
if (err) console.log('err: ', err)
else console.log(read)
})
from pigpio-client.
Sorry, you're using the promise. So use try/catch.
from pigpio-client.
Run your script again using: PIGPIO=1 node yourscriptname.js
Maybe slow it down to not generate so much output.
from pigpio-client.
ok I found the issue. I think I was setting up notify at wrong time. When I've done it on event connect. It works fine.
I will have to make hardware pull down resistor, as it triggers loads of event on single state change.
Well I guess it was my fault after all ;)
from pigpio-client.
Well, glad you got it sorted out.
from pigpio-client.
ok I found the issue. I think I was setting up notify at wrong time. When I've done it on event connect. It works fine.
Makes sense. The notify would be associated with either no socket or a socket that got closed somehow. So if you do get a socket disconnect, you will need to re-init your notifications!
from pigpio-client.
I got to that, when was reconnecting after disconnection. I have to reinit all gpios to make it work after reconnection.
This library has a big potential to create smart houses/devices. With pm2 it can be pretty reliable thing.
from pigpio-client.
pm2 - I'll have to lean more about it. Thanks for the tip.
from pigpio-client.
I'm re-opening this issue because notifications should be self re-initialized to keep consistent with gpio objects which re-connect without requiring the application to re-initialize them.
I'm also going to change the title to make it clear this issue deals with socket disconnection and later reconnection.
I have a few other items to clean up before I release a fix in 1.5.2 in a few days.
from pigpio-client.
Related Issues (20)
- Process exits silently ... HOT 1
- Make hardware PWM work HOT 1
- Network error not handled HOT 55
- Error using waveform HOT 11
- I2C support HOT 24
- lower timeout - for connection monitor HOT 2
- AssertionError [ERR_ASSERTION]: Argument 'gpio' is not a user GPIO. HOT 7
- can't set up pulldown resistor HOT 8
- make install error HOT 1
- Latest Installation Unit File In Git Is Wrong HOT 3
- SPI functionality HOT 10
- gpio.waveAddSerial() only supports 1 stop bit.
- Notify on only one edge HOT 10
- Can't use more than 11 pigpio.gpio() HOT 5
- Timing issues with pigpio-client HOT 1
- Correct way to destroy the instance? HOT 1
- writing and running pigpiod scripts? HOT 4
- i2c full features HOT 2
- timeout on first connect
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pigpio-client.