Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [leshan-dev] Implement ultrasonic sensor as Leshan client

Hi,

Thank you for your response. I tried a a random generating sensor and it works perfectly as the example. So it is best to say that the problem comes from my implementation of the sensor. Let me explain a bit further about my scenario. I use an ultrasonic sensor to collect the distance value through the GPIO pin of the raspberry Pi. To access those GPIO of the raspi, I have to use the library pi4j, so all those gpio stuff comes from that library. The thread.sleep in adjustDistance is to create the "rest time" between the high pulse and the low pulse of the ultrasonic, so the distance value can be calculated based on those pulses. As I mentioned, the leshan server can read the value from the ultrasonic, but only once because the adjustDistance method seems not to loop inside the runable() of the main method DistanceSensor. My best bet is that the runable() try to initiate the new run when the adjustDistance() hasn't finished yet, so I tried to increase the period time in scheduler.scheduleAtFixedRate but it doesn't work either.

Best regards,
Thong Q. Nguyen 

2017-07-31 15:27 GMT+02:00 Simon Bernard <contact@xxxxxxxxxxxxxxx>:

Hi,

The "leshan" code seems ok.

All the Thread.sleep in adjustDistance sounds strange to me.

Did you try to implement a dummy/mock sensor with random generating value ? without all the gpio stuff to be sure the problem is not there. (This will be easiest for us to reproduce)

Simon


Le 31/07/2017 à 14:53, Thong Q. Nguyen a écrit :
Hi all,

I am trying to implement an ultrasonic sensor (connect to my raspberry pi) as a leshan client and make the server observes the collected data from that sensor. I use the leshan-client-demo/RandomTemperatureSensor as the template. So far, I can use the web UI of leshan server to read the data from my sensor, but the problem is that the sensor value doesn't update in one running session (I have to restart the leshan client to get the new value of the sensor in the web UI). My full code for that class is here https://pastebin.com/av3WNbd1.

I don't know if this is off-topic here or not, but hopefully you can give me some suggestions :)

Thank you in advance.
Best regards,
Thong Q. Nguyen


_______________________________________________
leshan-dev mailing list
leshan-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/leshan-dev


_______________________________________________
leshan-dev mailing list
leshan-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/leshan-dev



Back to the top