Replies: 10 comments 8 replies
-
|
See command Sensor12. |
Beta Was this translation helpful? Give feedback.
-
|
Aha, "Sensor12" for an I2c device indexed at "13". I am now getting on command
These are the 16-bit readout values. What am I missing - how can I configure a voltage readout? And on the console and on the Web_Gui it shows all 4 possible values. I am using only the first. Can I suppress the other 3 from showing? |
Beta Was this translation helpful? Give feedback.
-
|
The Sensor12 command allows to change the PGA thus controlling the analog input range. To convert and display a voltage value (or any other scaled output), you can use the rules system. If you are using an ESP32, you can either try Berry, but I had not found direct examples. And if you finally got your scaled output you can supress the display of the raw 16bit values at Webserver using this command: To turn it on again: |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
An ADC typically does not measure voltage directly, it provides a ratio of an input value against a reference value. Ok, In the case of the ADS1115 the reference value is provided internally by a low drift voltage reference, but at many other ADC's the reference need to be connected externally. The raw value does not require the information of the reference, therefore this is more an universal approach in concern of a simple driver. I ask this question myself during the development of an ADS1256 driver (work in progress). In most cases the direct measured value is not the user application scale, so using rules or Berry for post-processing is quite obvious. |
Beta Was this translation helpful? Give feedback.
-
|
For completeness: I wondered about the precision of the ADS1115: Testing precision around 3 V, I get, e.g.: For me, factory setting is plenty good enough! |
Beta Was this translation helpful? Give feedback.
-
|
I remembered the result which @sfromis got Gemini AI coding, and tried it for the ADS115. Well, on first glance it looked good, but I got bugs (use of "or" instead "||", and wrong use of nil), but even after fixing this, it did not deliver proper values. After a deep look into the datasheet of the ADS1115 I found incorrect bit-wise configuration. With that also fixed, it worked: The ugly binary values ("30780") are from Tasmota core, the shiny "3.827 V" are from my code. After all, easy to do. "Someone" could well use this code to update core! |
Beta Was this translation helpful? Give feedback.
-
|
Did you have a look to this Berry driver ? |
Beta Was this translation helpful? Give feedback.
-
|
My clear preference would be that the current "core driver" (meaning, the one built into default Tasmota) would get an update to properly present The @Noschvie code lacks - like my own - the consideration of the scaling besides one, here 6144. Not sure how this is done in the core driver, but I'm afraid it is not trivial to do this via Tasmota? But even as it is, it does cost performance. The call of I am excited to have learned the |
Beta Was this translation helpful? Give feedback.
-
|
There is a flaw in both the core code for the ADS1115, as well as in my-AI-inspired code! The problem is that the ADC conversion time is unsufficiently considered, which could result in completely false readings. The conversion does take some time. Unsurprisingly, the more time you give the converter the lower the voltage scatter is. This speed can be configured at 8 levels from 8 SPS (Sample-per-Second) taking 165 ms, up to 860 SPS taking 13 ms. Once a conversion has been done, it is held in the "Conversion Register" as a 16 bit value. It is overwritten with the next conversion, once that next one is completed. You can read the reg at any time. When you read the register while a conversion is ongoing, you get the previously completed result! The crux is the following: you could have changed the channel before the latest read, and when you read too soon, you will get the PREVIOUS channel result, and believe it is the current one! Surely not what you want. In the code the "too soon" is attempted to respect by adding a delay between config setting and reading. The core code (https://github.com/erocm123/Sonoff-Tasmota/blob/master/sonoff/xsns_12_ads1115.ino ) uses an 8 ms delay. And it uses the fastest conversion (and only that one, i.e. always the worst resolution). However, as I said above I see the fastest conversion taking 13 ms (+/- a few ms). The AI-inspired code uses the default speed of 128 SPS, which needs 24 ms, and puts in a 10 ms delay. So, also insufficient! The ADS1115 offers two ways to check for completion of a conversion, a hardware and a software one. The hardware uses another pin on the MCU for polling or interrupt. The software uses a bit in the config register, and you must loop for bit state. Don't forget an exit clause in case the chip fails! I prefer the software solution. The code becomes mildly more complex, but you avoid nonsense data. P.S. The core code claims a sampling range for the ADS1115 from 128 SPS up to 6000 SPS. No way! Even the ADS1015 (only a 12 bit ADC) cannot do more than 3300 SPS. See above for true range of the ADS1115. Looks like Copy&Paste-Code from a different chip. You won't notice, because you cannot change SPS; it is coded as a 3 bit value, and 111b is the highest value anyway, and this is used. |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
-
The ADS1115 is a 4x ADC of 16bit. It is supported in Generic Tasmota, and when connected via I2C it brings Web_sensor answers like:
I would like it to show not binary readout (like 20574) but voltage (here: 3.846 V), and want to see only the "0" channel. Also, it can be configured fo 6 different scales; here by default the maximum "±6.144V" scale is configured.
I am unable to find any means to configure this output. Is it even possible?
Beta Was this translation helpful? Give feedback.
All reactions