Code for an D1 Mini pro to measure water height via a JSN-SR04T and send the result to IFTTT that will send it to a Google spreadsheet.
There are only a few tide sensors in Fort Lauderdale's new river; after Andrews Avenue bridge, there are none. With 300 miles of canals, many owners don't know the water level in their canal at a given time. This can be an issue if there is a fixed bridge and high water levels mean that you cannot get out or get back home. A low water level could mean that you run your board aground.
That's why I decided to build a custom made arduino-based tide sensor. By placing it on my dock, I can have live data on the water height and decide if it's a good time to take the boat out.
The code is well document but in a nutshell. The board connects to the wifi and uses the JSN-SR04T to take 5 measurements. If the measurements match (within 1cm close), it is sent to IFTTT, if they do not, another 5 measurements are taken until they do match. This loop happens every 5 minutes.
Make sure to use D1 and D2. I tried using other ports to connect to the JSN-SR04T and it would not work.
For the instruction ESP.deepSleep(300e6);
to work – which puts the board in deep sleep for 5 minutes - you must connect D0 with the Reset pin.
Note: the ESP board on the schema isn't an exact reproduction pin-wise
We get some rough weather here in Florida and the air is often pretty humid, that's why I decided to go with an IP65 box that would be weatherproof.
Because JSN-SR04T angle is super wide (75°) I had to move the sensor away from my dock using a PVC pipe. I used PVC because it is cheap and light, easy to cut, and the box can handle it's weight
- Arduino IDE
- Additional board manager URL: http://arduino.esp8266.com/stable/package_esp8266com_index.json
- The following libraries
- ArduinoJson by Benoit Blanchon
- ESP8266HTTPClient by Arduino
- ESP8266WiFi by Arduino
- HCSR04 by Martin Sonic
- IFTTT account
- Google account
What's needed for this project: