Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow calibration of HuaFan devices (and other hardware) #654

Closed
wants to merge 1 commit into from
Closed

Allow calibration of HuaFan devices (and other hardware) #654

wants to merge 1 commit into from

Conversation

PeteBa
Copy link

@PeteBa PeteBa commented Jul 28, 2017

The calibration limits hardcoded into xsns_hlw8012.ino are too high for calibrating the HuaFan devices. The HuaFan's shunt resistor is double the Sonoff's and there are only 4 voltage divider resistors rather than 5. For example, to calibrate the Huafan required the following values: HLWPCAL: 4,750, HLWUCAL: 1,525, HLWICAL: 1,680 (the first and last are below the hardcoded limits).

This PR proposes an alternative calibration approach allowing the user to provide known power, voltage and current values with the software auto-calibrating to these values. This would also allow the HuaFan to be calibrated as well as devices with other hardware. The PR adds the following three commands:

  • HLWPSET x: where x is the expected power in watts i.e. 60 for a 60 watt bulb
  • HLWUSET x: where x is the expected voltage in volts i.e. 240 for a 240 volt supply
  • HLWISET x: where x is the expected current in milliamps i.e. 250 for 0.250mA

The use cases for calibration are either:

  • a user connects up a known appliance, i.e. 60W bulb, and assumes 240V and 0.25A for voltage and current and enters these into the console
  • a user connects a load and uses a multimeter to determine all three values

This approach seems more consistent with the guidelines provided in the wiki pages for preparation and simplifies the calibration process.

arendst added a commit that referenced this pull request Jul 30, 2017
5.5.0 20170730
* Reduce code space by removing the following commands as they are
replaced by SetOption alternatives:
*   SaveState = SetOption0
*   ButtonRestrict = SetOption1
*   Units = SetOption2
*   MQTT = SetOption3
*   MQTTResponse = SetOption4
*   TempUnit = SetOption8
* Smoothing WS2812 animation poll, invert fade speed and max allowed
wakeup time down to 3000 seconds
* Fix initial button press detection
* Add support for Sonoff RF Bridge 433 using command RfKey
* Fix regression from 5.0.7 by increasing message buffer size from 360
to 368 to accomodate 4 x DS18x20 sensors (#637)
* Add GroupTopic to Topic test when using ButtonTopic/SwitchTopic to
send either ON/OFF or TOGGLE (#642)
* Adjust HLW calibration limits to accomodate HuaFan device and add
commands HlwPSet, HlwUSet and HlwISet (#654)
@pascalsaul
Copy link

pascalsaul commented Aug 4, 2017

The calibration is working quite nice with the SET command 👍 I'm only struggling with the voltage. Can it be outputted with one or two decimals? Because 1V is quite a big calibration gap. Now I need to wait when the voltage is rounded to calibrate.

Can you make an extra option to automatically calculate the PCAL when I have calibrated the U and I? Something like HLWPSETAUTO? I can measure the voltage (in parallel) and the current (in serie) with the multimeter. Calculating the P is quit hard with changing values :)

I don't believe that all bulbs have the exact same wattage ;) Thereby who got the old bulbs yet still?

When I measure exactly 231.0 V I send it to the device:
mosquitto_pub -t cmnd/pow_odu/HLWUset -m 231
18:24:43 MQTT: stat/pow_odu/RESULT = {"HlwUcal":"1944"}

When I look into the webinterface it keeps saying 230 V when my multimeter is saying 231.0

@PeteBa
Copy link
Author

PeteBa commented Aug 5, 2017

Thanks for adding this. Closing the pull request.

@PeteBa PeteBa closed this Aug 5, 2017
@PeteBa PeteBa deleted the huafan_calibration branch August 5, 2017 00:53
arendst added a commit that referenced this pull request Aug 5, 2017
5.5.1 20170805
* Fix Sonoff Rf Bridge issues
* Add Sonoff RF Bridge MQTT messages on received and learned RF signal
* Add command VoltRes 0|1 to select voltage resolution to 0.1 V (#654)
* Add averaging to Analog input (#686)
* Add Energy tele data on Sonoff Pow Threshold change (#688)
* Fix inconsistent property names in Messages (#690)
curzon01 pushed a commit to curzon01/Tasmota that referenced this pull request Sep 6, 2018
5.5.0 20170730
* Reduce code space by removing the following commands as they are
replaced by SetOption alternatives:
*   SaveState = SetOption0
*   ButtonRestrict = SetOption1
*   Units = SetOption2
*   MQTT = SetOption3
*   MQTTResponse = SetOption4
*   TempUnit = SetOption8
* Smoothing WS2812 animation poll, invert fade speed and max allowed
wakeup time down to 3000 seconds
* Fix initial button press detection
* Add support for Sonoff RF Bridge 433 using command RfKey
* Fix regression from 5.0.7 by increasing message buffer size from 360
to 368 to accomodate 4 x DS18x20 sensors (arendst#637)
* Add GroupTopic to Topic test when using ButtonTopic/SwitchTopic to
send either ON/OFF or TOGGLE (arendst#642)
* Adjust HLW calibration limits to accomodate HuaFan device and add
commands HlwPSet, HlwUSet and HlwISet (arendst#654)
curzon01 pushed a commit to curzon01/Tasmota that referenced this pull request Sep 6, 2018
5.5.1 20170805
* Fix Sonoff Rf Bridge issues
* Add Sonoff RF Bridge MQTT messages on received and learned RF signal
* Add command VoltRes 0|1 to select voltage resolution to 0.1 V (arendst#654)
* Add averaging to Analog input (arendst#686)
* Add Energy tele data on Sonoff Pow Threshold change (arendst#688)
* Fix inconsistent property names in Messages (arendst#690)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants