Projects/ESP8266 - Pressure (BMP085) Temperature Humidity (DHT22)): Difference between revisions

From Playful Exploration
Jump to navigation Jump to search
No edit summary
No edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[category:ESP]]
[[category:ESP]] [[category:Projects]] [[category:Weather]]


Version 1 of the quick'n-dirty weather station is online for the first 24 hours, running on a USB power stick, sending air pressure, temperature and humidity data from the balcony up directly to the VPS's influxdb.  No mptt, just simple http web requests.  Version 2 will need some enclosure to protect the electronic from the elements.
Version 1 of the quick'n-dirty weather station is online for the first 24 hours, running on a USB power stick, sending air pressure, temperature and humidity data from the balcony up directly to the VPS's influxdb.  No mptt, just simple http web requests.  Version 2 will need some enclosure to protect the electronic from the elements.
Line 6: Line 6:


[[File:ESP8266 - Pressure Temperature Humidity.JPG|300px|right]]
[[File:ESP8266 - Pressure Temperature Humidity.JPG|300px|right]]
== Features ==
= Features =
* AMS1117-3.3 Voltage Regulator
* AMS1117-3.3 Voltage Regulator
* Microcontroller ESP8266
* Microcontroller ESP8266
Line 12: Line 12:
* Sensor driver build into the firmware
* Sensor driver build into the firmware
* DHT22 Temperature and Humidity Sensor, sensor specific single wire protocol
* DHT22 Temperature and Humidity Sensor, sensor specific single wire protocol
* BMP280 Barometric Pressure Sensor, I2C
* BME280 Barometric Pressure Sensor, I2C
* CP2102 USB to UART Adapter
* CP2102 USB to UART Adapter


== Http-Requests based Data Push to Influxdb ==
= Http-Requests based Data Push to Influxdb =
{| class="wikitable"
{| class="wikitable"
|-
|-
Line 28: Line 28:
|-
|-
| init.lua
| init.lua
(part 1)
| <source lang="lua" line>print("\n\nHold gpio0 low to stop boot")
| <source lang="lua" line>print("\n\nHold gpio0 low to stop boot")
tmr.delay(1000000)
tmr.delay(1000000)
Line 40: Line 41:
|-
|-
| init.lua
| init.lua
(part 2)
| <source lang="lua" line start="10">
| <source lang="lua" line start="10">
-- restart if stall
-- restart if stall
Line 67: Line 69:
</source>
</source>
| Net client connects to influxdb every 3 seconds and send data
| Net client connects to influxdb every 3 seconds and send data
The fully charged power stick last about 26 hours.
|}
= Weather Events =
{| class="wikitable"
! Event !! Graph
|-
| Hail Storm || [[File:20160331 weather event hail storm.jpg|600px]]
|-
| Rain Storm || [[File:20160604 weather event rain storm.PNG|600px]]
|}
|}

Latest revision as of 00:27, 6 May 2019


Version 1 of the quick'n-dirty weather station is online for the first 24 hours, running on a USB power stick, sending air pressure, temperature and humidity data from the balcony up directly to the VPS's influxdb. No mptt, just simple http web requests. Version 2 will need some enclosure to protect the electronic from the elements.

Graphical output using Grafana: https://www.playfulexploration.com/grafana/dashboard/db/pressure-temperatur-humidity-5min-interval

ESP8266 - Pressure Temperature Humidity.JPG

Features

  • AMS1117-3.3 Voltage Regulator
  • Microcontroller ESP8266
  • Firmware Lua NodeMCU
  • Sensor driver build into the firmware
  • DHT22 Temperature and Humidity Sensor, sensor specific single wire protocol
  • BME280 Barometric Pressure Sensor, I2C
  • CP2102 USB to UART Adapter

Http-Requests based Data Push to Influxdb

file lua code Notes
config.lua
wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","PASSWORD")
wifi.sta.connect()
setup file, connects the esp to the router
init.lua

(part 1)

print("\n\nHold gpio0 low to stop boot")
tmr.delay(1000000)
if gpio.read(3) == 0 then print("...boot stopped") return end
print("...booting", collectgarbage('count'))
print('ready',collectgarbage('count'))

dofile('config.lc')
Startup code that allows stopping the boot by holding GPIO0 low.
init.lua

(part 2)

-- restart if stall
tmr.softwd(30)

--bmp085.init( dofile("i2c_locate.lc") )
bmp085.init( 6, 5 )
print( bmp085.pressure(), bmp085.temperature()/10, dht.read(7) )

trigger = nil
conn = nil
pub = function(c)
   local d="pa val="..bmp085.pressure()
   local s,t,h=dht.read(7)
   if s==0 then d=d.."\ntemp val="..t.."\nhumi val="..h end
   local m="POST /write?db=rocket HTTP/1.1\r\nContent-Length: "..d:len().."\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n"..d
   print(m)
   c:send(m)
end
trigger = function(c)
  conn = net.createConnection(net.TCP, 0)
  conn:on("connection", pub)
  conn:on("receive", function(conn,m) conn:close() conn=nil print(m) tmr.alarm(0, 3000, 0, trigger) tmr.softwd(30) end)
  conn:connect(8086,"playfulexploration.com")
end
trigger()
Net client connects to influxdb every 3 seconds and send data

The fully charged power stick last about 26 hours.

Weather Events

Event Graph
Hail Storm 20160331 weather event hail storm.jpg
Rain Storm 20160604 weather event rain storm.PNG