Giter VIP home page Giter VIP logo

rpifanpwm's Introduction

RpiFanPwm

树莓派通过UDP发送PWM指令控制风扇转速. 硬件平台为ESP8266WIFI版本,树莓派为4B.

因为通过树莓派直接PWM控制风扇一直不成功,我怀疑是树莓派的PWM引脚有些问题,所以只能绕路通过单片机硬件PWM,树莓派发送PWM数据到单片机.

device

树莓派

发送端为Rust编写,可以使用下面命令编译为可执行文件:

cd report
cargo build --release

编译完成之后可执行文件在 ~/report/target/release 中.
如果你需要自行定义单片机的地址和端口,则更改 ~/report/src/main.rs中的:

let addr = "192.168.3.6:8088";

将此处替换为你的地址并重新编译.

单片机

单片机为Arduino IDE工程,使用Arduino IDE直接打开即可.
不过需要注意的是,这里我使用的是ESP8266这个平台,如果你的硬件型号不一样,可以调整内部头文件或者代码.

源文件内部没有填写WIFI认证信息,你需要自行补齐:

#ifndef STASSID
#define STASSID ""
#define STAPSK  ""
#endif

针脚定义:

const int SPEED = D2;
const int PWM = D1;

UDP端口:

unsigned int PORT = 8088;

安装

为了避免树莓派每次重启之后都需要手动启动进程的问题, 你可以使用自动化脚本安装服务:

./install.sh
systemdctl status rpifanpwm.service

服务将自动安装并开机启动.

License

MIT Copyright (c) 2020 Mr.Panda.

rpifanpwm's People

Contributors

mycrl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.