
ESP8266にはADCが1つしかなかったので、ADCを増やす方法がないか検索しているとCD74HC4067アナログマルチプレクサというものがありました。最大16個のアナログ入力センサーを1つのADCピンに接続できます。
Home AssistantのESPHomeでサポートされています。
試行錯誤でかなり時間がかかりましたが、YAMLのインストールがようやく完了したのですが、センサーが反応せず一度使用を断念しました。
しかし、ESP8266のADCは1.0Vまでの入力しか対応していないということが分かり、固定抵抗を替えようやく動作させることができました。
通常10kΩのNTCサーミスタを使用するときに10kΩの固定抵抗を使うのですが、100kΩにしたところ温度を計測することができました。
ESPHomeでのYAML
sensor:
- platform: resistance
id: resistance_reading_1
sensor: adc_channel_1
configuration: DOWNSTREAM
resistor: 100kOhm
name: "NTC Resistance 1"
- platform: resistance
id: resistance_reading_2
sensor: adc_channel_2
configuration: DOWNSTREAM
resistor: 100kOhm
name: "NTC Resistance 2"
- platform: adc
id: adc_sensor
pin: A0
update_interval: 10s
accuracy_decimals: 2
- platform: cd74hc4067
id: adc_channel_1
number: 0
sensor: adc_sensor
update_interval: 10s
- platform: cd74hc4067
id: adc_channel_2
number: 1
sensor: adc_sensor
update_interval: 10s
- platform: ntc
sensor: resistance_reading_1
name: "NTC Temperature 1"
calibration:
b_constant: 3435
reference_temperature: 25°C
reference_resistance: 10kOhm
- platform: ntc
sensor: resistance_reading_2
name: "NTC Temperature 2"
calibration:
b_constant: 3435
reference_temperature: 25°C
reference_resistance: 10kOhm
cd74hc4067:
- id: multiplexer
pin_s0: GPIO13
pin_s1: GPIO12
pin_s2: GPIO14
pin_s3: GPIO16
LOGは以下な感じ
[sensor:093]: 'adc_sensor': Sending state 0.25000 V with 2 decimals of accuracy
[cd74hc4067:036]: switch to input 0
[sensor:093]: 'adc_channel_1': Sending state 0.24805 V with 3 decimals of accuracy
[resistance:039]: 'NTC Resistance 1' - Resistance 8127.5Ω
[sensor:093]: 'NTC Resistance 1': Sending state 8127.47998 Ω with 1 decimals of accuracy
[ntc:026]: 'NTC Temperature 1' - Temperature: 30.5°C
[sensor:093]: 'NTC Temperature 1': Sending state 30.46387 °C with 1 decimals of accuracy
[cd74hc4067:036]: switch to input 1
[sensor:093]: 'adc_channel_2': Sending state 0.24902 V with 3 decimals of accuracy
[resistance:039]: 'NTC Resistance 2' - Resistance 8162.1Ω
[sensor:093]: 'NTC Resistance 2': Sending state 8162.08936 Ω with 1 decimals of accuracy
[ntc:026]: 'NTC Temperature 2' - Temperature: 30.3°C
[sensor:093]: 'NTC Temperature 2': Sending state 30.34988 °C with 1 decimals of accuracy
固定抵抗を100kΩにしましたが、正しいことなのかイマイチわかっていませんが、室温程度の測定には問題なさそうでした。
試行錯誤の詳しい部分、抵抗値を100kΩにした詳しい経緯はこちら↓
