I’ve tried it with an arduino and it worked perfectly fine. But when I tried it on our raspberry pi with the provided code. It is reading accurate values some of the time but no data for the rest. We think it might be a raspberry pi serial issue but we can’t be sure. There are limited resources online. Our school project doesn’t allow us to use arduino so it is kind of painful at the moment. Any ideas why it won’t work with RasPi?
From the looks of things, DFRobot publishes code for the Pi, so I doubt it’s incompatible.
Is anything changing about the measurements between the Pi and Arduino? (i.e. moving rooms or pointing at a different surface)
Usually, when I have comms problems like this, I like to step back from the library and talk to the sensor “manually” to confirm things are working as expected.
I took a look at the product wiki and it suggests the sensor just throws out measurement data - and doesn’t wait for a command over serial or anything like that.
If you’re on a Pi, you should be able to use the screen command to open up a serial port and see what’s coming out. If it looks intermittent, that’ll give us more to go off. If it’s constant, maybe some of the data is invalid… The serial port in question should be /dev/ttyAMA0
Be careful to poll within 150 milliseconds or you will always get garbage or no data.
This is a really crappy sensor that just blurts out a data stream, and it is up to you to meet its requirements.
3 Likes
And you can get our latest projects and tips straight away by following us on: