Auteur CETECH11 | Dernière modification 18/11/2023 par CETECH11
LED, Lights, Neo Pixel RIng, Arduino Nano, DHT11, Temperature Sensor Temperature_Control_Neo_Pixels_with_Arduino_Nano_1.JPG Circuitry
A NeoPixel ring controlled by a DHT11 sensor and an Arduino Nano can be a fascinating project that combines temperature sensing with visual feedback. This article will guide you through the process of building such a system.
You must check out PCBWAY for ordering PCBs online for cheap!
You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Also, check out this useful blog on PCBWay Plugin for KiCad from here. Using this plugin, you can directly order PCBs in just one click after completing your design in KiCad.
First, connect the DHT11 sensor and the Neo Pixel ring to the Arduino Nano. The DHT11 sensor can be connected to any digital pin on the Arduino Nano. The Neo Pixel ring should be connected to the D2 pin of the Arduino Nano.
You will need to install the DHT library and the Adafruit Neo Pixel library in your Arduino IDE. These libraries contain the necessary functions to interact with the DHT11 sensor and the Neo Pixel ring.
First Navigate to Sketch > Include Library > Manage Libraries...
In the Library Manager, there is a search box. Type “DHT sensor library” into the search box.
In the search results, find the library named “DHT sensor library” by Adafruit. Click on it, then click the “Install” button.
And that’s it! You’ve successfully installed the DHT11 sensor library in Arduino IDE. This library should now be available for inclusion in your sketches.
The next step is to program the Arduino Nano. The program should read the temperature from the DHT11 sensor and change the color of the Neo Pixel ring based on the temperature.
For example, you could program the Neo Pixel ring to display a blue color when the temperature is below a certain threshold.
A green color when the temperature is within a comfortable range,
and a red color when the temperature is above a certain threshold.
#include <Adafruit_NeoPixel.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#define DHTTYPE DHT11 // DHT 11
#define DHTPIN 3
DHT_Unified dht(DHTPIN, DHTTYPE);
#define PIN 2 // Neo
Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(115200);
dht.begin();
sensor_t sensor;
strip.begin();
strip.setBrightness(100);
strip.show();
}
void loop() {
sensors_event_t event;
dht.temperature().getEvent(&event);
Serial.print(F("Temperature: "));
float temp1 = event.temperature;
Serial.print(temp1);
Serial.println(F("°C"));
dht.humidity().getEvent(&event);
Serial.print(F("Humidity: "));
float hum1 = event.relative_humidity;
Serial.print(hum1);
Serial.println(F("%"));
if (temp1 >= 28 && temp1 < 31) {
strip.clear(); // Set all pixel colors to 'off'
for (int i = 0; i < 12; i++) { // For each pixel...
strip.setPixelColor(i, strip.Color(0, 150, 0));
strip.show();
}
}
else if (temp1 < 28) {
strip.clear();
for (int i = 0; i < 12; i++) { // For each pixel...
strip.setPixelColor(i, strip.Color(0, 0, 150));
strip.show();
}
}
else {
strip.clear();
for (int i = 0; i < 12; i++) { // For each pixel...
strip.setPixelColor(i, strip.Color(150, 0, 0));
strip.show();
}
}
}
en none 0 Published
Vous avez entré un nom de page invalide, avec un ou plusieurs caractères suivants :
< > @ ~ : * € £ ` + = / \ | [ ] { } ; ? #