Setup Sensors with Arduino to Send Mobile and Email Alerts

For the visual learners, here's a 4 minute video:

Intro

Remember that fantastic Arduino project. The one that monitors your environment then shows you a flashing LED. The one that prints a detailed error on a 0.91-inch display. Maybe even buzzes an annoying sound at you. Bet you, all it did was annoy your cat.

If only you could send a notification to yourself. One that will reach you regardless where you are. Maybe even an email. 

Well, with Zentser you can do just that. Zentser helps you create mobile notifications from sensors in five easy steps.

After the setup you will also be able to view graphs, setup thresholds for Alerts, and export data to run it through AI/ML models. 

Let me show you how.

Requirements

Mobile App:

Zentser for iOS (install) or Zentser for Android (install)

Software:

Arduino IDE (download)

Hardware:

ESP8266 (buy) low-cost microcontroller with Wi-Fi

DHT22 (buy) accurate temperature & humidity sensor

Step 1: Arduino IDE

If you haven't yet, download and install Arduino IDE.

Then go to Tools > Manage libraries.

Search for 'Zentser'

Install Zentser ESP SDK

Install additional dependencies

Load Zentser libraries


Now go into File > Examples, and scroll down to “Zentser ESP SDK”, and you have the sample template code with all the included libraries.

Load the Example Code

Now leave this IDE for now. We'll come back to it in Step 4.


Step 2: Zentser Mobile App


Install the app

Get it on Google Play

Hopefully the first step is easy and intuitive. We’re at a point where a four year old can install a dozen apps on a phone that was unlocked for one minute. 


Sign up

After installing and launching the app, sign up. You can register by validating your email and creating an account. Alternatively, authenticate with your social Google or Facebook identity.

Sign Up screen
Sign Up screen


In the app, create a new device 

Before you click “Create device” button, I recommend to edit your “Device name” and “Sensor name” text fields. As a naming best practice:

  • For “Device name” enter where or what you are measuring. For example, I would enter ‘Basement’ for tracking that the temperature there is above freezing
  • For “Sensor name” enter what you are measuring. Optionally, include the units. For example, I would enter “Temp (F)”

Now click “Create device”

Add your first device
Add your first device
Give it a name
Give it a name

Get your custom code

Once you see generated code for your device, click on “Export code” to send yourself a copy. You will need to get it over to a computer to program your ESP2866 microcontroller. You can mail the code to yourself or save it in a cloud storage file. 

Copy custom code
Copy custom code
Save or Send code to yourself
Save or Send code to yourself


Step 3: Hardware

Here’s the hardware I use for my personal configuration:

  • ESP8266 - a low-cost microcontroller with Wi-Fi
  • DHT22 - an accurate temperature & humidity sensor

If you're familiar with sensors, you might be asking why I'm not using DHT11 instead. Well, in my experience, the smaller range and more significant variance make DHT11 impractical. While DHT11 is one of the cheapest sensors, you will get what you pay for in real-world applications. So let's invest a few extra dollars and buy more accurate readings.

You can use different parts. Just note that the pinout can be completely different on different ESP8266 boards and DHT22 devices. Triple check your positives and negatives before connecting the wires. If you smell a burning smell, you know you fried something. Toss the burnt part and try again.

If you know what you’re doing, add resistors, breadboards, solder your connections, etc. If you’re like me, connect the three wires.

Hardware wiring
Hardware wiring

Now connect your ESP8266 microcontroller to a micro-USB, then plug a regular USB end into your computer.

Note: Don’t use USB charge-only cables!

Make sure to use a data cable USB and save yourself hours of troubleshooting red herring errors.

Step 4: Program the Device

In the Arduino IDE, we will need one additional library with its dependencies for the DHT sensor.

Add Library for Sensor

Also, ensure that the connected board is the correct esp8266 and the Port is correctly selected.

Check your settings

Then in the template code, enter your Wi-Fi information so that the board can successfully connect to the internet.

And then, simply replace everything between the “--- START ---” and “--- END ---” comments with the code that you saved from Zentser mobile application. Then verify the sketch compiles successfully.

Modify Arduino Code for Your Device

After you see that there are no issues in compiling, upload the code to the microcontroller.

tbh, you can just hit Compile :) 

You can check on the serial monitor that the information is sent successfully from your sensor to Zentser.

Monitor your microcontroller

Step 5: Almost Done

You have just:

  • created a Zentser device
  • hardwired physical components
  • and successfully programmed your device

If you’re not an engineer, that’s quite a fit. If you are an engineer, it’s still quite an accomplishment to celebrate. Now you have an active sensor sending you data you can access on the go.


Go back into your mobile Zentser app. You should now see a numeric value presented for your device. If you drill down, you can even see timeline graphs with your temperature readings.


Next steps

Now that you have configured your sensor to report to a Zentser app, you can take it to the next level.


Automate with Notifications

In the app, you can set up high or low thresholds for your readings. That way, you will get notified in real-time of any abnormalities.

This goes beyond checking for temperature or humidity. With different sensors connected to Zentser, you can detect and alert about:

  • barometric pressure changes
  • soil moisture for plants
  • water leaks
  • excessive noise
  • light overexposure
  • flammable and toxic gases

I would love to hear how you set up your sensor notifications. If you have some cool configs, or if you run into any issues, please comment below.


Now let's automate some everyday things with Zentser!

For updates on advance measuring techniques and sensors, please sign up for our list
Thanks for signing up! We will send you informative content on how to use sensors to make your life better!
Oops! Something went wrong while submitting the form.
Latest POSTS
Copyrights © zentser.io | All rights reserved.