I have a number of sensors linked to an esp32. If I were to program in C/C++ I would use and array to cycle through each sensor. It appears this is not possible ine ESPHOME. Is there a way to use an array in this way in ESPHOME?
void loop() {
for (n = 0; n <= 6 ;n++){
value[n] = analogRead(pinArray[n]);
You will need to provide more information on what your goal is. esphome has some particular ways of doing things and thinking about them in ways that work elsewhere probably wonāt be effective.
I have used both Tasmota and esphome. The mental models you have to have are very different.
As an example, in Tasmota every (configurable) time period all sensor values get published. In esphome each sensor gets published independently. This is good in that you can publish it only when it needs to be published. This is different than in Tasmota and if you are expecting it to work that way, you will be disappointed. This difference (and others) meant I had to change the strategy I used in Node-RED for publishing from MQTT to InfluxDB. Had I been using just HA, it would have been easy as esphome is designed to play well with HA.
Thank you both for your answers. Trust me to want to do something which is fundamentally contrary to the philosophy to ESPHOME. I will need to consider what to try next. I like the ease of usong esphome with tried and tested processes
If you start with what your real goal is, you will probably get help in how to express it in esphome.
It sounds like you just need to create multiple sensors, one for each sensor/pin. There are ways to minimize the repeated configuration/code, but they are not well explained. Copy-n-paste seems to be the āstandardā, start with that.
I seem to have passee the YAML test and have 5 channels with sensor controlling a gpio pin. now to get it to work in a live situation.
Is there a way to get esphome to output data to a com port as I thing there is a way to graph the data in excel?
I will repeat myself, what is your goal? You appear to be working uphill.
esphome was created to work well with Home Assistant. Home Assistant has all sorts of graphing capabilities.
I use MQTT, Node-RED, InfluxDB, and Grafana, but I started doing that more than a decade ago well before esphome and even Home Assistant existed as an idea in anyoneās eye. There are MANY ways to accomplish most tasks. Which one is best depends on many factors.
Iām monitoring the growth of various plants including tomatoes fuchsia pellargoniums. I trying to optimise the environment using sensors like soil humidity humidity soil and air temperature. Using esp32s allows me to sense different parameters
HA has support (to make things easy) to do graphing and automation based on sensor readings, which you will likely need to complete your task.
If you are just starting out, it would be great to use that, since you are using esphome and the two are designed to play well together.
If you are NOT using HA, you are likely āworking uphillā and your task will be much harder and your question makes a little more sense. But, it also indicates you are probably asking the wrong question to get a great answer.
If your goal is to see the values of many sensors and graph then over time, the simple answer is set up Home Assistant.
Your desire to graph in Excel (for iot sensor data) does not make sense to me and I like and use Excel regularly for many things.