About

The following page will document using various technologies to add automation to a Telwin Touring 15 battery charger. The Telwin Touring 15 seems like a good candidate, seems made in Italy and has some good internals featuring a very large transformer and some good workmanship on the PCB connections as well as having ample space inside to insert our own electronics.

The Telwin Touring 15 is a charger that features an array of colored LEDs as a charge indicator, from left to right, as well as a commuter between 12, respectively $24V$. The charger seems to be very straightforward in its operation: simply connect the leads to the battery and then plug in the charger. When the colored LEDs indicate a full charge, the Telwin Touring 15 must be disconnected manually by pulling the plug.

It would be nice to hack into the Telwin in order to be able to add some automation via IoT, perhaps to make the charger turn off once the maximal load has been reached, and even transmit the voltage to some data collector based on MQTT or generate some charts to be able to monitor the battery's health.

Requirements

  • an ESP, 8266 or ESP32, we typically use a WeMoS due to their small size and sufficient GPIO ports. In this case, the analog input will be used and the WeMoS D1 mini / pro features a single analog input making it a perfect choice to measure the voltage,
  • a high-amperage relay (not necessarily a latching relay, but could be cool),
  • a small micro-transformer stepping $220V$ alternative to $5V$ DC; this will be used to power the ESP directly from the mains connection without messing with the Telwin's circuit at all,
  • some high wattage resistors in order to construct a voltage sieve meant to map $0..12V$ somewhere into the digital-analog range of $0..3.3V$ at which the ESP analog input operates,
  • the usual construction materials for soldering, glue gun, etc,

Block Diagram

                             +------------+
                             |            |
        +--------------------+  10A Relay |
        |                    |            |
        |      +-------------+            |           to Telwin Touring 15
        |      |             |            |              charger logic
        |      |         +---+            |              
        |      |         |   |            |                ^ +  ^ -
        |3.3V  | GPIO    |   +----+---+---+                |    |  
  +-----+------+--+      |        |   |                    |    |
  |      ESP      |      |        |   +--------------------+    |
  +----+--+-----+-+      |        |                             |
       |  | A0  |        |        +---------------------+       +----+
       |  |     |        |        |                     | +12V  |    |
       |  |     |        |    +---+------+            +-+-------+-+  |
       |  |     |        |    |          |            |           |  |
       |  |     +--------+----+          |            |           |  |
       |  |     |             |          |            |           |  |
       |  +-----|-------------+ Resistor |            | Battery   |  |
       |        |             |  Divider |            |           |  |
       |        |             +--------+-+            +-----------+  |
       | +5V DC |                      |                             |
  +----+-----+  +----------------------+-----------------------------+
  | AC -> DC |  |
  +----+---+-+  |
       |   |    |
       |   +----+
       |        |
       |        | Common GND
       |       ///
       |
       | 220V AC

In short, the circuitry that will be designed will interrupt the positive lead between the Telwin Touring 15 charger and the vehicle battery as well as sap the voltage off the vehicle battery and feed it to the ESP for measuring.

Voltage Divider

Given that the ESP analog input tolerates voltage ranging $0..3.3V$, the voltage divider will have to step down $12V$ to somewhere between $0V$ and $3.3V$. The resistors should be rated with a high wattage, and large values, in order to reduce the amount of generated heat, so preferably somewhere at $1W$ should cover it. Using the voltage divider or an online voltage divider calculator, it seems that two resistors rated at $1M\Omega$, respectively $3M\Omega$ should lower the $12V$ from the battery to $3V$ which is sufficiently low to not burn the analog input on the ESP.

Empirically speaking, the voltage divider will just lower the voltage of the battery where the vehicle battery has been measured to provide from $11.1V$ on the lowest charge and up to $13.4V$ when fully charged. This means that the voltage divider will fluctuate between $3V$ and a little something at $13.4V$ when the battery is fully charged and down a few millivolts when the battery is discharged and providing only $11.1V$. These measurements are mostly application-driven and it just so happens that the device being powered "gives up" when the battery falls lower than $11.1V$ but is happily working at anything over $11.1V$.

The voltage divider could of course be replaced by a proper voltage sensor that is calibrated to provide a consistent voltage measurement yet it seems that such sensors are not common regardless of their simplicity. In any case, the voltage divider works great.

Once connected, the voltage divider will provide the few millivolts variation to the analog input of the ESP. Using the code:

integer analogValue = analogRead(A0);

