techpaul wrote:Brief look suggests the 'A' pin is their 'ACTION' pin which is their version of the SPI Slave Select signal, dont GND this signal connect it to the correct Slave Select signal from the Pi
Yes, A is actionpin with active low. For testing purposes connecting this to the ground should be equivalent with connecting this to the slave select signal and pulling this low.
techpaul wrote:I suspect you have not soldered wires and with the device permanently selected any noise or intermittent connection is giving extra clock pulses and that is why it is continuously running.
I soldered male pins to the thermometer PCB and inserted it to the breadboard. Also, data output is 2kHz, noise frequency should be random.
PiGraham wrote:How are you doing the software 2kHz clock?
You could implement a software SPI by bit-bashing gpio lines for clock and data, ignoring the SPI hardware functions.
Is that what you mean? You may have issues with inconsistent clock frequency.
Python testing code:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)# action
GPIO.setup(3, GPIO.OUT)# clock
GPIO.setup(2, GPIO.IN)# data
GPIO.output(4, False)# action pin is active low
start = time.time()
res = ''
for x in range(2000):# measure 2k in 1s
GPIO.output(3, True)# clock up
time.sleep(0.00025)
GPIO.output(3, False)# clock down
res += ('1' if GPIO.input(2) else '0')#
time.sleep(0.00025)
print(time.time() - start)# tune sleep time so time diff would be 1s
with open('spi.txt', 'w') as myfile:
myfile.write(res)
edit: Thank you for your comment. Set clock pin to input and saved it's states, turns out thermometer sends clock signal. Datasheet didn't mention it acts as a master, I assumed Raspberry should send clock signal. Although Raspberry don't have hardware SPI slave support, I guess I can write my own code using Raspberry as a slave.