Hi, I tested the HX710B Air Pressure Sensor Module (0-40kPa) with an Arduino sketch and a library I found on internet and it works fine (see picture).

Also, I think the sensor range is not 0 to 40 kPa as stated but instead has a range of 0 to 10 kPa which is still good for my application. I had 6 sensors in hand, and they all had a range of 0 to 10 kpa.

Using Pd and Bela I would like read the raw data of the pressure values and use it in my patch.

Is it possible to do this with Pd?
Any advice would be appreciated!

Thanks!

Note: The ADC part number associated with this pressure module from what I find on internet is HX710B. The one on mine is TM-7711. But like I said the Arduino sketch works fine.

It's hard to find a datasheet in english for this. This seems to be the closest thing to it, though it may be auto translated from Chinese. Anyhow, it looks like you interact with it as if it was a shift register, without latch pin, sampling on the falling edge of the clock and with tight timing requirements. For that you'll need to use the Bela digital channels at audio rate. The ShiftRegisterIn class is not quite flexible enough to handle this as it doesn't allow to generate the clock, so it has to be done manually. Let's try that first before connecting it to Pd. Try something like this in a new C++ project:

--removed--

The project is running without error, but there are no values on the console.

My setup is like this:
sensor Vcc ---- Bela P9 pin 3 (3.3 v)
sensor GND ---- Bela P9 pin 1 (GND)
sensor SCK ---- Bela P8 pin 7 (D0)
sensor OUT ---- Bela P8 pin 8 (D1)

I included a translated copy of the TM-7711 chip, which seems close to what you found:

Is there anything else I can do?

2304140030-tm-shenzhen-titan-micro-elec-tm7711-c80695-002zh-cnen.pdf
586kB

I amended the code above. Try again.

It now reads inputWord: 16777215, but it does not responds to pressure.

changed again, try that ?

Same result inputWord: 16777215

Same result!

I get same result! Guilio, I really appreciate the effort.!!!

New results.
inputWord :
0
0
0
1
7
79
63
63
63
63
127
127
63
63
319
1119
63
63
63
The values do not change with pressure.

Try this:

#include <Bela.h>

const unsigned int kClockPin = 0;
const unsigned int kDataPin = 1;
const unsigned int kNumBits = 24;
// number of clock pulses being written:
// - 25: differential input
// - 26: temperature or DVDD-AVDD
// - 27: differential input, gain 128
const unsigned int kDataType = 25;
uint32_t inputWord;

bool setup(BelaContext* context, void*)
{
	pinMode(context, 0, kClockPin, OUTPUT);
	pinMode(context, 0, kDataPin, INPUT);
	return true;
}

static unsigned int gCount = 100000;

void render(BelaContext* context, void*)
{
	for(unsigned int n = 0; n < context->digitalFrames; ++n)
	{
		unsigned int loopbackDelay = context->digitalFrames * 2 + 2;
		if(gCount > loopbackDelay + kNumBits * 2 + 800) { 
			// data pin goes low means data is ready and a new acquisition cycle can start
			if(digitalRead(context, n, kDataPin) == 0)
			{
				gCount = 0;
				inputWord = 0;
			}
		}
		bool clk = 0;
		if(gCount < kDataType * 2) // write the clock output
			clk = !(gCount & 1);
		digitalWriteOnce(context, n, kClockPin, clk);
		if(gCount >= loopbackDelay && gCount < loopbackDelay + kNumBits * 2)
		{
			// after the loopback delay, read the data in on the falling edge
			if(gCount & 1)
			{
				// shift data in on odd frames
				bool bit = digitalRead(context, n, kDataPin);
				inputWord <<= 1;
				inputWord |= bit;
			}
		}
		if(loopbackDelay + kNumBits * 2 - 1 == gCount)
		{
			// input is ready
			// extend sign
			if (inputWord & 0x800000)
				inputWord |= 0xFF000000;
			rt_printf("%llu inputWord: %u\n", context->audioFramesElapsed + n, inputWord);
		}
		gCount++;
	}
}

void cleanup(BelaContext* context, void*)
{}

Building project ...
Building render.cpp...
...done
Using library ShiftRegister
Linking...
...done
Build finished
[warning] unused variable 'kRateHz' [-Wunused-const-variable] column: 20, line: 12
/root/Bela/projects/sensor_hx710b/render.cpp:12:20: warning: unused variable 'kRateHz' [-Wunused-const-variable]
const unsigned int kRateHz = 10;
^
1 warning generated.
Running project ...
inputWord: 0
inputWord: 0
inputWord: 6143
inputWord: 4286578687
inputWord: 4286578687
inputWord: 4286578687
inputWord: 4286578687
inputWord: 4286578687
inputWord: 4286578687
inputWord: 4286578687
inputWord: 4286578687
inputWord: 4286578687
inputWord: 4286578687

