Skip to content

Instantly share code, notes, and snippets.

@andrew-ayers
Forked from creationix/a-notes.md
Created November 4, 2016 02:07
Show Gist options
  • Save andrew-ayers/36fb831ea9cc724cdbd6553793ec0706 to your computer and use it in GitHub Desktop.
Save andrew-ayers/36fb831ea9cc724cdbd6553793ec0706 to your computer and use it in GitHub Desktop.
gikfun esp8266 kit

Amazon has a really good deal on an ESP8266 board in stock with prime. http://www.amazon.com/Gikfun-ESP8266-ESP-12-Industrial-version/dp/B00RK1W7R6

There are no instructions with it so I bought one and between probing with my multimeter and trying different things, I was able to get nodemcu running.

Yellow jumper seems to toggle between flash mode and at mode, closed is flash mode.

three pins labeled gnd, tx, tr are for uart and are what you should plug in. tx-tx,rx-rx,gnd-gnd.

You can leave power dangling

The other pins are set as needed for normal operation.

I have no idea what firmwware it comes with, but nodemcu flashed just fine using their windows based flasher.

After that I was able to pull the jumper and connect to the lua repl using 9600 baud (default for nodemcu firmware)

Tri-color LED pins (nodemcu numbering) https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en#new_gpio_map

  • 6 - green
  • 7 - blue
  • 8 - red

There are also 6 red LEDs for testing other pins. High is off, low is on. Their nodemcu numbers (going from tiny blue to rgb) are:

  • 4
  • 3
  • 2
  • 1
  • 5
  • 0

Writing to 9 seems to crashe the repl. Perhaps it's reset?

10 - is the blue led on ESP chip itself.

setting 11 or 12 to output resets the device.

for i = 0, 8 do
gpio.mode(i, 1)
end
tmr.alarm(0, 500, 1, function ()
for i = 0, 8 do gpio.write(i, math.random(2) - 1) end
end)
red, green, blue = 8, 6, 7
color = 0
usePwm = true
if usePwm then
pwm.setup(red, 500, 512)
pwm.setup(green, 500, 512)
pwm.setup(blue, 500, 512)
pwm.start(red)
pwm.start(green)
pwm.start(blue)
function led(r, g, b)
pwm.setduty(red, r)
pwm.setduty(green, g)
pwm.setduty(blue, b)
end
tmr.alarm(0, 10, 1, function ()
color = (color + 1) % 360
if color < 120 then
led(color, 120 - color, 0)
elseif color < 240 then
led(240 - color, 0, color - 120)
else
led(0, color - 240, 360-color)
end
end)
else
floor = math.floor
gpio.mode(red, gpio.OUTPUT)
gpio.mode(green, gpio.OUTPUT)
gpio.mode(blue, gpio.OUTPUT)
tmr.alarm(0, 1000, 1, function ()
color = (color + 1) % 8
gpio.write(red, color % 2)
gpio.write(green, floor(color / 2) % 2)
gpio.write(blue, floor(color / 4) % 2)
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment