Fan Raspberry Pi 4

Good night folks can you tell me if there is any way to identify via command if the raspberry 4 cooler is on?

You could use this node:


And hook up a debug node to show the temperature.

Something like this:


But you will need a Clock source to pulse the node at a given rate.
(an inject node set to repeat ever 'n' seconds)


Good night friend .. actually the temperature indicator I already have .. but I would like to somehow validate if the fan is actually on or not

Detecting if the fan is actually spinning is a whole lot of fun.

Depending on how you want to do it.......

Physical detection of the fan spinning is not going to be easy. It requires some detection device to be physically installed (and before that BUILT!)

Detecting current flowing is also not easy. It requires extra circuitry to be installed.
That in itself creates heat. Any electronics does.

Why are you so worried?

So I use the raspberry in my project in a closed box, visually after closing the box I have no idea if the fan is running or not, and a factor that makes me more concerned is that the temperature even with the box is no more than 60G , so I would like to have more information on my monitoring panel

Well, fair enough.

In no particular order:
1 - What is the normal temperature range it will be seeing?
2 - Does it get too hot?
3 - Use a bigger fan.
4 - Add code so if it gets too hot it shuts down.

I have that on some of mine.

Here is a hacked version for a more generic use.
Mine has a lot more stuff in it which I am not wanting to share.

[{"id":"b504cda2.763398","type":"switch","z":"b4f1ccd4.5e8d1","name":"EXTREME HEAT 1","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"70","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":500,"y":730,"wires":[["c95d3e9f.a38208"]]},{"id":"6b8c6042.8e5118","type":"switch","z":"b4f1ccd4.5e8d1","name":"EXTREME HEAT 2","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"80","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":500,"y":770,"wires":[["80f3fff3.221eb8"]]},{"id":"c95d3e9f.a38208","type":"function","z":"b4f1ccd4.5e8d1","name":"1","func":"msg.payload = 1;\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":730,"wires":[["676fd85b.2c1fb"]]},{"id":"80f3fff3.221eb8","type":"function","z":"b4f1ccd4.5e8d1","name":"2","func":"msg.payload = 2;\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":770,"wires":[["676fd85b.2c1fb"]]},{"id":"676fd85b.2c1fb","type":"function","z":"b4f1ccd4.5e8d1","name":"Make message","func":"//  Set up messages\nvar name = (\"Your Device Name here\");\nvar msg1 = {};\nvar msg2 = {};\nvar msg3 = {};\nmsg1 = {payload: \"Over temperature\"};\nmsg2 = {payload: \"Shutting down.  Excess heat\"};\nmsg3 = {payload: \"sudo shutdown -h now\"};\n\nif (msg.payload == 1)\n{\n    return [msg1,null,null];\n} else\nif (msg.payload == 2)\n{\n    return [msg1, msg2, msg3];\n} else\nif (msg.payload == \"TEST\")\n{\n    return [msg1,msg2,null];\n}","outputs":3,"noerr":0,"x":840,"y":730,"wires":[[],[],[]],"outputLabels":["State message","Broadcast message","Shutdown command"]},{"id":"38b3fb72.fb9f4c","type":"function","z":"b4f1ccd4.5e8d1","name":"Existing temperature output","func":"\nreturn msg;","outputs":1,"noerr":0,"x":220,"y":750,"wires":[["b504cda2.763398","6b8c6042.8e5118"]]},{"id":"3c09cade.f5275e","type":"comment","z":"b4f1ccd4.5e8d1","name":"Message saying what is happening.","info":"","x":1110,"y":680,"wires":[]},{"id":"29fe5922.bd344e","type":"comment","z":"b4f1ccd4.5e8d1","name":"Message saying machine shutting down","info":"","x":1120,"y":730,"wires":[]},{"id":"b03d23e5.1291d8","type":"comment","z":"b4f1ccd4.5e8d1","name":"Send this to an `exec` node","info":"","x":1090,"y":780,"wires":[]}]

But I think you will get the idea.

1 - What is the normal temperature range he will see?
Answer - Between 40 and 60
2 - Is it too hot?
Answer - on average 50
3 - Use a bigger fan.
Answer - I am using two

4 - Add code so that, if it gets too hot, it will turn off.

I will test your code thank you very much friend

You will need to tweak (edit) the two nodes which determine the "I'm getting hot" and the "I'm now shutting down" temperatures.

But that was a given.

There are other (better) ways of doing what I did.

I do things as I know how to. The two function nodes could be replaced with change nodes.
But I'm not going to be that picky.


What you really need to do is run the machine and see what it is reading.

If you are pushing it too hard, it won't be good.

2 fans... Yeah. Ok. Are they in series or parallel?

That can't quite work.

If it normally shows between 40 and 60. 50 can't be too hot.

You probably want to make "Too hot" to be 65.
Then maybe 68 SHUTDOWN.

Are you trying to identify whether the output pin has been set to switch the fan on, or whether the fan is actually rotating?

1 Like

I would like to identify if the fan is physically turning

The two fans then in series

A Pi 4 is designed to run at up to 85C I believe. It will throttle the processor so as not to run above that. I have a heatsink on mine and when working it runs close to that but rarely throttles. They are in cases which are more ventilation holes than case.

In order to do that in node-red you first have to decide what you are going to measure to know if it is turning. Measuring the current is one possibility as I think @Trying_to_learn suggested. You could fit a camera and actually see whether it is turning. A microphone could listen for the sound. Numerous ways, but before implementing it in node-red you need to know what you are trying to do.

the cool one .. so in my rasp I have two fans and only a few dicipators .. so my fear is that it will stop ventilating and burn the plate .. so I thought about bringing this information to the monitoring panel that I am developing

I understood friend .. I believed that because the fan junper was plugged into the raspberry it would have some feature, from the raspberry itself but ok, I will have to think of some alternative solution and implement it. thanks for listening

Simpler just to monitor the CPU temperature as @Trying_to_learn has suggested and then do something if it gets too hot. After a while you will see what temperature it runs at normally so can trigger an alarm if it goes much above that.

Yes. this can be a solution .. if you notify me in some way. I can send someone to take a look at the equipment

and, all things being good, it will probably never happen anyway.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.