on the Arduino will set the analogValue to some generated integer between $0$ and $255$. This means that with the battery connected and the voltage divider in place, two measurements should be taken using the above code and the ESP; once with the battery being discharged that will provide the lower limit integer value corresponding to a discharged battery, respectively one again with the battery fully charged that will provide the upper limit integer value corresponding to a fully charged battery.

Intuitively, one would define these analog fictive values as global constants within the code injected into the ESP and then perhaps take decisions on whether to toggle the relay or not depending on the current value. However, it was decided to modify the Arduino pin toggle code and add another action named measure that would publish the current value of the analog pin A0 (on the ESP82666) to an MQTT broker such that the actual logic is passed onto Node-Red.

Trivially, in a closed-self-standing project, all of the actual reasoning could just be integrated into the ESP Arduino code without requiring Wifi network, Node-Red, and so on, and so forth…

Relay

The relay chosen has been a non-latching Featherwing relay rated at $250V$ and $10A$. Even though the relay will only switch $12V$ such a fat relay has been chosen due to its high amperage due to vehicle batteries typically being designed for very high power as they are required to mechanically move the engine for initial ignition.

One interesting choice has been made concerning the relay, in that the connections have been made in such a way that the relay will in fact be continuously charging the battery once the Telwin Touring 15 charger is plugged in, and if a signal is sent through the ESP GPIO pin, only then will the relay decouple the battery. This choice has been made for independence and compatibility, allowing the Telwin Touring 15 charger to function regardless of the additional logic that requires an infrastructure (Wifi, etc). That being said, the ESP / Node-Red logic only decouples or interrupts the charging of the battery instead of, intuitively, starting to charge the battery.

Similarly, another interesting choice is that when the relay decouples the positive connection between the charger and the vehicle battery, the actual measurement on the analog pin is performed directly from the disconnected lead of the battery such that the charging circuitry of the Telwin is not involved in the reading of the battery voltage.

The Micro-Transformer AC to DC Converter

Even though a stepdown pulled from the existing Telwin Touring 15 logic would have been sufficient to step down $12V$ to $5V$ as required by the ESP, it was deemed wiser to just use a micro AC-to-DC converter that acts in parallel with the charger logic, in order to not interfere with the actual charging process of the Telwin Touring 15.

In fact, measurements between the various connections and marked solder pads proved to be quite erratic; for instance, one pad marked clearly $+6V$ (although, it is unclear why $6V$ would even be necessary for a $12V$/$24V$ charger?) has been measured to pull as high as $12V$ or even $32V$ such that even if a downstepper or buck converter would be used, then it would have been necessary to use a constant-current guaranteed $5V$ output in order to not fry the ESP as the voltage fluctuates erratically across the Telwin Touring 15 logic board.

In some ways, the motto has been: "let the charger do what it is designed to do and let's add our logic in parallel", instead of trying to demystify the design of the Telwin Touring 15 charger.

Realization

The realization of the circuitry is rather straight-forward, with hot melt glue used to secure down the components to the chassis. The following image documents where the various components have been placed inside the case of the Telwin Touring 15 charger.

There were not particular problems encountered, just that the charger tends to heat up due to the gargantuan transformer such that for further work, perhaps a fan could be integrated to waft off some of the heat from the circuitry.

Arduino Code

The Arduino code used is a fork of the ESP pin toggler but with an array ANAL[] used for storing analog input pins, for both the ESP8266 and the ESP32 with an additional action measure being added to the API in order to retrieve the current value of the analog pin; in the context of the project, the value corresponding to the battery charge.

Unable to display file "http://svn.grimore.org/arduino-sketches/arduinoPinToggle/arduinoPinToogle%20(with%20analog%20measurement).ino": It may not exist, or permission may be denied.

Node-Red

With the Arduino code uploaded to the ESP and the boxed closed up tightly, the ESP can now be accessed via the pin toggle API by publishing to the MQTT broker a command to which the ESP will respond with the current level of the analog pin. It now really depends on what we would like to accomplish with the added control. For instance, a chart could be generated to keep a history of how the battery is discharging, along with a gauge perhaps to display the current battery voltage as well as "ON" and "OFF" buttons to toggle the charging (in the following image "ON" carries the meaning of starting to charge the battery, respectively "OFF" means to stop charging the battery).

Here is a full Node-Red flow export that generates the displays and controls on the Node-Red dashboard as observed in the previous image:

