emeraldlkp.blogg.se

Automatic temperature controlled fan using arduino
Automatic temperature controlled fan using arduino









automatic temperature controlled fan using arduino

You can view the Channel Stats in ThingSpeak and observe the live temperature, the status of the fan, and the runtime values. The data from BMP280 sensor is sent to the channel.

#Automatic temperature controlled fan using arduino code

Note: To stop the while loop and stop executing the code (to stop sending data to the ThingSpeak channel), press Ctrl+C in the MATLAB Command Window. X=thingSpeakRead(ChannelID, 'ReadKey',ReadAPI, 'Fields',4) Y=thingSpeakRead(ChannelID, 'ReadKey',ReadAPI, 'Fields',) % Switching on the relay and turning on the fan ThingSpeakWrite(ChannelID, 'WriteKey',WriteAPI, 'Fields',) WriteDigitalPin(a, 'D2',1) % Writing 1 to D2 disconnects the relay switchįlag=0 % start/stop the timer based on this variable In this example, we set the threshold to 26 degree celsius (you can change it, if required).Ī=arduino( 'COM9', 'Uno', 'Libraries', 'I2C') Replace the values of ChannelID, ReadAPI and WriteAPI variables to match the actual values corresponding to your channel.

automatic temperature controlled fan using arduino

Run these commands, one after the other, in the MATLAB command window (it is assumed that Arduino board is connected to COM9 port). After comparing the temperature against a threshold (26 degree celsius), we use the Write API Key to send the signal that triggers the fan control on pin D2 of Arduino board that is connected to the relay, and also to send the calculated run time values to the same channel. To explore the data from the sensor and find the temperature using ThingSpeak, we use the Read API Key.

automatic temperature controlled fan using arduino

In this example, we use a custom MATLAB code that reads temperature data from the channel (the data which is originally obtained from the BMP280 sensor) and triggers a signal when temperature crosses a threshold, and then writes the result back to the channel. The bmp280 object in MATLAB Suport Package for Arduino Hardware establishes a connection to the connected BMP280 sensor and reads the temperature data. The MATLAB code uses channel ID and its Write API Key to publish data over IoT to the ThingSpeak channel. You can run the MATLAB code on the Arduino board that has BMP280 sensor connected. Run MATLAB Code to Obtain Temperature Data from BMP280 Sensor











Automatic temperature controlled fan using arduino