Introduction: Smart WareHouse/Control Shed/GreenHouse Monitoring
Humidity and temperature monitoring is a very important factor in salt/dairy warehouses, greenhouses as well as in homes. Instead of taking manual readings from digital meters I plan to make a device which will automatically stream real time statistics of warehouses (temperature/humidity) to the MyDevices Cloud. By this way, we can get real time result anywhere any time and take decisions on time to save products from damage. I am also adding one more feature in this system that is Gas & Smoke Monitoring which is good with respect to safety. In case of any fire or smoke you can get the alert on your mobile via MyDevices App or SMS/Email and make arrangements on the time to safe the warehouses,Greenhouses or home.
I am dividing this projects in to 3 parts.
1st device is for out door temperature & humidity monitoring.
2nd device will be used inside the warehouse/greenhouse which will include Temperature, Humidity & Gas Level/Smoke alert.
In the last & 3rd phase we will discuss about Cayenne Platform features like Project Option, Triggers & Alert, Sharing feature
For Outdoor Device:
- 1x NodeMcu
- 1x DHT22 Temperature & Humidity Sensor
- 3x Jumpier wires
- 1x 3d Printed Box for device
- 1x Charger (For NodeMCU Power)
For Indoor Device:
- 1x SparkFun ESP8266 Thing Dev Board
- 1x DHT22 Temperature & Humidity Sensor
- 1x MQ-2 Gas Sensor Module
- 1x 10k Resistor (for MQ-2 Gas Sensor Module)
- 15x Jumpier Wires
- 1x 3d Printed Box for devices
- 1x 5V Charger for Device
Step 1: Initial Setup
Before we move to our Main Phase i think we need to do some basic work like Arduino IDE Setup for Sparkfun ESP8266 thing dev boards and Caynne My-Devices Setup.
Note:Please Watch the above images according to below list.
- Please watch the above youtube Video to setup ESP8266 Boards in Arduino IDE.
- Before we move to Cayenne My-Devices portal. Register yourself at http://cayenne.mydevices.com/ and login to portal to get start.
- Click on Add New... Menu in the left and click on Device/Widget.
Click on "Generic ESP8266".
After Clicking on ESP8266 you will get credentials for your devices like MQTT Username, MQTT Password, Client ID and save these credentials for future use.
At the left side you will see the guide to connect your board with Mydevices via Arduino IDE.
Open the Arduino IDE and click on Sketch->Include Library->Manage Libraries. you will see the library manager and type "Cayenne" in search box and select the "Cayenee-MQTT-ESP8266" and click on Install.
Before you move to the next step select the NodeMCU in Arduino IDE from Tools->Board-> NodeMCU:
Now we need an example to test our board connection with my-device cloud. click on File->Examples->Caynne-MQTT-ESP8266->ESP8266. after clicking on this example you need to change SSID,wifi password according to your wifi network. Recall the Cayenee my-Devices credentials and update in a code. upload the code to board and watch your Cayenne Dashboard.
If your board successfully connected to Cayenne My-Devices cloud then you will get random values at channel 0 which shows that you board is sending data to cloud.
Our Arduino IDE & My Devices initial setup has been completed. I think now we need to move towards our real goal.
Step 2: Out Door Device Setup
abpve is the picture of electronic components those are required for this phase.
In the above diagram I demonstrated how to connect DHT22 sensor with NodeMCU. If you are new to this please read this article to play with DHT22 sensor.
Electronic design is completed. Now we need a box to save our components from dust and harsh weather and of course from some naughty guys. Click here to download 3D printer design files.or you can also download the file at the end of this step.
Physical things are completed. Now we need to move towards Cayenne My-Devices to visualize the data and put our device online to real world to get some live data.
Already we created the device in Caynne My-Devices portal and tested the code. In this phase we will create custom widgets for temperature and humidity. So in this phase we will learn about how to create custom widgets for channels.
- Click on Add New->Device/Widget->Custom Widgets:
- Select Value Widget. If you see the list there are many widgets like Chart, Gauge button etc., we will use the Chart widget in the future for reporting.
- After selecting Value Widget you can see the next tab which contains Name, Device, Sensor type, unit, icon & channel.
- Repeat the above widget process for Humidity value widget. Cayenne setup has been completed below images is showing both widgets.
- Plug the NodeMCU ESP8266 with PC and upload the below code. Before uploading the code to board please change the credentials & Wifi Settings according to your Cayenne device settings.
- After uploading the code verify from the Cayenne dashboard either the device is sending the packets or not. Hopefully the device is sending the packets to the cloud. Unplug the device from the PC and plug into its USB charger and hang on the wall outside to get real time data.
- Screen shot demonstrate the real-time values from outdoor device.
Step 3: Indoor Devices Setup
In Indoor Device I am going to use Sparkfuk ESP8266 Thing Dev Board with DHT22 Sensor & MQ-2 Gas Sensor Module. Below is the picture of component that we need for indoor device.
Before going to use Sparkfun ESP8266 thing dev Board in the project we need to install the FTDI Driver. Please visit the link for complete guide on how to install FTDI Driver for Sparkfun.
Initially SparkFun ESP8266 Thing Dev board came without soldering. But I need male headers with this board to work easily. So break the male headers in to 2 groups each group contains 10 pins. You guys also use female header pins. After soldering it looks more beautiful.
- Follow the above fritizing diagram to assemble the components on the breadboard.
- After putting the components on the breadboard, my breadboard looks funny. Sorry I don't have U-Shaped jumper cable but if you have it, it looks beautiful.
- After completing the setup on the breadboard. Repeat the same steps in Cayenne My-Devices portal to create a new Indoor Device (save the credentials for future use) with 3 Channels/Custom Widgets. 0 for Temperature, 1 for Humidity, 2 for Gas Level (select Gauge Widget for Gas Level instead of Value).
- We also need Graphs for Temperature & Humidity to watch the past trends. Again click on Add New->Device/Widget->Custom Widget-> Line Chart:
After creating all Widgets your Device Dashboard will look like above(8th # image from gallery). I think it's looking beautiful. One nice feature of Cayenne dashboard is that you can resize and change the placement of your widgets according to your own taste. By the way my taste is not good in designing.
After completing the Cayenne Setup, please upload the below code to Sparkfun ESP8266 board but again change your credentials and Wifi settings in a code. Before uploading the code to the board please select the SparkFun ESP8266 Thing Dev board from Tools->Board->SparkFun ESP8266 Thing Dev.
Every thing is online. Now we need to pack our breadboard components into 3D Printed case which will save the components from dust. Please download the case from at the end of this page.
Note:Go to Cayenne Dashboard and view the live readings of sensor.
Step 4: Cayenne Project
In the above phases we learn about how to connect the sensors with NodeMCU ESP8266 Board & Spark fun ESP8266 Thing Dev board, creating Devices/Widgets in Cayenne and sending the data to them. But these are the basic functions of Cayenne.
In the above scenario I used two devices and watching their data by clicking on separate links in the dashboard, I think its very difficult to switch again and again. Don't worry, Cayenne provides Project option to show the different devices data at once.
Click at + button which is located at top I marked this point with white box. When you click on "+" button it will ask the Name of Project inside the tab. Enter your project name and hit enter. After that you will see the below screen which will contain different option like Overview, Scheduling, Triggers/Alerts & Sharing. We will see the all features step by step.
My first priority is to display both devices' readings in a single page. So we are at the Overview tab. Just drag the devices from the left panel to the center of the workspace and a popup box will appear with different widgets. Select the widgets that you want to show at this screen. Again repeat the same step for the other device and select the widget that you want. then re-arrange the widgets according to your mood.
Triggers & Alerts are a very important feature in any IoT Cloud platform. For example if our device goes offline then how do we know? Or any of our warehouse's temperature/humidity goes higher or lower then what? Don't worry, Cayenne provides triggers & alerts option to handle all of these options. Just click on "Triggers & Alert" tab and then click on "New Trigger" button.
Drag the device in the "IF" box and select the channels from drop down box. In my case I drag InDoor Device and selected temperature channel and changed the Min value to 10 and Max Value to 60 and in the Then tab I add my email address and checked the send email option. I will receive a notification email if my temperature goes Up/Down according to specified limits. And that is the main function of Device+Cayenne which will keep us updated with any situation anytime anywhere.
Above(6th# Image) is the email notification which I received during my testing phase. Which is stating that your temperature sensor of "Indoor Device" has reached the threshold limit.
After making a trigger for temperature we also need a trigger if the device goes offline/online in any case. Just repeat the same process and select the "Online/Offline" from the drop down list and reset of the procedure the same as I stated above.
After setting up the Project & Triggers next feature is Sharing. For example somebody wants to see your warehouse status like your customers or any other third party then what will you do? are you willing to provide your Cayenne login details? Off course not because it's totally technical department so Cayenne provides sharing feature to share your project dashboard with any person by sending a link he can view only specific sensors reading that you put in the project. By the way if you want to give different access to different users create multiple projects and add the widgets according to user levels. Okay just click on "Sharing" Tab.
After clicking on sharing tab you will see the popup which will ask from you "What would you like to share" below. Click on checkbox and click on Copy Link and you are ready to see the standalone dashboard without any login info. Paste the URL in to the new browser tab and below is the standalone view of your devices sensors data.
Step 5: Future Work
I created this project within a very short duration of time as I am working and other stuff so there are many features that I want to add to this project.
- By adding LDR we can monitor the Light Level.
- By adding Relay Control we can make triggers to handle the different situations like in case of smoke readings system will turn on the emergency siren & lights.
- By adding Air Pressure Sensor we will get environment status & make safety decisions.
- By adding LED Light in device we can know about device status like device is connected to the internet or not. Or sensors are reading proper values or not.