Interfaces for communicating hardware devices

Howdy!

I have a question about how people are implementing communications between different hardware devices or modules (possibly asynchronously, possibly horizontally).

For example, I would like to know how OurSci’s reflectometer communicates with the SurveyStack Android app (hi @gbathree and @OctavioDuarte).

Questions:

  • What makes up a message in that interface?
  • What criteria might be important when choosing protocols and message structure?
  • Are there standard ways to get devices talking to each other?

I feel that I’m struggling hopelessly with Python’s serial interfaces and threading, so I’d like to know if there are easier/standard ways to get devices to talk to each other.

Thanks :slight_smile:

Nico


Context: I just posted an issue to the OpenTrons repo, asking about the best ways to make their products “interoperable” with other CNC machines.

1 Like

I’m a big fan of the W3C Web of Things standard, which defines a lot of those things. It’s not intended for scientific hardware specifically, more aimed at common IoT devices like light bulbs and thermostats, but there’s no reason it can’t handle more complicated datatytpes. We use it for the OpenFlexure Microscope, and it has proven to be quite a good solution, especially when trying to integrate multiple different devices together.

I think, provided your device is powerful enough to handle HTTP, it’s usually a good way to go. There are tons of good libraries in different languages supporting HTTP interfaces, and lots of good conventions on how to write them.

I was recently involved in a really fun project led by @beniroquai where we hooked up the OpenFlexure software, an OpenTrons OT2, and ImJoy for image processing, all controlled by a Jupyter notebook. I think the OpenTrons sort of has an HTTP interface, but it doesn’t expose the full functionailty: it’s mostly intended to be used to upload a protocol, which the OT2 then executes using its on-board computer. I am fairly sure the most successful configuration ran the Jupyter notebook directly on the OT2, which does give a Python API for its own functions, and then used the HTTP API to control the OpenFlexure server. It’s written up in a paper in Advanced Biology (open access).

2 Likes

Yes! I came across the paper recently. Astounding :B

Then perhaps HTTP will be the way to go. I’m not familiar with the W3C standard, nor with any other standard so far :P, so it seems a bit daunting. I’ll try reading up on it.

Thanks Richard!

1 Like

Just some use case notes:

By chance or context, the pipetting robot I’m working on has components similar to OT’s: a web GUI → JSON → python module → GCODE → hardware drivers.

What troubles me is that I can’t really envision how to standardize the hardware driver end. We’re using Arduino with GRBL, so HTTP may be impossible. Do you think the WoT standard can help?

A solution for CNC controllers may be Klipper, which @jeremycahill is already considering. Klipper can drive many CNC controller boards (many different and many simultaneously), and be driven through a virtual serial interface or API server.

Klipper seems nice for hardware-agnosticism and the web-standard stuff (which I have to read up on).

Sidenote: I just realized that the OFM has python drivers for GRBL. There is also the Gerbil module, and the module I wrote. Why did this happen? xD

1 Like

Sorry for the last response.

We use a valid JSON (ASCII Serial/Uart) as the command and as the response. It allows us to use things like BT Serial protocols, along with other types of communication mechanisms, in a pretty general way.

It contains a meta section at the top level and then a data section for the bulk data. It’s not terribly consistent, there are other sections that deliver data which have custom names.

But happy to share the details. I’m realizing in writing this I don’t think I have it described well, though if you have a device you could easily see it. It’s often shortened before the data is saved (the full raw output isn’t necessarily saved) so it’s not really visible in the existing saved data we have. If you’re interested I can post here an example and break it down if that’s helpful.

2 Likes