I am using a l293d ic to control a fan with my raspberry pi
I am using a l293d ic to control a fan with my raspberry pi. What is the code to control the fan based on temperature?
Solution
Requirements
Software
I2C
Follow the article here to setup I2C to communicate to the temp sensor.
Installing GPIO capability
Type the following in the Pi terminal to install GPIO capability: sudo apt-get install python-rpi.gpio
Testing Connections
Upload the following Python program to the Raspberry Pi in order to test the fan control from the GPIO. Run the script \"turn_fan_on.py\" or \"turn_fan_off.py\" in order to verify the connections.
turn_fan_on.py
turn_fan_off.py
Controlling the fan based on temperature
The following script implements some logic that turns on the fan when the temperature has risen above TEMP_THRESHOLD. The fan will stay on until the temperature drops below the threshold - TEMP_HYST. This way the fan doesn\'t rapidly turn on and off when the room is around the temperature threshold.
