How to develop 3rd party software to control FarmBot


#1

We are trying to develop a separate software to control FarmBot. I found that I can send the control message through MQTT. However, I did not find detailed information on how to use MQTT to control FarmBot. Is there any tutorial on how to do it?

Thanks!


#2

We have recently published developer documentation describing the process. Does that answer your question, or did you have a more specific question in mind?


#3

Thanks, Rick.

Yeah. I want to create software with a UI using C++. The UI has buttons to move the FarmBot arm around. Do I first communicate with the Web API? Then the Web API talks with the Raspberry PI through MQTT? And then the Raspberry PI control the FarmBot? Or could I directly communicate with the Raspberry PI through MQTT from my software?

Is there a library I can use to accomplish this? What is the best way to communicate with the FarmBot either directly or indirectly? I found information here and there, such as CeleryScript, and Farmbot JS, However, I could not put everything into one piece solution yet.


#4

@Xiaofeng

Do I first communicate with the Web API? Then the Web API talks with the Raspberry PI through MQTT? And then the Raspberry PI control the FarmBot? Or could I directly communicate with the Raspberry PI through MQTT from my software?

I’ve written a common use case document here which covers these use cases.

If you want to store or manage device data, use the REST API.

If you want to directly control the bot, use the MQTT message broker

I’m happy to clarify (or update the documentation) if you are still having trouble deciding.

For your application, you would most likely need to:

  • Import a C++ MQTT library

  • Manually send rpc_request to the device over the bot/device_XYZ/from_client channel.

  • Manually handle rpc_ok, rpc_error responses on the bot/device_XYZ/from_device channel.

Examples (written in Python) can be found here.

Is there a library I can use to accomplish this?

There is currently no C++ library available, so you will need to handle MQTT connections manually. As you have mentioned, there is FarmbotJS and also Farmware Tools (Python).

I found information here and there, such as CeleryScript, and Farmbot JS, However, I could not put everything into one piece solution yet.

The docs serve as a guide (rather than an API reference or reference manual). The best way to read it is to start from the begining and read the topics in order. They are still very much a work in progress though- if you are still having issues understanding the material, let me know. I am happy to help with whatever questions you have.


#5

Thanks, Rick. I will read through the docs and come back with more questions.