CodeforSouth / iot-flood-tracker

⚡️ 😴 Learn how to build a sensor that could be used for tracking flooding
https://medium.com/code-for-miami/building-iot-flood-trackers-for-miami-with-miami-7186a8c7200e
BSD 3-Clause "New" or "Revised" License
5 stars 1 forks source link

Flood Tracker | How To Build a Electron Distance Sensor

Miami floods "badly" as of recently due to many factors. We at Code for Miami see this as a problem that needs to be addressed. For that reason, we are showing others DIY ways to build their own sensors to track flooding.

In this experiment, you are going to build a sensor that is able to measure distances from 10cm up to 200cm. The data will be transmitted via cell to The Particle cloud service.

Required Parts

To build this sensor, you need the following hardware:

Useful Parts

Prepare your laptop

https://docs.particle.io/guide/tools-and-features/cli/photon/

Wire up the circuit on breadboard

TODO: FIGURE OUT IF THE VOLTAGE DIVIDER IS NECESSARY

Place components as shown in the schema.

The HC-SR04 sensor is a 5V device, while the Electron operates at 3.3V. Therefore, we provide power to the sensor from the Vin pin (= 5V from USB).

The 2 resistors function as a voltage divider to convert the 5V coming from the sensor to a safe 3.3V level.

R1: 470 Ohm (yellow purple black black [brown]) R2: 1k Ohm (brown black black brown [brown])

alt text

Connect Particle to the cloud

Identify device

Connect the device to your computer using USB and place the device in [listening mode](blinking dark blue) by holding down the S MODE button until the main status LED blinks dark blue, about 3 seconds

First, you want to know the Device ID of the Photon you just connected:

$ particle identify

Your device id is 2300211353337353037
Your IMEI is 35316207243
Your ICCID is 8936500002860393
Your system firmware version is 0.7.0

If firmware version not 0.7.0 or higher, see Mario or Christina.

Copy this device id to your TextPad. You will need it in a few moments.

The Photon status LED should be BREATHING CYAN when it's happily connected to the internet.

Add the device to your account (See Mario or Cristina to be added to the Code for Miami account)

Write sketch for the Photon

Open the online build environment of Particle.io on build.particle.io.

At the left-hand side, you can see the vertical menu on the left hand side which you will use during the process. Hover your mouse over each item to get familiar with the different options:

FLASH - VERIFY - SAVE - CODE - LIBRARIES - DOCS - DEVICES - SETTINGS

Let's get started!

Paste the code from GitHub url, https://github.com/Code-for-Miami/iot-flood-tracker/blob/master/GiveMeData.ino replacing it's current content

Flash successful! Please wait a moment while your device is updated...

Monitor the published sensor values

Debug readings from local serial port (Photon need to be connected to USB)

$ particle serial monitor
Opening serial monitor for com port: "/dev/tty.usbmodem1411"
Serial monitor opened successfully:
Report: 13.55 cm
Report: 55.19 cm
Report: 55.17 cm
Report: 59.33 cm
Report: -1.00 cm
Report: 55.88 cm
Report: 57.36 cm
Report: 30.78 cm
Report: 110.74 cm
Report: -1.00 cm
Report: 229.14 cm
Report: 231.03 cm

Go Hack add features and build the hardware