Print Friendly, PDF & Email

Components Required:

1. NodeMCU DEVKIT – Buy

2. Linux PC/Windows PC (Tested with Windows 10, Ubuntu 14.04 LTS)

3. Micro USB cable – Buy

Way to go ->

1. Connect NodeMCU DEVKIT to PC via the Micro USB cable.

2. Write the following Lua scripts and upload to NodeMCU.

init.lua

wifi.setmode(wifi.STATION)
wifi.sta.config("wifi_name","wifi_password")
print(wifi.sta.getip())
dofile("FromTS.lua")

FromTS.lua – this script will read the last stored data point on the ThingSpeak Chart

function RemoveHeaders()
	http.get("https://api.thingspeak.com/channels/your_Channel_ID/fields/1/last?key=Read_API_Key", nil, function(code, data)
    if (code < 0) then
      print("HTTP request failed")
    else
      print("Voltage = " .. data .. " V")
    end
  end)
end

-- every 5 seconds, check ThingSpeak
tmr.alarm(0, 5000, 1, function() RemoveHeaders() end)

ESPlorer output

FromTS