NodeMCU Config

= Micropython =

Basics
sudo pip install esptool 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
 * Installing:

import esp esp.check_fw
 * Check the firmware integrity:

sudo apt install picocom picocom /dev/ttyUSB0 -b115200
 * Connecting via Terminal:

import webrepl_setup
 * Connecting via REPL(web):

If you disabled automatic start-up on boot, you may run configured daemon on demand using: import webrepl webrepl.start

import os os.listdir
 * Checking filesystem:

os.mkdir('dir')
 * Create directories:

os.remove('data.txt')
 * Remove Files:

f = open('data.txt', 'w') f.write('some data') f.close
 * Writing Data to files:

f = open('data.txt') f.read f.close
 * Reading data:

import machine machine.freq               # get the current frequency of the CPU machine.freq(160000000)      # set the CPU frequency to 160 MHz
 * Checking Machine Frequency & Overclocking:

import network ap = network.WLAN(network.AP_IF) print(ap.config('essid'))
 * Check AP Name:

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'))
 * Change AP name and password:

As a final step of boot procedure, main.py is executed from filesystem This file is a hook to start up a user application each time on boot (instead of going to REPL). For small test applications, you may name them directly as main.py but instead it’s recommended to keep your application(s) in separate files, and have just the following in main.py:
 * Boot Process:

import my_app my_app.main

sudo pip install adafruit-ampy ampy --port /dev/ttyUSB0 put ~/Desktop/main.py
 * Upload data using Serial Port

Deep-sleep mode

 * This shut down the ESP8266 and all its peripherals & also WiFi.
 * But not including the real-time-clock, which is used to wake the chip.
 * This drastically reduces current consumption and is a good way to make devices that can run for a while on a battery.
 * You Must connect GPIO16 to the reset pin.

Control a hobby servo
Hobby servo motors can be controlled using PWM. They require a frequency of 50Hz and a duty between about 40 and 115, with 77 being the center value.


 * Manual Movements


 * Random movements:

One Wire DS18B20 Temp Sensor

 * References