Esp8266 mqtt stepper motor remote control curtains

28BYJ-48 using a stepping motor esp8266-12f (or nodemcu) mqtt arduino IDE Based development
to control the motor by wifi module further MQTT transmission instruction, the curtains open or closed motor drive

The demo Address:
Link

Construction model

How to make electric curtains, cattle explain to you how it works
reference this video to build a model curtains
enter description here

It is important to build a model of stability, even if the motor can not control but the curtains open and closed models built are affected

  • To stick firmly motor
  • Thin ropes to choose coarse (high friction)
  • Soft paper cloth or curtains selected from
  • Pulleys must be done very carefully the impact rotation

Do I first trial demonstrated that to work when making a model curtains, made a lot of wrong doing was ugly
, but experiment a success! ! !
enter description here

Our second model is my curtains and other java big brother stay up late to do it, two engineering students to do by hand is really too tortured people ...
enter description here

Stepper motor principle

A stepping motor 28BYJ-48
enter description here

Meaning 28BYJ-48 an outer diameter of 28 mm was shot eight four-phase permanent magnet stepping motor reducer
for driving the stepping motor 28BYJ-48, the most common method is to use a ULN2003 driver board.
With the + 5V power Arduino development board method directly ULN2003 driver board power supply is short-time test, but do not supply power to the drive plate ULN2003 prolonged use of Arduino.
enter description here

A more detailed analysis of the principles link

Stepper motor control

FIG circuit wirings
enter description here

Stepper library used
to establish a stepping motor objects
define the motor control pin and basic information motor.
Motor control pin is 8,9,10,11
or more pins are sequentially connected ULN2003 driver board In1, In2, In3, In4
Create Object motor

示例代码
参考 dianji.ino 学习stepper库的使用方法
创建对象 Stepper steppermotor(STEPS_PER_ROTOR_REV, 8, 10, 9, 11);
其中的第一个参数为 一次转动的步数
在这里可以设置为2048

示例代码

/*
  Arduino控制28BYJ-48步进电机测试程序
  本示例程序旨在演示如何通过Arduino控制28BYJ-48步进电机。
*/
 
//本示例程序使用Stepper库
#include 
 
// 定义电机控制用常量
 
// 电机内部输出轴旋转一周步数
const int STEPS_PER_ROTOR_REV = 32; 
 
//  减速比
const int GEAR_REDUCTION = 64;
 
/*
 * 转子旋转一周需要走32步。转子每旋转一周,电机输出轴只旋转1/64周。
 * (电机内部配有多个减速齿轮,这些齿轮会的作用是让转子每旋转一周,
 * 输出轴只旋转1/64周。)
 * 因此电机输出轴旋转一周则需要转子走32X64=2048步,即以下常量定义。
*/
 
// 电机外部输出轴旋转一周步数 (2048)
const float STEPS_PER_OUT_REV = STEPS_PER_ROTOR_REV * GEAR_REDUCTION;
 
// 定义电机控制用变量
 
// 电机旋转步数
int StepsRequired;
 
// 建立步进电机对象
// 定义电机控制引脚以及电机基本信息。
// 电机控制引脚为 8,9,10,11 
// 以上引脚依次连接在ULN2003 驱动板 In1, In2, In3, In4 
 
Stepper steppermotor(STEPS_PER_ROTOR_REV, 8, 10, 9, 11); 
 
void setup()
{
//setup函数内无内容
}
 
void loop()
{
  // 极慢转动4步用于观察ULN2003电机驱动板LED变化
  steppermotor.setSpeed(1);    
  StepsRequired  =  4;
  steppermotor.step(StepsRequired);
  delay(1000);
 
   // 慢速顺时针旋转一圈
  StepsRequired  =  STEPS_PER_OUT_REV; 
  steppermotor.setSpeed(500);   
  steppermotor.step(StepsRequired);
  delay(1000);
  
  // 快速逆时针旋转一圈
  StepsRequired  =  - STEPS_PER_OUT_REV;   
  steppermotor.setSpeed(800);  
  steppermotor.step(StepsRequired);
  delay(2000);
 
}

参考太极创客链接

wifi模块控制电机

依旧使用的stepper库更改了GPIO引脚
创建对象
Stepper steppermotor(STEPS_PER_OUT_REV, D1, D2, D5, D6);
Stepper steppermotor(STEPS_PER_OUT_REV, 5, 4, 14, 12);
(两个一样)

看到国外一个使用nodemcu mqtt 以及 28BYJ-48步进电机的使用方法
更换了引脚 更改了部分参数 成功了

接线图
enter description here
enter description here
(对应GPIO 分别是GPIO 5,GPIO 4, GPIO14, GPIO12)

创建的对象为 Stepper steppermotor(STEPS_PER_OUT_REV, D1, D2, D5, D6);
其中第一个参数设置为200 速度设置80 相比于arduino都比较小
将第一个参数提升到600时电机转不动… 没找到原因

项目参考代码链接

GitHub地址

更多学习教程

ESP开发学习基础知识

基础知识包括对esp模块的认识与了解 mqtt协议的了解,arduino IDE运用代码编写等等。

  1. arduino基础学习
  2. esp系列模块的介绍
  3. mqtt协议的介绍与使用
  4. 利用mqtt esp模块 基于arduino IDE开发方法
  5. AT command esp brush firmware module
  6. esp module using sleep mode
  7. esp8266-01s introduction and use
  8. esp8266-12f introduction and use
  9. NodeMcu introduction and use
esp development of IOT applications

Based modules and other modules esp8266 application scenario according to an actual production and demand of Things

  1. FRID access control systems FRID arduino relay electromagnetic lock-based development
  2. esp32-cam video stream acquired image processing
  3. Stepping motor esp8266 mqtt developed automatic curtain control
  4. Gets indoor temperature and humidity based on DHT11 Esp8266 mqtt
  5. Gets indoor air quality based on CCS811 esp8266 mqtt
  6. Based on infrared remote control intelligent module esp8266 mqtt development
  7. Based ws2812 esp8266 mqtt development of intelligent multi-level lighting
  8. Based ws2812 esp8266 mqtt development of intelligent multi-mode light atmosphere
  9. Broadcast System Intelligent Voice mp3player esp8266 mqtt based development
  10. The wisdom of the comprehensive application of IOT classroom project development
Published 46 original articles · won praise 59 · views 70000 +

Guess you like

Origin blog.csdn.net/Nirvana_6174/article/details/104563479