×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

Make calls to ESP32

  • Posts: 2
  • Thank you received: 0

Make calls to ESP32 was created by Stephan

Hello,

I am relativly new to INDI. I am currently working my way in driver development. The docs.indilib.org/drivers/ is a very good starting point - thank for that.

I wonder how to connect to a ESP. I want to control let's say for simplicity an led that is connected to a pin of the ESP32. Normally you set up a small web server on the ESP32 that is available in the local network, then calling urls to control the devices like 192.168.1.2/switch?state=on or 192.168.1.2/switch?state=off. You could also use websockts with that ESP websever.

So how would you do that with C++ and INDI. Most connection examples use serial connection, there are also a few drivers that make a TCP connection but I must admit here I do not understand how this works. Has anybody some advice or exemplae for me?

Thank you, Stephan
6 months 1 week ago #96611

Please Log in or Create an account to join the conversation.

  • Posts: 1187
  • Thank you received: 370
Hi Stephan,
welcome to the INDI community!

WeatherRadio is an INDI driver for a weather station, where the INDI driver has both options for a serial and a HTTP based communication. WeatherRadio::executeCommand() handles the communication with the Arduino that manages all weather sensors. The communication can be either through USB or - as you want to do - via the network.

Take a look here:
github.com/indilib/indi-3rdparty/blob/ma...atherradio.cpp#L1387

This branch handles the communication via HTTP.

HTH
Wolfgang
6 months 1 week ago #96612

Please Log in or Create an account to join the conversation.

  • Posts: 2
  • Thank you received: 0

Replied by Stephan on topic Make calls to ESP32

Hi Wolfgang,

Thank you very much - the code example will help a lot. I know curl from php.

Clear skies,
Stephan
6 months 5 days ago #96661

Please Log in or Create an account to join the conversation.

Replied by Jasem Mutlaq on topic Make calls to ESP32

We have bundled httplib now in INDI, so please use this for all http calls in any new drivers.

Check out the Planewave Mount driver that makes a use of httplib. In your case, it's pretty easy to implement:
httplib::Client cli(tcpConnection->host(), tcpConnection->port());
cli.Get("/switch?state=on);

And you're set!
Last edit: 6 months 5 days ago by Jasem Mutlaq.
6 months 5 days ago #96680

Please Log in or Create an account to join the conversation.

Time to create page: 0.211 seconds