This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RPI Cooling fan control
#1
Here is my circuit and NodeRed flow to control a 12v cooling fan for the RPi
My Pi is used in a fairly high ambient temperature so a little cooling might be required in summer
(I actually solved the problem that was causing my Pi to overheat but Id put together the cooling controller so I went ahead and installed it anyway Smile ) 

Circuit diagram
   

NodeRed flow
   

NodeRed code
Code:
[{"id":"1189fc4b.908fa4","type":"ui_switch","z":"9793012f.3afaf","name":"Fan Override","label":"Fan switch","group":"693e1549.6d363c","order":0,"width":"0","height":"0","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":510,"y":1220,"wires":[["dfb0d3e9.3b755"]]},{"id":"dfb0d3e9.3b755","type":"rpi-gpio out","z":"9793012f.3afaf","name":"Fan control on GPIO18","pin":"12","set":true,"level":"0","freq":"","out":"out","x":850,"y":1260,"wires":[]},{"id":"234b0bca.01bb54","type":"function","z":"9793012f.3afaf","name":"CPU Fan threshold","func":"str = msg.payload;\nmsg.payload = str.substring(5,9);\nmsg.payload = Number(msg.payload);\nif(msg.payload >65) msg.payload = 1;\nelse if(msg.payload <=65) msg.payload = 0;\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":1320,"wires":[["dfb0d3e9.3b755"]]},{"id":"32c875db.e8e48a","type":"exec","z":"9793012f.3afaf","command":"vcgencmd measure_temp","addpay":false,"append":"","useSpawn":"","timer":"","oldrc":false,"name":"RPi Temp.","x":330,"y":1320,"wires":[["234b0bca.01bb54","cc33579b.e30ba8"],[],[]]},{"id":"cc33579b.e30ba8","type":"function","z":"9793012f.3afaf","name":"CPU Temp","func":"str = msg.payload\nmsg.payload = str.substring(5,9);\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":1360,"wires":[["e8101264.ed32e","318c3d17.88c2d2"]]},{"id":"504fcc1f.10ed74","type":"inject","z":"9793012f.3afaf","name":"","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"x":124.5,"y":1328.25,"wires":[["32c875db.e8e48a"]]},{"id":"e8101264.ed32e","type":"ui_gauge","z":"9793012f.3afaf","name":"","group":"3067d01a.af5d4","order":2,"width":0,"height":0,"gtype":"gage","title":"CPU Temperature","label":"C","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"x":830,"y":1360,"wires":[]},{"id":"318c3d17.88c2d2","type":"ui_chart","z":"9793012f.3afaf","name":"","group":"2381998f.63b6d6","order":0,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","ymin":"","ymax":"","removeOlder":"3","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":830,"y":1400,"wires":[[],[]]},{"id":"693e1549.6d363c","type":"ui_group","z":"","name":"Col3","tab":"7ae3bc3.4c07544","order":3,"disp":false,"width":"3"},{"id":"3067d01a.af5d4","type":"ui_group","z":"","name":"Col1","tab":"7ae3bc3.4c07544","order":1,"disp":false,"width":"3"},{"id":"2381998f.63b6d6","type":"ui_group","z":"","name":"Temp Chart","tab":"8b537ae0.9e5938","disp":true,"width":"10"},{"id":"7ae3bc3.4c07544","type":"ui_tab","z":"","name":"RPi Control","icon":"dashboard","order":4},{"id":"8b537ae0.9e5938","type":"ui_tab","z":"","name":"CPU Temp","icon":"dashboard","order":5}]
Reply
#2
Updated flow to incorporate basic PWM fan speed control
Just change values in the "PWM Fan control" function node to configure temperature thresholds

Code:
[{"id":"d3940991.1a2ef8","type":"inject","z":"2b47cf3c.1f345","name":"","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"x":110,"y":180,"wires":[["1b8455a0.d1cbfa"]]},{"id":"1b8455a0.d1cbfa","type":"exec","z":"2b47cf3c.1f345","command":"vcgencmd measure_temp","addpay":false,"append":"","useSpawn":"","timer":"","oldrc":false,"name":"Read RPi Temp.","x":300,"y":180,"wires":[["c9389a57.3c92b8"],[],[]]},{"id":"c9389a57.3c92b8","type":"function","z":"2b47cf3c.1f345","name":"Convert to Number","func":"str = msg.payload\nmsg.payload = str.substring(5,9);\nmsg.payload = Number(msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":180,"wires":[["dca36c2e.25785","d44efe8e.eccc7","e2829e61.1dca8"]]},{"id":"dca36c2e.25785","type":"ui_gauge","z":"2b47cf3c.1f345","name":"","group":"3067d01a.af5d4","order":2,"width":0,"height":0,"gtype":"gage","title":"CPU Temperature","label":"C","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"60","seg2":"65","x":770,"y":60,"wires":[]},{"id":"d44efe8e.eccc7","type":"ui_chart","z":"2b47cf3c.1f345","name":"","group":"2381998f.63b6d6","order":0,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","ymin":"","ymax":"","removeOlder":"3","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"x":730,"y":120,"wires":[[],[]]},{"id":"e2829e61.1dca8","type":"function","z":"2b47cf3c.1f345","name":"PWM Fan Control","func":"if(msg.payload <=45) msg.payload = 0;\nelse if(msg.payload >45 && msg.payload <=55) msg.payload = 30;\nelse if(msg.payload >55 && msg.payload <=60) msg.payload = 50;\nelse if(msg.payload >60 && msg.payload <=65) msg.payload = 75;\nelse if(msg.payload >65) msg.payload = 100;\nreturn msg;","outputs":1,"noerr":0,"x":770,"y":180,"wires":[["84179128.fd722"]]},{"id":"84179128.fd722","type":"rpi-gpio out","z":"2b47cf3c.1f345","name":"Fan Control","pin":"12","set":false,"level":"1","freq":"","out":"pwm","x":990,"y":180,"wires":[]},{"id":"3ae31bf5.f57c24","type":"ui_switch","z":"2b47cf3c.1f345","name":"Fan Override","label":"Fan Override","group":"693e1549.6d363c","order":0,"width":"3","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"100","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":750,"y":240,"wires":[["84179128.fd722"]]},{"id":"3067d01a.af5d4","type":"ui_group","z":"","name":"Col1","tab":"7ae3bc3.4c07544","order":1,"disp":false,"width":"3"},{"id":"2381998f.63b6d6","type":"ui_group","z":"","name":"Temp Chart","tab":"8b537ae0.9e5938","disp":true,"width":"10"},{"id":"693e1549.6d363c","type":"ui_group","z":"","name":"Col3","tab":"7ae3bc3.4c07544","order":3,"disp":false,"width":"3"},{"id":"7ae3bc3.4c07544","type":"ui_tab","z":"","name":"RPi Control","icon":"dashboard","order":4},{"id":"8b537ae0.9e5938","type":"ui_tab","z":"","name":"CPU Temp","icon":"dashboard","order":5}]
Reply
#3
(2018-03-31, 03:27 PM)affinite Wrote: Updated flow to incorporate basic PWM fan speed control
Just change values in the "PWM Fan control" function node to configure temperature thresholds
Hi Affinite,
I'm a complete newbie in NodeRed ! Could you help me to implement that function into my configuration, knowing I 'm using a 5 V fan (0.2A) ?
I plan to use your circuit diagram, I would like the fan to start working for T>45°, and full fan speed when T reaches 65° ...
Cordialement
Didier B
Pi4, SSD USB3, OP 3.0 Touch SK 3.2.1 OpenCPN  5.8.4 :  Thank you  Thank you  Thank you


Reply
#4
(2019-04-22, 05:20 PM)Didier B Wrote:
(2018-03-31, 03:27 PM)affinite Wrote: Updated flow to incorporate basic PWM fan speed control
Just change values in the "PWM Fan control" function node to configure temperature thresholds
Hi Affinite,
I'm a complete newbie in NodeRed ! Could you help me to implement that function into my configuration, knowing I 'm using a 5 V fan (0.2A) ?
I plan to use your circuit diagram, I would like the fan to start working for T>45°, and full fan speed when T reaches 65° ...

Didier
I dont have access to my RPi at present to remind myself of the specific steps. 
Basically in order to setup the Node Red part you should

copy the code text I provided to the clipboard
Open Node Red and create new node and then paste the code provided into the code box
That code then drives GPIO poin 18 to turn the fan on and off

I dont have my RPi with me so I'll get my spare setup and give some step by step instructions in a day or two.
Regards
Steve
Reply
#5
https://www.youtube.com/watch?v=V0SmNcIYCtQ

http://forum.openmarine.net/showthread.php?tid=1032
Reply
#6
Didier
The Youtube video that Jim suggested gives a good indication on how to import code into a new Node Red Node. I suggest you watch it and the other beginners tutorials in order to get a good basic understanding of how Node Red works.
When you are comfortable with editing your Node Red flows then copy all the code in my second post to the clipboard, and go into Node Red 
Use the import function to import my code from the clipboard into your flow
Once you can see the new Nodes in your flow, double click on the "PWM Fan control" function node
If you look at the code you will see some bands/steps that I used to run the fan at various settings depending on CPU temperature
You will see that I have started the fan running at 30% when the temp is above 45 degrees. There are steps at 55 degrees and 60 degrees but at 65 degrees I turn the fan up to 100% 
Regards
Steve
Reply
#7
Thank you Steve and Jim321 !
I'll give it a try ASAP !
I'll come back to this thread as soon as I get some results Smile
Cordialement
Didier B
Pi4, SSD USB3, OP 3.0 Touch SK 3.2.1 OpenCPN  5.8.4 :  Thank you  Thank you  Thank you


Reply
#8
Photo 
Hi !


I was so inspired by this post, thanks !!,  so I did some fine-tuning and documented it in this post https://pysselilivet.blogspot.com/2019/0...ntrol.html

   
________________________________________

Blog; https://pysselilivet.blogspot.com/
Reply
#9
Waowwww
Looks great ! Leaving soon for summer cruise,  I will try it in september !

Sailoog, I know you are VERY BUSY, but would there be any chance to get this on board for R2 ?
Cordialement
Didier B
Pi4, SSD USB3, OP 3.0 Touch SK 3.2.1 OpenCPN  5.8.4 :  Thank you  Thank you  Thank you


Reply
#10
Fun, but why would this be more important than getting a new version out the door, as the people interested in it can install it themselves?


Sent from my iPhone using Tapatalk
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)