Things used in this project

Hardware components:
13711 01
SparkFun ESP8266 Thing - Dev Board
×1
09873 01a
SparkFun FTDI Basic Breakout - 3.3V
×1
Lithium Ion Cylindrical Battery - 3.7v 2200mAh
High Power - check below for the solar power version!
×1
R8326274 01
Raspberry Pi 2 Model B
×1
LiPo battery 200mAh or 400mAh
Low Power - the solar power version needs only a smaller battery
×1
0.5W solar panel
Low Power - the solar power version needs of course an solar panel 5.5V max., 110mA
×1
Software apps and online services:
Nodemcu style5 150px.png 150x150
NodeMCU firmware

Schematics

Modified LiPo charger - input from solar panel
Esp4

Code

init.luaLua
init script will be started by autostart of nodemcu, scripted in LUA language, change the SSID and passkey according to your Wifi AP, uncomment dofile ("thing.lua") if you want to autostart thing.lua after next boot
print('init.lua ver 1.2')
wifi.setmode(wifi.STATION)
print('set mode=STATION (mode='..wifi.getmode()..')')
print('MAC: ',wifi.sta.getmac())
print('chip: ',node.chipid())
print('heap: ',node.heap())
-- wifi config start
wifi.sta.config("SSID","passkey")
-- wifi config end
wifi.sta.connect()
 tmr.alarm(1, 1000, 1, function()
  if wifi.sta.getip()== nil then
  print("IP unavaiable, Waiting...")
 else
  tmr.stop(1)
 print("ESP8266 mode is: " .. wifi.getmode())
 print("The module MAC address is: " .. wifi.ap.getmac())
 print("Config done, IP is "..wifi.sta.getip())
 -- dofile ("thing.lua")
 end
end)
thing.luaLua
sending analog sensor data to ThingSpeak cloud for visualization, replace YOURWRITEKEY with your ThingSpeak write key
port = 80

function sendData()

t1=adc.read(0)
print("VOC:"..t1.." C\n")

-- conection to thingspeak.com
print("Sending data to thingspeak.com")
conn=net.createConnection(net.TCP, 0) 
conn:on("receive", function(conn, payload) print(payload) end)
-- api.thingspeak.com 184.106.153.149
conn:connect(80,'184.106.153.149') 
conn:send("GET /update?key=YOURWRITEKEY&field1="..t1.." HTTP/1.1\r\n") 
conn:send("Host: api.thingspeak.com\r\n") 
conn:send("Accept: */*\r\n") 
conn:send("User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n
")
conn:send("\r\n")
conn:on("sent",function(conn)
                      print("Closing connection")
                      conn:close()
                  end)
conn:on("disconnection", function(conn)
          print("Got disconnection...")
  end)
end

-- send data every X ms to thing speak
tmr.alarm(0, 10000, 1, function() sendData() end )
init.lua - the power test cycle LUALua
This trick helps to give a little time buffer in case you do want to flash a new LUA file ... without this you need to flash the nodeMCU code again to release the init.lua script ...
FileToExecute="pw.lua"
l = file.list();
for k,v in pairs(l) do
  if k == FileToExecute then
    print("*** You've got 5 sec to stop timer 0 ***")
    tmr.alarm(0, 5000, 0, function()
      print("Executing ".. FileToExecute)
      dofile(FileToExecute)
    end)
  end
end
pw.lua - the power test cycle LUALua
just does an deep sleep every 60 sec ... here is the place for ESP8266 code to be executed during wake up ... we moved from 60 sec now to 300 sec sleep (5 minutes)
interval = 60000000
node.dsleep(interval-tmr.now())

Credits

Guido web
fab-lab.eu

Maker!

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

NodeMCU Home Weather Station with Websocket
Intermediate
  • 301
  • 6

Full instructions

NodeMCU and BME280 Home Weather Station that serves a webpage using Websockets

PiMiniMint
Intermediate
  • 173
  • 4

Full instructions

Build your very own Linux terminal inside a mint tin!

Stepper Motor Control
Intermediate
  • 86
  • 3

Full instructions

A full featured Stepper control involving speed and line interpolation for 2 axis motion.

SORT4U
Intermediate
  • 69
  • 2

Full instructions

It's the sorting machine that you've been waiting for. Just throw all your junk in it and let it sort for you.

SORT4U

Team The Avengers

Solar Smart Greenhouse Using Vertical Aquaponic Towers
Intermediate
  • 3,154
  • 43

Work in progress

Feed your family with 22 sqm greenhousing by combining permaculture, aquaponic vertical towers and IoT.

Drop of Life
Intermediate
  • 676
  • 17

Full instructions

A display to remind me when I can donate blood and save lives, powered by the Red Cross API and Particle.

ProjectsCommunitiesContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback