Author Topic: Use ESP32 as a sudo-moteino node to PiGateway - success  (Read 160 times)

duane1

  • NewMember
  • *
  • Posts: 10
  • Country: us
Use ESP32 as a sudo-moteino node to PiGateway - success
« on: January 27, 2021, 11:13:53 AM »
I finally upgraded my PiGateway to V9.2 on a new Pi4.   Pretty easy upgrade and everything works great.  I decided to try out the new PiGateway HTTPEndpoint feature.   I used a M5Stack Atom Lite ESP32 module with a precision temperature and humidity sensor to mimic a moteino node.   Works great.  Pretty nice new feature that Felix has provided. 

I ran into one particular problem, so I attached my entire script so it may help someone.  The https requires Authorization.  Well, I knew that, but the syntax was very elusive.   The hints and examples I found on LowPowerLab were javascript and the syntax is different for C++.    From my internet searches, the majority of ESP32 (Arduino IDE)  https Get or Post examples are non-secure http.  Of the examples using the secure https Get or Post, all used certificates.  I could not find an example using username and password.  I resorted to reading the library I was using (HTTPClient.h) to finally figure it out:

Code: [Select]
thisClient.setAuthorization(PI_USER, PI_PASS);

Hope this is useful.   
--- Duane1
« Last Edit: January 27, 2021, 11:29:31 AM by Felix »