Please help with code

Help with writing code for esp8266 board. It is necessary that at one temperature the steppe motor moves in one direction, and when there was a different temperature, it moves in the other direction

Welcome to the forum

Why did you start a topic in the Uncategorised category of the forum when its description is

:warning: DO NOT CREATE TOPICS IN THIS CATEGORY :warning:

Your topic has been moved to the Programming category

What code do you have so far ?

Before asking questions:


  • Questioners know what their hardware and software looks like but the volunteers here do not; you need to fully explain what’s not working, and how it is supposed to work.
  • Please read all the posting guidelines before asking your questions; follow these guidelines in your post.

Hardware

  • As always, show us a good schematic of your proposed circuit.
  • Show us good images of your ‘actual’ wiring.
  • Give WEB links to your major components.

Software

  • In the Arduino IDE, use Ctrl T or CMD T to format your code, then copy the complete sketch.
  • Use the < CODE / > icon from the ‘posting menu’ to attach your copied sketch.

When you follow the posting guidelines, volunteers can be more effective.

@andrewal - they are here:

What help, exactly, do you need?
How far have you got by yourself? Where are you stuck?

Do you have a LM35 or DS18B20 type temperature sensor?
Do you have a SG-90 or similar Servo Motor?
Do you have a seperate 5V/1A DC Power Supply to feed powr to the Servo Motor?

If the naswers are yes, then you can move forward with your project.

#include <dht11.h> // Подключаем библиотеку для управления сервоприводом
#include <servo>

#define SERVO_PIN 8 // Пин, к которому подключен сервопривод
#define DHT11_PIN 7

Servo servo; // Создаем экземпляр объекта Servo

void setup() {
servo.attach(SERVO_PIN); // Подключаем сервопривод к указанному пину
}

void loop() {
float temperature = readTemperature(); // Читаем значение температуры

// Выводим значение температуры в монитор последовательного порта
Serial.print("Temperature: ");
Serial.println(temperature);

// Проверяем условия температуры для управления сервоприводом
if (temperature < 15) {
// Вращаем сервопривод против часовой стрелки
servo.write(0);
} else if (temperature > 25) {
// Вращаем сервопривод по часовой стрелке
servo.write(180);
}
}

float readTemperature() {
// Здесь вам нужно добавить код для считывания температуры с датчика
float temperature = 0.0;
код для считывания температуры ...
return temperature;
}

temperature sensor DHT11

Hi, @andrewal
Welcome to the forum.

What does your code do at the moment?

Are you getting valid readings from the DHT11?

Can you please post a copy of your circuit a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Do you have a stepper motor or a servo?

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

What is about Servo Motor and Power Supply? Do you have these?

Yes, I have everything. The board is now arduino uno

I use Steppe motor count, see above, unfortunately I can’t throw off the diagram, since I’m away now

Can you please post the dht11.h Library as an attached file? I can't compile your sketch of post #6.

https://drive.google.com/drive/folders/1mJVI-IzPX7-CWleIajH_4XGnACtSqF3C?usp=drive_link I don't remember one of the two. Only the file needs to be uploaded to the arduino folder where all the libraries are

1. Include the zipped folder (dht 0.1.13) that you have passed to me in your Arduino IDE. I have also attached the folder for you.

2. Upload the following sketch (your one slightly modified; compiled and not tested).

#include<Servo.h>
#include <dht.h>
dht DHT;
Servo servo;

#define SERVO_PIN 8 // Пин, к которому подключен сервопривод
#define DHT11_PIN 7

void setup()
{
 Serial.begin(115200);
 Serial.println("DHT TEST PROGRAM ");
}

void loop()
{
 int chk = DHT.read11(DHT11_PIN);
 float myTemp = DHT.temperature;
 // Выводим значение температуры в монитор последовательного порта
 Serial.print("Temperature: ");
 Serial.println(myTemp, 1);  //1-digit after decimal point
 // Проверяем условия температуры для управления сервоприводом
 if (myTemp < 15.0)
 {
   // Вращаем сервопривод против часовой стрелки
   servo.write(0);
 } else if (myTemp > 25.0) {
   // Вращаем сервопривод по часовой стрелке
   servo.write(178);
 }
 delay(2000);
}

3. Post the feedback.
4. Please, read Section-13.5 of the attached pdf file on dht11 sensor.
Ch-13SensorsLec.pdf (1.3 MB)
dht 0.1.13.zip (9.1 KB)

2 posts were split to a new topic: Cleaning Solar Panels

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