Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Geschrieben

Hello,

I am working on a personal project using the Load Cell Bricklet V2 and I would like to know if the SPI protocol is described somewhere, so I can use an Arduino (with level converters) to talk to it.

I could not find any description of the SPI protocol.

Geschrieben

Hi,

You don't have to implement the SPI protocol yourself if you don't want to. Instead you can use the C/C++ bindings for microcontrollers. Those bindings implement the SPI-TFP protocol for you, so that you can use more or less the same API as with the normal C bindings. See for example here for the Load Cell Bricklet API.

To use the bindings you have to use a Hardware Abstraction Layer (HAL) for your Arduino, but currently there is no generic one available. (We've released the bindings just some weeks ago). You basically have two options here: Patch the Arduino ESP32 Brick HAL or try to use the prototype Arduino HAL, however I'm not sure if this one works right now.

If you really want to implement the SPI protocol yourself, you have to take a look at our implementations, as there currently is no documentation of the SPI protocol. The implementation used in the microcontroller bindings is here: https://github.com/Tinkerforge/generators/tree/master/uc (have a look at spitfp.h/.c)

As a very short overview (so you know what to grep for ;) ):

  • The SPI protocol (called SPITFP) wraps the TFP protocol that is also used over TCP. See here for the TFP protocol: https://www.tinkerforge.com/en/doc/Low_Level_Protocols/TCPIP.html and for example the Load Cell 2.0 packets: https://www.tinkerforge.com/en/doc/Software/Bricklets/LoadCellV2_Bricklet_TCPIP.html
  • SPITFP consists of two header bytes, a wrapped TFP packet (if it is not only an ACK) and one footer byte:
    • The packet length: 3 bytes for an acknowledgement or 11 to 83 bytes for a payload packet
    • The sequence number of this packet (4 bit) and the sequence number that is acknowledged with this packet (also 4 bit)
    • (Footer) A checksum over all packet bytes except this one. This is a Pearson hash . See here for an implementation
  • Only one packet in flight is allowed in each direction. A bricklet will resend the last packet if you don't acknowledge it.
  • Bricklets expect that you send a CoMCU-enumerate as first packet. If you don't, the bricklet will send a response for the enumerate by itself.

 

Geschrieben
  • Autor

Thanks for your answer.

I think I can find my way through it. :-)

Just 2 more questions:

-how do I find the bricklet UID? 

-where do I find information about CoMCU-enumerate?

 

Geschrieben
31 minutes ago, fj2020 said:

-how do I find the bricklet UID? 

The bricklet returns its UID in the enumerate response. For the enumerate request you don't have to set a UID, but use 0 (or "1" if base58-encoded)

31 minutes ago, fj2020 said:

-where do I find information about CoMCU-enumerate?

This is basically the "normal" enumerate: https://www.tinkerforge.com/de/doc/Low_Level_Protocols/TCPIP.html#broadcast-functions but with another function ID (252).

Geschrieben
  • Autor

Ok, That sets it. Thanks a lot...

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.