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

Pool Buddy
Intermediate
  • 250
  • 5

Work in progress

Monitor and log water quality (pH & ORP) and temperature from everywhere.

Pulse Train Hat for Raspberry Pi Mecanum Bot Example
Intermediate
  • 782
  • 15

Full instructions

With this example, we show how to use the PTHAT and wireless Xbox controller to control a Mecanum Bot.

WiFi Messenger
Intermediate
  • 408
  • 8

Protip

Calling my son from his room using 2 ESP8266 modules, instead of shouting.

Smart Garden
Intermediate
  • 1,013
  • 11

Smart Garden is plant environmental monitoring system.

Intel Curie TinyTILE Dress: Accelerometer + Optical Fibers
Intermediate
  • 331
  • 10

Full instructions

A dress using Intel Curie accelerometer on TinyTILE and its small form factor to control colors of the optical fibers with arm movements.

Particle Photon Flip Dot Clock
Intermediate
  • 1,928
  • 30

Full instructions

The flip dot display uses an electromechanical dot matrix that spin from black to yellow to display text, numbers and more!

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Feedback