Hi,
I am hacking into an Chinese led aquarium lamp with an ESP8266 on board.
The pcb has an temp output I located on GPIO14. I programmed a dallas_temp to it.
I also have a low side PWM fan connected by transistor to GPIO3.
But when the fan is on, it gives noise on the dallas temp.
I tried pausing the fan, which works, but the change in fan speed drives me crazy.
As in my second still original lamp, the fan doesn’t turn of, and temp reading is stable, there has to be a way of making it work without stopping the fan.
AI is of nu use in this as I tried it for the last couple of days.
This is a log file when the fan is turning and messing up the dallas_temp.
[21:32:49.976][D][dallas.temp.sensor:128]: Scratch pad: F7.41.55.00.7F.FF.0C.51.3F (E0)
[21:32:59.000][W][component:462]: dallas_temp.sensor cleared Warning flag
[21:33:00.166][W][component:431]: dallas_temp.sensor set Warning flag: scratch pad checksum invalid
[21:33:00.167][D][dallas.temp.sensor:128]: Scratch pad: F7.01.55.40.7F.FF.4C.14.7F (2C)
[21:33:08.710][I][safe_mode:071]: Boot seems successful; resetting boot loop counter
[21:33:09.297][W][component:462]: dallas_temp.sensor cleared Warning flag
[21:33:09.781][W][component:431]: dallas_temp.sensor set Warning flag: scratch pad checksum invalid
[21:33:09.781][D][dallas.temp.sensor:128]: Scratch pad: F8.05.55.00.7F.FF.4C.14.C5 (CB)
[21:33:19.429][W][component:462]: dallas_temp.sensor cleared Warning flag
[21:33:19.922][D][dallas.temp.sensor:054]: 'Lamp Temp': Got Temperature=31.500000°C
[21:33:30.170][D][dallas.temp.sensor:054]: 'Lamp Temp': Got Temperature=31.437500°C
[21:33:39.823][D][dallas.temp.sensor:054]: 'Lamp Temp': Got Temperature=31.437500°C
[21:33:49.768][D][dallas.temp.sensor:054]: 'Lamp Temp': Got Temperature=31.437500°C
[21:34:00.096][D][dallas.temp.sensor:054]: 'Lamp Temp': Got Temperature=31.375000°C
[21:34:10.143][D][dallas.temp.sensor:054]: 'Lamp Temp': Got Temperature=31.375000°C
[21:34:19.769][D][dallas.temp.sensor:054]: 'Lamp Temp': Got Temperature=31.375000°C
[21:34:30.080][D][dallas.temp.sensor:054]: 'Lamp Temp': Got Temperature=31.375000°C
[21:34:40.069][D][dallas.temp.sensor:054]: 'Lamp Temp': Got Temperature=31.312500°C
[21:34:49.771][D][dallas.temp.sensor:054]: 'Lamp Temp': Got Temperature=31.312500°C
[21:34:59.935][D][dallas.temp.sensor:054]: 'Lamp Temp': Got Temperature=31.250000°C
[21:35:10.037][D][dallas.temp.sensor:054]: 'Lamp Temp': Got Temperature=31.250000°C
[21:35:19.782][W][component:431]: dallas_temp.sensor set Warning flag: scratch pad checksum invalid
[21:35:19.789][D][dallas.temp.sensor:128]: Scratch pad: FF.FF.FF.FF.FF.FF.FF.FF.FF (C9)
[21:35:29.408][W][component:462]: dallas_temp.sensor cleared Warning flag
[21:35:29.781][W][component:431]: dallas_temp.sensor set Warning flag: scratch pad checksum invalid
[21:35:29.781][D][dallas.temp.sensor:128]: Scratch pad: F3.23.75.00.7F.FF.0E.12.2A (24)
[21:35:39.483][W][component:462]: dallas_temp.sensor cleared Warning flag
[21:35:39.788][W][component:431]: dallas_temp.sensor set Warning flag: scratch pad checksum invalid
[21:35:39.788][D][dallas.temp.sensor:128]: Scratch pad: F3.01.55.04.7F.FF.0C.50.2A (73)
[21:35:49.158][W][component:462]: dallas_temp.sensor cleared Warning flag
This is the YMAL code connected to the dallas and the fan where the fan gets paused to make a measurement.
globals:
- id: meting_bezig
type: bool
restore_value: no
initial_value: 'false'
- id: lamp_uit_tijd
type: uint32_t
restore_value: no
initial_value: '0'
- id: fan_speed
type: float
restore_value: no
initial_value: '0.0'
one_wire:
- platform: gpio
pin:
number: GPIO14
mode:
input: true
pullup: true
id: ow_gpio14
sensor:
- platform: dallas_temp
one_wire_id: ow_gpio14
index: 0
name: "Lamp Temp"
id: lamp_temp
update_interval: never
- platform: template
name: "Fan snelheid"
unit_of_measurement: "%"
update_interval: 5s
lambda: return id(fan_speed) * 100.0;
Output:
- platform: esp8266_pwm
pin: GPIO3
id: fan_pwm
frequency: 25000 Hz
interval:
- interval: 10s
then:
- lambda: |-
if (id(fan_speed) == 0.0) return;
id(meting_bezig) = true;
- output.turn_off: fan_pwm
- delay: 100ms
- component.update: lamp_temp
- delay: 1000ms
- output.turn_on: fan_pwm
- lambda: id(meting_bezig) = false;
- interval: 500ms
then:
- lambda: |-
float pot = id(light_pot).state;
auto time = id(ha_time).now();
int uur = time.hour;
bool schema_aan = (uur >= 15 && uur < 22);
bool schema_override_uit = (pot >= 0.1 && pot < 0.2);
bool schema_override_aan = (pot >= 0.2);
bool lamp_aan;
if (schema_override_aan) {
lamp_aan = true;
} else if (schema_override_uit) {
lamp_aan = false;
} else {
lamp_aan = schema_aan;
}
if (lamp_aan) {
id(lamp_uit_tijd) = 0;
} else if (id(lamp_uit_tijd) == 0) {
id(lamp_uit_tijd) = millis();
}
bool fan_aan = lamp_aan || (id(lamp_uit_tijd) > 0 && (millis() - id(lamp_uit_tijd)) < 120000);
float temp = id(lamp_temp).state;
float fan_target = id(fan_speed);
if (!isnan(temp)) {
if (temp < 40) {
fan_target = 0.6;
} else if (temp < 50) {
fan_target = 0.8;
} else {
fan_target = 1.0;
}
}
if (!id(meting_bezig)) {
if (fan_aan) {
id(fan_pwm).set_level(fan_target);
id(fan_speed) = fan_target;
id(status_led).turn_on();
} else {
id(fan_pwm).set_level(0.0);
id(fan_speed) = 0.0;
id(status_led).turn_off();
}
}