So Easy MicroPython — ESP8266 Difi WF8266RDF IoT Learning Board and its Demos

Yungger
5 min readSep 22, 2021

DiFi is a learning board that integrates Relay, Photo-resistor, RGB LED, Button switch, Infrared sensor, Buzzer, DHT11 temperature and humidity sensor and other sensing components. It can save the complicated between ESP8266 and sensing components. Wiring, supplemented by the following example, can complete the basic exercises of the whole set of components in a short time.

In addition to the basic sensors, the external pin design allows you to connect breadboards and other sensors by yourself.

*** Because its MCU is ESP8266, so it is an IoT enable device to let you remotely control your appliances ! ***

Some On-Board Sensors’ Demo

* Built-in LED ON-OFF

import utime as time
from MyMachinePin import myPin
led = myPin(2) # GPIO 2, OUTPUT
for _ in range(5):
led.on
time.sleep_ms(300)
led.off
time.sleep_ms(300)

* RGB LED

import utime as time
from MyKitLedRGB import myRGB
led = myRGB(12, 13, 14)
led.lightColor(“red”)
time.sleep(1)
led.lightColor(“green”)
time.sleep(1)
led.lightColor(“blue”)
time.sleep(1)
led.lightOFF()

* Button Switch

from MyMachinePin import myPinInput, myPinOutput 
sw = myPinInput(0) # 按鍵
led = myPinOutput(2) # 內建 LED while True: led.value(sw.value()) # SW 按下時, LED 亮, 放開滅

* Relay

from MyMachinePin import myPinInput, myPinOutput
sw = myPinInput(0) # 按鍵
led = myPinOutput(2) # 內建 LED
relay = myPinOutput(16) # 繼電器
while True:
val = sw.value()
led.on if val == 0 else led.off # SW 按下時, LED 亮, 放開時, 滅
relay.on if val == 0 else relay.off # SW 按下時, Relay 通電, 放開時, Relay 斷電

* IR Obstacle Avoidance Sensor

import utime as time
from MyMachinePin import myPinInput, myPinOutput
irsw = myPinInput(4) # 按鍵
led = myPinOutput(2) # 內建 LED
while True:
led.value(irsw.value()) # IR 偵測距離內(此板須與物體零距離完全接觸時), LED 亮, 遠離時, 滅

* Buzzer

from MyMachinePWM import myPWM
buzzer = myPWM(15) # GPIO 5, OUTPUT
buzzer.attach()
for _ in range(3):
buzzer.tone(1320) # Mi:659 或 1320
time.sleep_ms(500)
buzzer.toneoff
time.sleep_ms(500)
buzzer.detach()

* Photo-resistor

from MyMachinePin import myPin
from MyMachineADC import myADC
pr = myADC(0) # 光敏電阻
led = myPin(2) # 內建 LED
while True:
led.off if pr.value() < 800 else led.on # 遮蓋光敏電阻時, LED 亮, 放開時, 滅

* DHT11 Temperature and Humidity Sensor

from MyKitDHT import myDHT
my = myDHT(5, 2500) # 每 2500 毫秒才偵測一次
while True:
if my.measure():
print("Temperature:{} \u00b0C & {} \u00b0F, Humidity:{} %".format(my.C, my.F, my.H))

* IR Receiver

import utime as time
from MyMachinePin import myPin
from MyKitIR import myReceiver
ledR = myPin(12) # Led RED
ledG = myPin(13) # Led Green
ledB = myPin(14) # Led Blue
rx = myReceiver(4)print('Press your remote controller button and receive the IR signal ...')
while True:
try:
key, command, code, bits = rx.read()
if key is not None:
if key == '1':
# 紅
ledR.on
ledG.off
ledB.off
elif key == '2':
# 綠
ledR.off
ledG.on
ledB.off
elif key == '3':
# 藍
ledR.off
ledG.off
ledB.on
else:
ledR.off
ledG.off
ledB.off
time.sleep_ms(100)
except KeyboardInterrupt:
break

* IR Sender (+ Receiver)

import utime as time
from MyKitIR import myReceiver, mySender
rx = myReceiver(4)
tx = mySender(0)
print('Press your remote controller button and receive the IR signal ...')
while True:
try:
key, command, code, bits = rx.read()
if bits is not None:
bits = tx.getBits(code)
print('\nReceiced Key:{}, Command:{}, Value:{}, Bits:{} '.format(key, command, code, bits))
tx.send(bits)
print('\nSent Key:{}, Command:{}, Value:{}, Bits:{} '.format(key, command, code, bits))
time.sleep(3)
except KeyboardInterrupt:
break

Other Demos : Some Add-on Sensors or Modules

* WS2812 LED NeoPixel Strip

* Ultrasonic HC-SR04

* LCD1602

* SSD1306 OLED

* Servo

* … And almost every others sensors can DO !!

[ IoT Demos ]

* Connect Wifi and control LED remotely

* Press button and send out a LINE Notify immediately

That’s all, so easy right ? Hope this helps !

Posted by Yungger

If it really help you, you are welcome to clap your hands clicking on top-left icon, or want to buy me a coffee to encourage me to write more, I thank you too 😘 😘 !!

--

--