Integrate existing Arduino sketches into ESPHome?

Title is a bit vague, but I’ll try to elaborate on it.

There is this awesome open source project for bike riders to measure distance of overtaking cars to your own bike called OpenBikeSensor. I just took a short look into it, but my imagination went crazy! :smiley:

My mind came up with two main topics:

Integrate it into Home Assistant with ESPHome

Integrate it into Home Assistant to transfer the recorded data into InfluxDB and make some crazy visualisations.

More on that later on.

Add more sensors

Add more sensors and record everything in your interest like:

  • speed - it has a GPS
  • speed - magnet on spokes and hall sensor on frame
  • cadence - mount a magnet on your crank and put a hall sensor to the frame
  • current gear - store the different cock sizes and with wheel rotation and crank rotation you get the gear
  • height - add a barometric sensor and measure the height
  • slope - we have the height and the horizontal speed, let’s calculate the slope

  • Additional for eBikes:
  • battery level - just measure the voltage of the battery pack
  • current draw by the motor - add a shield with a shunt resistor and get the data

All this data can be great to analyze which cadence is efficient in battery usage at a given slope for example.

Having a history of current draw of the same segment over time can show you the training effort…

How to integrate with ESPHome

This is why I am asking. I haven’t taken a look into the ESPHome code so far.

I have got experience in Python programming, I did some stuff with ESP32s in Arduino sketches, did some tinkering with ESP IDF but nothing to fancy and my C++ isn’t just rusty, it’s worse than a leaky bucket made of iron.

Hence, before I dive deeper into the topics wanted to know whether it could be possible to take an existing firmware like the one of OBS and wrap it with an ESPHome custom offline sensor?

The default CustomSensors seem to have to be in the HA WiFi all the time, but the OBS sensors would be away again and again and have to import the data as batches later on…

Is there an abstraction in ESPHome to cover such a case?

Most people (I guess) will never bother with the ESPHome code itself because it is essentially a “no code” solution (which still allows to go “advanced” with lambda for people who need it)

ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.

www.esphome.io

In theory that might be possible to some extend but it will probably consume much more effort than just rebuilding the functionalities in esphome totally from scratch. :page_facing_up:

Nether esphome nor HA can handle a “import” of “old” data (at a later time) - guess this is the ultimate show stopper. :no_entry_sign:

1 Like

Sorry for the late reply. Had been on vacation the last two weeks.

Thanks for pointing out the showstopper!

Always good to discuss new ideas with experienced folks.