Hello,
arduino newbie here. I have a project parts&code below for watering plants. Problem is that arduino board getting really hot (especially highlited part on picture). Could you please try to help me find out if it is a problem or give me an advice how to lower the heat generated. Thank you.
Parts:
UNO R3 ATmega328P
UNO Shield Ethernet Shield W5100 R3
temp&humidity DHT11
temp DS18b20 via 4,7k resistor
humidity 86062
water level HC-SR04
water pump driver L9110S
water pump 240L/H DC 12V 2 Phase CPU Cooling Car Brushless Water Pump Waterproof C1
AC 100V-240V Converter Adapter DC 9V 1A
connected to computer for debug
connected to ethernet
Code:
//dht11-moistureTemp
#include "DHT.h"
#define DHTPIN 3 // what digital pin we're connected to
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
//ds18b20-temp
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
//86062-hygrometer
//Constants
const int hygrometer = A0; //Hygrometer sensor analog pin output at pin A0 of Arduino
//Variables
int sh; //SoilHumidity
const int allowedMinimumSoilHumidity = 50;
//ThingSpeak
#include "ThingSpeak.h"
#define USE_ETHERNET_SHIELD
// Use wired ethernet shield
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
EthernetClient client;
unsigned long myChannelNumber = 164880;
const char * myWriteAPIKey = "";
// L9910 motor driver
static const int A_IA = 6;
static const int A_IB = 7;
int pump = 0;
// HC-SR04 ultrasonic
#define TRIGPIN 8 // Trig pin z HC-SC04 na pin 8;
#define ECHOPIN 9 // Echo pin z HC-SC04 na pin 9;
const int allowedMinimumWaterLevel = 8;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); //Begin serial communication
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Arduino smartGarden by George - ThingSpeak - v1.0"); //Print a message
sensors.begin();
Ethernet.begin(mac);
ThingSpeak.begin(client);
pinMode(A_IA, OUTPUT);
pinMode(A_IB, OUTPUT);
//Nastaví pin 9 jako vstupní
pinMode(ECHOPIN, INPUT);
//Nastaví pin 8 jako výstupní
pinMode(TRIGPIN, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
delay(2000);
pump = 0;
//dht11-moistureTemp
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");
Serial.print(f);
Serial.print(" *F\t");
Serial.print("Heat index: ");
Serial.print(hic);
Serial.print(" *C ");
Serial.print(hif);
Serial.println(" *F");
//ds18b20-temp
// Send the command to get temperatures
sensors.requestTemperatures();
Serial.print("Soil temperature: ");
Serial.println(sensors.getTempCByIndex(0)); // Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire
float st = sensors.getTempCByIndex(0);
//Update value every 1 sec.
//86062-hygrometer
// When the plant is watered well the sensor will read a value 380~400, I will keep the 400
// value but if you want you can change it below.
sh = analogRead(hygrometer); //Read analog value
sh = constrain(sh,400,1023); //Keep the ranges!
sh = map(sh,400,1023,100,0); //Map value : 400 will be 100 and 1023 will be 0
Serial.print("Soil humidity: ");
Serial.print(sh);
Serial.println("%");
// Vyšle impuls do modulu HC-SR04
digitalWrite(TRIGPIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIGPIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIGPIN, LOW);
// Spočítá vzdálenost
float distance = pulseIn(ECHOPIN, HIGH);
distance= distance*0.017315f;
// odešle informace na sérivý port
Serial.print(distance);
Serial.println("cm");
if (distance < allowedMinimumWaterLevel) {
if (sh < allowedMinimumSoilHumidity) {
Serial.println("PUMP ON!");
// pump on
pump = 1;
digitalWrite(A_IA, LOW);
digitalWrite(A_IB, HIGH);
delay(2000) ; // 5 seconds
// pump off
digitalWrite(A_IA, LOW);
digitalWrite(A_IB, LOW);
Serial.println("PUMP OFF!");
delay(2000) ; // 5 seconds
} else {
Serial.println("Soil is well moisturized already :-)");
}
} else {
Serial.println("ERROR MINIMUM WATER LEVEL REACHED!");
}
//ethernet
ThingSpeak.setField(1,t);
ThingSpeak.setField(2,h);
ThingSpeak.setField(3,st);
ThingSpeak.setField(4,sh);
ThingSpeak.setField(5,distance);
ThingSpeak.setField(6,pump);
ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
//Read frequency:
delay(13000);
}