NodeMCU Projects: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 8: | Line 8: | ||
esptool.py --port /dev/ttyUSB0 erase_flash |
esptool.py --port /dev/ttyUSB0 erase_flash |
||
esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 ~/Desktop/esp8266-20171101-v1.9.3.bin |
esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash --flash_size=detect 0 ~/Desktop/esp8266-20171101-v1.9.3.bin |
||
*Connecting via Terminal: |
*Connecting via Terminal: |
||
Line 17: | Line 16: | ||
import webrepl_setup |
import webrepl_setup |
||
Following on-screen instructions. After reboot, it will be available for connection. |
|||
If you disabled automatic start-up on boot, you may run configured daemon on demand using: |
If you disabled automatic start-up on boot, you may run configured daemon on demand using: |
||
import webrepl |
import webrepl |
||
webrepl.start() |
webrepl.start() |
||
*Playing with GPIO: |
*Playing with GPIO: |
||
<syntaxhighlight lang="python"> |
|||
import machine |
import machine |
||
pin = machine.Pin(2, machine.Pin.OUT) |
pin = machine.Pin(2, machine.Pin.OUT) |
||
pin.on() |
pin.on() |
||
pin.off() |
pin.off() |
||
def toggle(p): |
def toggle(p): |
||
Line 39: | Line 36: | ||
toggle(pin) |
toggle(pin) |
||
time.sleep_ms(500) |
time.sleep_ms(500) |
||
</syntaxhighlight> |
|||
<syntaxhighlight lang="python"> |
|||
⚫ | |||
import machine |
|||
import time |
|||
pin = machine.Pin(2, machine.Pin.OUT) |
|||
def toggle(p): |
|||
p.value(not p.value()) |
|||
while True: |
|||
for i in range(100,999): |
|||
time.sleep_ms(i) |
|||
toggle(pin) |
|||
</syntaxhighlight> |
|||
⚫ | |||
import os |
import os |
||
os.listdir() |
os.listdir() |
||
*Create directories: |
|||
os.mkdir('dir') |
|||
*Remove entries: |
|||
os.remove('data.txt') |
|||
* Checking Machine Frequency & Overclocking: |
* Checking Machine Frequency & Overclocking: |
||
Line 48: | Line 67: | ||
machine.freq() # get the current frequency of the CPU |
machine.freq() # get the current frequency of the CPU |
||
machine.freq(160000000) # set the CPU frequency to 160 MHz |
machine.freq(160000000) # set the CPU frequency to 160 MHz |
||
*Check AP Name: |
|||
import network; |
|||
ap = network.WLAN(network.AP_IF); |
|||
print(ap.config('essid')); |
|||
*Change AP name and password: |
|||
import network; |
|||
ap = network.WLAN(network.AP_IF); |
|||
ap.active(True); |
|||
ap.config(essid='MyESP8266', authmode=network.AUTH_WPA_WPA2_PSK, password='mypassword'); |
|||
print(ap.config('essid')); |
|||