[Dprglist] Communication between RPi and QTPy

Chris N netterchris at gmail.com
Wed Sep 29 19:54:40 PDT 2021


In a nutshell:
*On the QtPy :*
* program the qtpy using VSCode + PlatformIO + Arduino framework
* I usually run VSCode on my Windows/Linux laptop and use the VSCode
"remote" feature, but that was not working reliably for this case, so for
this I simply run VSCode on the Pi directly and use VNC
* use the "Adafruit_BNO08x" Arduino library
* add a 1sec delay at power-up / reset, to allow the virtual serial port to
get properly initialized and to give the Pi and QtPy some time to do their
virtual serial port handshaking
* be sure to explicitly reset the bno - i have found that otherwise it
sometimes does not work properly on power-up
* configure the bno085 to report "game rotation vectors" @ 100Hz
* use polling to get the values from the bno085 (no I/O pin left on the
QtPy to use the interrupt signal from the bno085)
* @ 100Hz, print current time, yaw and the 8 analog readings from the
QtPy's analog inputs using Serial.printf() like so:
*
Serial.printf("%09lu,%+07.3f,%03d,%03d,%03d,%03d,%03d,%03d,%03d,%03d\r\n",
t_now, imu_yaw, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7])

*On the Pi:*
* using python
* use serial.read()  from the python serial library - with timeout   ( not
serial.readline()  - that one does not perform well)
* parse the comma-separated values (see printf() statement above)  via the
scanf function from the scanf python library
* do some math to compensate for the ~1.5 ... 2.0 degrees worth of
offset/error that accumulates for every 360 degrees of rotation.

I invited you to 2 of my github repos.  romi/qtpy.py   is the code for the
Pi,   io_slave_2 is the code for the QtPy itself.


On Tue, Sep 28, 2021 at 11:01 PM Thalanayar Muthukumar <tnkumar at gmail.com>
wrote:

> Hi Chris,
>
> I also have a QTPy connected to a BNO055 and would like to have the
> information accessible to the RPi.
>
> It was interesting to hear of the communication you have built between the
> RPi4 and QTPy.
>
> If you have any pointers on how to accomplish this, will appreciate it.
> Thanks.
>
> Regards.
> - Kumar
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dprg.org/pipermail/dprglist-dprg.org/attachments/20210929/d1c27346/attachment.html>


More information about the DPRGlist mailing list