The values do not change with pressure.

Ok, It is now sensing pressure. The readings are a little odd:

With no pressure or 0.0kpa:
inputWord: 8388607
inputWord: 141498
inputWord: 141501
inputWord: 8388607
inputWord: 141496
inputWord: 8388607
inputWord: 141479
inputWord: 141475
inputWord: 8388607
inputWord: 141493

With 2.5 kpa:
inputWord: 933487
inputWord: 933235
inputWord: 8388607
inputWord: 933093
inputWord: 932807
inputWord: 8388607
inputWord: 932675
inputWord: 932416
inputWord: 8388607
inputWord: 932347

With 5.0 kpa:
inputWord: 8388607
inputWord: 1750196
inputWord: 1749810
inputWord: 1749476
inputWord: 1749034
inputWord: 1748692
inputWord: 8388607
inputWord: 1748567
inputWord: 1748249
inputWord: 8388607

With 7.7kpa:
inputWord: 8388607
inputWord: 2596166
inputWord: 2595908
inputWord: 2595662
inputWord: 8388607
inputWord: 2595496
inputWord: 2595238
inputWord: 8388607
inputWord: 2595106
inputWord: 8388607

With 10.0kpa:
inputWord: 3411910
inputWord: 3411743
inputWord: 8388607
inputWord: 3411650
inputWord: 3411447
inputWord: 3411257
inputWord: 8388607
inputWord: 3411150
inputWord: 3410979
inputWord: 3410801

With 12.2 kpa it tops at:
inputWord: 4194303
inputWord: 4194303
inputWord: 4194303
inputWord: 4194303
inputWord: 4194303
inputWord: 4194303
inputWord: 4194303
inputWord: 4194303
inputWord: 4194303
inputWord: 4194303

Try again, I added a timestamp to get a better sense of what's going on. 8388607 is 23 ones which is a bit of a weird value to read. If the sensor doesn't respond, you'd expect 24 ones. As 4194303 is 22 ones (wheres you'd expect 23 ones as the max value), it may denote that the readings are shifted by one.

Here we go,
Note: The script was restarted at each new pressure to allow for easier data copying.

0.0 kpa:
80 inputWord: 140010
161 inputWord: 8388607
546 inputWord: 140008
8315 inputWord: 140004
8396 inputWord: 8388607
12200 inputWord: 140020
12281 inputWord: 8388607
16084 inputWord: 140036
23853 inputWord: 140026
23934 inputWord: 8388607

2.5 kpa:
80 inputWord: 891767
6781 inputWord: 891759
14551 inputWord: 891767
22320 inputWord: 891729
30090 inputWord: 891655
37859 inputWord: 891591
45629 inputWord: 891469
53398 inputWord: 891353
53479 inputWord: 8388607
57283 inputWord: 891296

5.0 kpa:
80 inputWord: 1769297
5212 inputWord: 1768816
5293 inputWord: 8388607
9097 inputWord: 1768542
16867 inputWord: 1768176
24637 inputWord: 1767781
32406 inputWord: 1767371
40176 inputWord: 1767020
47946 inputWord: 1766622
55716 inputWord: 1766278

7.5 kpa:
80 inputWord: 2551662
6322 inputWord: 2551474
6403 inputWord: 8388607
10207 inputWord: 2551349
17977 inputWord: 2551060
18058 inputWord: 8388607
21862 inputWord: 2550942
21943 inputWord: 8388607
25747 inputWord: 2550776
33517 inputWord: 2550530

10.0 kpa:
80 inputWord: 3387268
161 inputWord: 8388607
3457 inputWord: 3387108
11227 inputWord: 3386794
11308 inputWord: 8388607
15112 inputWord: 3386625
15193 inputWord: 8388607
18996 inputWord: 3386486
19077 inputWord: 8388607
22881 inputWord: 3386322

Tops at 12.2 kpa:
73102 inputWord: 4192181
80871 inputWord: 4194303
88640 inputWord: 4194303
96409 inputWord: 4194303
104178 inputWord: 4194303
111948 inputWord: 4194303
119717 inputWord: 4194303
127486 inputWord: 4194303
135255 inputWord: 4194303
143025 inputWord: 4194303