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!

Contact

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

Edison Weather Station
Intermediate
  • 33
  • 2

Full instructions

A simple weather station based on edison board.

Starry Night Prom
Intermediate
  • 2,675
  • 22

How did I stand out at prom? In a light up dress of course!

Autonomous Plant (ESP8266 - Arduino)
Intermediate
  • 108
  • 2

Full instructions

Want to build system that takes care of a plant? Here's my first attempt. Using ESP8266, soil moisture and Sonoff grow light

SSH Raspberry Pi 2 in Ubuntu
Intermediate
  • 57
  • 2

Full instructions

Simple method to SSH Raspberry pi from Ubuntu

Arduino 101 Packet Radio IMU
Intermediate
  • 1,051
  • 3

Packet Radio on your Arduino 101 - The Arduino 101 Orientation Visualizer redone with Packet Radio!

Face Detection Using OpenCV With Raspberry Pi
Intermediate
  • 3,641
  • 33

Protip

In this project, we are going to detect faces using OpenCV with Raspberry Pi.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login