We are about to switch to a new forum software. Until then we have removed the registration on this forum.
There are a few question that has been asked in this forum here that I've followed them already but both did not work with my Rpi.
Here are two from a few of them I have worked around but fail. (1), (2) I see the 2nd example from a site that seems like a legit Github of Processing team (?) is a very updated one but I still get only 0 from it. However, when run the python in terminal my sensors do work well.
I'm using Rpi 3 B and my code is exactly copy and paste from the 2nd. I've created a new folder in Rpi and have two file.pde one is a class and one is a main function (setup and draw).
So, what else should I do or any info that I should looking into to fix this problem?
Answers
Are you getting an error message, or is it just that you are getting
0
instead of values?@Jeremydouglass Not at all! I only get 0. That's why I have no clue to debug or anything. I am not with my Rpi right now So I cannot screenshot/put my code in here. But, I am sure my code is exactly like the link (2). The data coming into Rpi for sure. I can see that through terminal. Also, the organization of my files in a folder also separate into two .pde with similar name like his. Moreover, I have already tried running only Processing code or Python through terminal at different time. In case this is like Arduino talking to Processing over a Serial port where only one can use the port. However, 0 is what I still got.
hmm... I wonder if I have to "turn on" the sensor somehow before click play in Processing IDE? What should I do?
From your second link, it is not clear how you are sending the data, at least not from the second link above. To clarify, you are running Processing in your R-pi and then... how are you retrieving this data? Are you connecting a PC to your R-pi and using a terminal to read the serial port?
Please provide the source code (MCVE).
Kf
Hi @kfrajer,
Here is how I test my sensor. I followed Adafruitinstruction. And, YES! I run processing IDE on Rpi. Here is my code and snapshots from Rpi monitor.
The sensor connect to channel 0 and 1. 0 is a pot and 1 is FSR As you see in these photos![](https://photos-1.dropbox.com/t/2/AABwfCpD3tMOp11Dl7ysCP-JL5I7O2U2ncmpm3t1vma2Yw/12/49114685/jpeg/32x32/1/_/1/2/Photo%20Feb%2025%2C%201%2033%2036%20PM.jpg/EK_r3CUY8sIBIAcoBw/tJr0nzq53wN_x1pAqx1Rhr3tJ98hKrP4jkzoZBmhR6c?size=2048x1536&size_mode=3)
When touch the FSR the channel 1 change its value.![](https://photos-6.dropbox.com/t/2/AACeN_n182fxEkEiDBdGT8jgOA8fIGt66V4DaKItneftdw/12/49114685/jpeg/32x32/1/_/1/2/Photo%20Feb%2025%2C%201%2033%2045%20PM.jpg/EK_r3CUY8sIBIAcoBw/MXoyvv4-8KJp8YLcA8OMbhQ2SGRx3tSNojxZ_fl9tIE?size=2048x1536&size_mode=3)
But in IDE, I only got 0![](https://photos-5.dropbox.com/t/2/AAD_HbQzXiu7T_bOuDiq99TqPrTqbLbEMkOL06f0TCvvmA/12/49114685/jpeg/32x32/1/_/1/2/Photo%20Feb%2025%2C%201%2042%2044%20PM.jpg/EK_r3CUY8sIBIAcoBw/UGu8oFpm45msdlU3Z6BRlFMMIs_H8_MAGEuSm8UgR6U?size=2048x1536&size_mode=3)
@TuangPing
Not sure if I understand correctly: Are you saying that channel 1 works, but channel 0 doesn't? Or are you saying that both are not working in Processing IDE, but in some other environment (which one)?
Hi @gohai, both of the channel work fine with my sensor. But, they do not work with processing. I tried println(adc.getAnalog(1) ); and println(adc.getAnalog(0) ); And I get 0.
What shown in pictures saying that sensors on 0 and 1 are not incorrect installed because terminal of Rpi can see the value that changed. However, I couldn't make IDE of processing see it.
@TuangPing How do you go about determining in the terminal that the ADC is working correctly?
@gohai. What do you mean by determining the ADC? If I understand correctly what you mean; I touched the sensor FSR and rotating the potentiometer and the value change! Although I do not know why the rest of the channels from 3-7 has random values.
@TuangPing What program or tool are you using in the terminal?
@gohai .
Here is a link I follow from Adafruit I have mentioned ealier. However, I attach a link directly to github of that person the python code is loaded from.
To add more detail, according to Adafruit, I went with Software SPI. But, thinking if I should try wire like hardware SPI.
@TuangPing Yes, Processing's IO library only supports the hardware SPI interface. See here: https://github.com/processing/processing/wiki/Raspberry-Pi#spi
@gohai, Hey! Thank you so much :D ! they all work now.
@TuangPing Can you comment on how did you solve your problem please?
Kf
@kfrajer Sure no problem ;D
Look into Adafruit link I provided earlier. There, u'll see they mention a software SPI and a hardware SPI. Like @gohai says, Processing accesses the data from using the hardware SPI not the software. Therefore, you have to connect your pins follow the hardware SPI instruction!
On the Adafuit page, they do not explain this. However, in the link that @gohai posted, which I've selected as the answer, will tell you why.
@TuangPing Thank you.
Kf