Esp8266 and other web enabled chips and their boards have been around for a while .
It was time I used the ones I’d bought. Having scored a few days off work, I dusted off the parts box and started bread boarding. but what to make! There are so many things you can make with a low power web enabled device but i thought it was best to revive an old project.
A long time ago I tired measuring the depth of water using the BMP085 which has been discontinued and superseded by several chips the newest being the BMPE280 which also measures humidity.
That project had a huge flaw, when the atmospheric pressure changed during a measurement the depth measurement would be incorrect by as much as half a meter :-/
Now that I’m living on tank water, accurate water depth is important in my life. Also useful for aquariums etc. I must note there are plenty of other ways to measure water depth/height including sonar on water surface, light reflections, float switches, conductive squish tube (cant remember the name). However they all suffer from environmental influences or accuracy problems.
This setup uses 2 bmp180’s on an i2c bus and toggling a reset register on each sensor to select between them for readings. This way the pressure in the tank and of the atmosphere can be measured to increase accuracy.
They are hooked up to a Weemos D1 mini clone programmed via an Arduino IDE. I’ll link to Gitub when the code isn’t in such a terrible state.
Here is a snippet of code:
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include "HTTPSRedirect.h"
#include <Wire.h>
#include <Adafruit_BMP085.h>
HTTPSRedirect allows for direct posting to a google sheet for data storage via a google script. Without this you are doomed to submit to the cost and limitations of one of the online services like Thingspeak, Adafruit.io, data.sparkfun, thinger.io…
If I was actually to deploy this on my tanks it is important to have a few things worked out. Especially handing Wifi outage and the Power system.
For the WiFi the ESP8266WiFiMulti library was used. This allows you to code in several access points. Very useful for me since I have 5 routers handling the internet on my property. But you can include your phone hotspot so you can get data in case the home router goes out or starts disliking your iot thing for any reason.
For the power hacking together a reclaimed lipo some cheap solar light solar cells and a charge board made for a nice long term low power system. However this setup only supplies 20mA (0.02A) in full sun which we can assume will only happen for 4-5 hours a day. So this means…
We need to sleep. Putting the esp8266 to sleep reduces its power consumption considerably. From about 70-150mA (0.07A idle - 0.15A during wifi comms) to 20uA (0.00002A).
However in my setup with a voltage divider measuring the battery and the two pressure sensors I had a 630uA (0.00063A) draw during deep sleep. So on a 3000mA battery you could power sleep for over 200 days or run with WiFi on for almost one day. However if the ESP8266 is only awake for 10 seconds every 10 minutes and asleep the rest other the time, it should only need a battery (0.416mah awake 0.695mAh asleep) totaling 1.035mAh for an hour or 24.852 mAh for a day. Now on a 3000mA battery the setup would last 120 days.
Lets include our measly solar charging. 20mAh for 4.5 hours a day could charge a flat 90mAh battery each day and we only need 24.852mAh. This means we have surplus power to account for miss-aligned solar cells, my bad math, cloudy days and for times the ESP8266 is awake for longer than it should be. Worse case scenario the sensor setup will need to be charged 3 times a year. I’d call this deployable.
Now I just need to make the housing so I can attach it to my tank and the get the graphing of the data working properly.