[{"id":"3d855204.d96e16","type":"tab","label":"HAM","disabled":false,"info":""},{"id":"37ae5a081801688e","type":"group","z":"3d855204.d96e16","name":"Charger Battery Monitoring","style":{"label":true},"nodes":["559c008a.92c058","19e76393.c65efc","14e7b3be.7bd7b4","78d40567.ee3b0c","af5ac47c.7d8a78","7799b961.a33a38","b2355d7e.2416e8","390f5ddba636ce44","0283552f23b547a3","1b75db6f35461359","5b1bf2d3ac07eb3c","bf2bd038ce089561","7e8b3edaf4d651c7","79feb8de17dcaf0e","6ab578026fbadf46","d86822b5368e118b","214e6692a33f715d"],"x":44,"y":39,"w":1862,"h":322},{"id":"e16801600ded8677","type":"group","z":"3d855204.d96e16","name":"Charger Button Switch","style":{"label":true},"nodes":["d87e88b2.4c2058","c42be10b.ad282","f996617e.773f48","ffd2e283.e5f68","0cc44b4b733d95e4","2ade7ff6b972de5e"],"x":54,"y":399,"w":412,"h":322},{"id":"559c008a.92c058","type":"debug","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":200,"wires":[]},{"id":"19e76393.c65efc","type":"mqtt in","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"","topic":"esp/1607cb","qos":"2","datatype":"auto","broker":"725ed69c.6d76a8","nl":false,"rap":true,"rh":0,"inputs":0,"x":140,"y":200,"wires":[["559c008a.92c058","78d40567.ee3b0c"]]},{"id":"d87e88b2.4c2058","type":"mqtt out","z":"3d855204.d96e16","g":"e16801600ded8677","name":"","topic":"esp/1607cb","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"725ed69c.6d76a8","x":370,"y":580,"wires":[]},{"id":"c42be10b.ad282","type":"inject","z":"3d855204.d96e16","g":"e16801600ded8677","name":"on(6)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"pin\":\"6\",\"state\":\"on\",\"action\":\"set\"}","payloadType":"json","x":150,"y":560,"wires":[["d87e88b2.4c2058"]]},{"id":"f996617e.773f48","type":"inject","z":"3d855204.d96e16","g":"e16801600ded8677","name":"off(6)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"pin\":\"6\",\"state\":\"off\",\"action\":\"set\"}","payloadType":"json","x":150,"y":440,"wires":[["d87e88b2.4c2058"]]},{"id":"ffd2e283.e5f68","type":"inject","z":"3d855204.d96e16","g":"e16801600ded8677","name":"get(6)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"pin\":\"6\",\"action\":\"get\"}","payloadType":"json","x":150,"y":680,"wires":[["d87e88b2.4c2058"]]},{"id":"14e7b3be.7bd7b4","type":"inject","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"measure(0)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"pin\":\"0\",\"action\":\"measure\"}","payloadType":"json","x":290,"y":320,"wires":[["5b1bf2d3ac07eb3c"]]},{"id":"78d40567.ee3b0c","type":"json","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"","property":"payload","action":"","pretty":false,"x":320,"y":260,"wires":[["7799b961.a33a38"]]},{"id":"af5ac47c.7d8a78","type":"debug","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1570,"y":140,"wires":[]},{"id":"7799b961.a33a38","type":"function","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"","func":"if(typeof msg.payload.value !== 'undefined' && msg.payload.pin === 0) {\n    const value = msg.payload.value\n    msg.payload = value\n    msg.topic = \"battery\"\n}\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":260,"wires":[["b2355d7e.2416e8"]]},{"id":"b2355d7e.2416e8","type":"switch","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"[0-9]+","vt":"str","case":false}],"checkall":"true","repair":false,"outputs":1,"x":610,"y":260,"wires":[["0283552f23b547a3"]]},{"id":"390f5ddba636ce44","type":"ui_gauge","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"","group":"37446b7f.46e394","order":0,"width":0,"height":0,"gtype":"gage","title":"Battery Level","label":"V","format":"{{value}}","min":"11.1","max":"13.8","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1210,"y":300,"wires":[]},{"id":"0283552f23b547a3","type":"range","z":"3d855204.d96e16","g":"37ae5a081801688e","minin":"228","maxin":"296","minout":"11.1","maxout":"13.8","action":"clamp","round":false,"property":"payload","name":"","x":770,"y":260,"wires":[["1b75db6f35461359"]]},{"id":"1b75db6f35461359","type":"function","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"Round to One Decimal","func":"msg.payload = Math.round(msg.payload * 10) / 10\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":980,"y":260,"wires":[["390f5ddba636ce44","7e8b3edaf4d651c7"]]},{"id":"0cc44b4b733d95e4","type":"ui_button","z":"3d855204.d96e16","g":"e16801600ded8677","name":"","group":"37446b7f.46e394","order":1,"width":0,"height":0,"passthru":false,"label":"Off","tooltip":"","color":"","bgcolor":"","icon":"","payload":"{\"pin\":\"6\",\"state\":\"on\",\"action\":\"set\"}","payloadType":"json","topic":"topic","topicType":"msg","x":150,"y":600,"wires":[["d87e88b2.4c2058"]]},{"id":"2ade7ff6b972de5e","type":"ui_button","z":"3d855204.d96e16","g":"e16801600ded8677","name":"","group":"37446b7f.46e394","order":3,"width":0,"height":0,"passthru":false,"label":"On","tooltip":"","color":"","bgcolor":"","icon":"","payload":"{\"pin\":\"6\",\"state\":\"off\",\"action\":\"set\"}","payloadType":"str","topic":"topic","topicType":"msg","x":150,"y":480,"wires":[["d87e88b2.4c2058"]]},{"id":"5b1bf2d3ac07eb3c","type":"mqtt out","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"","topic":"esp/1607cb","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"725ed69c.6d76a8","x":470,"y":320,"wires":[]},{"id":"bf2bd038ce089561","type":"ui_chart","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"","group":"37446b7f.46e394","order":3,"width":0,"height":0,"label":"Battery History (V)","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"11.1","ymax":"13.8","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":1790,"y":80,"wires":[[]]},{"id":"7e8b3edaf4d651c7","type":"buffer-array","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"","bufferLen":"60","startWhenFilled":false,"x":1210,"y":80,"wires":[["6ab578026fbadf46"]]},{"id":"79feb8de17dcaf0e","type":"change","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"average-array","rules":[{"t":"set","p":"payload","pt":"msg","to":"$average(payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1580,"y":80,"wires":[["bf2bd038ce089561"]]},{"id":"6ab578026fbadf46","type":"switch","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1390,"y":80,"wires":[[],["d86822b5368e118b","af5ac47c.7d8a78","79feb8de17dcaf0e"]]},{"id":"d86822b5368e118b","type":"function","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"Generate","func":"msg.payload = Array.from({length: 60}, () => 0)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1220,"y":180,"wires":[["214e6692a33f715d"]]},{"id":"214e6692a33f715d","type":"split","z":"3d855204.d96e16","g":"37ae5a081801688e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":1390,"y":180,"wires":[["7e8b3edaf4d651c7"]]},{"id":"725ed69c.6d76a8","type":"mqtt-broker","name":"iot.internal","broker":"iot.internal","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"37446b7f.46e394","type":"ui_group","name":"Battery Charger","tab":"5030924.1240b6c","order":1,"disp":true,"width":"12","collapse":false},{"id":"5030924.1240b6c","type":"ui_tab","name":"HAM","icon":"dashboard","disabled":false,"hidden":false}]

If curious, the flow is named HAM, from HAM amateur radio, given that for this application the car battery is used to powered a HAM radio. The reason being zero redundant ESR being generated by static batteries instead of powering the HAM radio from the mains. In fact, when the HAM radio is in use, this project is used to stop charging the battery and physically (as in, electrically-physically) disconnect the battery from the mains in order to achieve a low probability for ESR.

As explained previously, there has been a calibration phase, such that the lower $Y$-axis threshold of $11.1V$ has been deemed the lower limit that corresponds to (incidentally) a meaningless reading of 228 on the analog pin, when the HAM radio stops working, as well as $13.4V$ that corresponds to the meaningless analog reading of 296 when the battery is fully charged and the HAM radio is most happy.

One difficulty in creating the Node-Red dashboard for monitoring the battery, is that the voltage gauge updates every second, whilst the chart is generated over a period of one day by sampling the battery voltage every minute. A single MQTT broker subscription is used and just for completeness sake, a slow down data rate trick has been used to separate the data such that the two displays can run at different data rates.


vehicles/cars/automating_a_vehicle_battery_charger.txt · Last modified: 2023/05/31 17:45 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.