新手请教个问题,我用的是esp01s,继电器是JQC-3FF-S-Z淘宝上买的,链接https://detail.tmall.com/item.htm?id=15909056050&spm=a1z09.2.0.0.5feb2e8du8xut5&_u=91mh409d62a,但是死活就是不触发,继电器的指示灯是亮的(红灯和绿灯都亮)用的是io2发送高低电平信号,代码用的是arduino IED自带的Blink那个实例改的,就是把LED_BUILTIN改成了pin,pin=2,继电器是设置为高电平触发。完整代码如下:
/*
ESP8266 Blink by Simon Peter
Blink the blue LED on the ESP-01 module
This example code is in the public domain
The blue LED on the ESP-01 module is connected to GPIO1
(which is also the TXD pin; so we cannot use Serial.print() at the same time)
Note that this sketch uses LED_BUILTIN to find the pin with the internal LED
*/
int pin=2;
void setup() {
pinMode(pin, OUTPUT); // Initialize the LED_BUILTIN pin as an output
}
// the loop function runs over and over again forever
void loop() {
//原来是LED_BUILTIN的地方,改成了pin
digitalWrite(pin, LOW); // Turn the LED on (Note that LOW is the voltage level
// but actually the LED is on; this is because
// it is active low on the ESP-01)
delay(1000); // Wait for a second
digitalWrite(pin, HIGH); // Turn the LED off by making the voltage HIGH
delay(2000); // Wait for two seconds (to demonstrate the active low LED)
}
通过使用电表测量,io2引脚确实是高低电平每秒钟交替变化,也就是说代码貌似没什么问题,但是继电器没有任何反应,反而板载的led灯一秒钟闪一次,继电器不是只要电平变化就能触发的吗,难道还有其他条件?一开始怀疑是电流不够,看继电器产品说明需要5mA电流,拿电表测了电流,发现是3点几毫安,于是尝试增大了电流超过5mA,继电器上绿灯红灯都是亮的。结果继电器仍然没有反应,实在没招了,请各位帮帮忙。
esp01s继电器不触发
Re: esp01s继电器不触发
您好:
您可以先检查一下您的继电器触发信号是否是 3.3V,并且使用模组的 3.3V 与 GND 测试触发情况。
您可以先检查一下您的继电器触发信号是否是 3.3V,并且使用模组的 3.3V 与 GND 测试触发情况。
Who is online
Users browsing this forum: No registered users and 90 guests