Wednesday, April 3, 2019

Sensor-Ways Building Different IoT Devices

In this post we will build different variation of IoT devices that can work and communicate with the open source IoT backend application "Sensor-Ways".

The previous post summarize everything about building, compiling, configuring and monitoring the IoT device, so in this post we will focus on the hardware part and code.

All these devices can be either: Sensor-based only, Control-Only devices or Mixed Sensor and Control devices, so we will simplify all the devices to be sensor only and we will show an example of how to have a control device.

To connect a control device connect the relay the switch something on/off, you can connect up-to 2 relay modules as per the current design, but you can change it to accommodate more. Same for sensors, currently the supported is max 2 sensors connected, but this also can be change.
Therefore the following hardware components are for all devices and we will only list the required sensor beside each device:

Hardware Components:
- Arduino Wemos d1 or d1 mini or similar ESP8266 which contains the embedded WiFi chip.
- Buzzer (for local alarm)
- 5V Relay modules (1-2 optional in case we need to control other electric devices upon any action from the sensor reading or from the Sensor-Ways backend)
- Connection wires.
- Adapter 9V would be good to power the Wemos d1 board, optionally you can power it using USB connection or 9V Battery.

The following are optional connected components:
Connectivity:
1. Optional Buzzer (if local alarm is required): GND and D7
2. Optional Relay 1 (if control device is required): GND & D5 
3. Optional Relay 2 (if a second control device is required): GND & D8 or D7 

1) Safety Devices

These devices are mainly about home and workplace safety, for example you can monitor the temperature in different location so you can have early detection of fire and better quality of locating the exact fire location.
Same for gas leakage either for home or for industrial uses.

- Gas-Temperature Monitoring Device

We already discussed this device in the previous post in details:
https://osama-oransa.blogspot.com/2019/03/sensor-ways-open-source-iot-devices.html
Sensors:
1. MQ-2 or any to 5v, GND and A0  
2. DHT sensor to 5v, GND and D6  
Device Code:
You will need the 2 files in the same folder:

- Gas Monitoring Device

Sensor:
- Gas sensor like MQ-2 or any MQ sensor, Connected to 5v, GND and A0.
Device Code:
You will need the 2 files in the same folder:


- Temperature Monitoring Device

Sensor:
- DHT sensor to 5v, GND and D6
Device Code:
You will need the 2 files in the same folder:




2) Security Devices

These devices mostly fall into securing some locations such as restricted access doors, or home security.

- Door/Window Open Monitoring Device

This can monitor a window or a door to know if it is open or closed and send alert upon change of the status.
Sensor:
- Door magnetic sensor (see picture), Connected to 5v, and D6.
Device Code:
You will need the 2 files in the same folder:

- Laser Monitoring Device

To be posted soon.

- Drawer Control Device

To be posted soon.

- Camera Monitoring Device

To be posted soon.

- Motion Sensor Device

To be posted soon.

3) Environmental Devices

These devices is more about monitoring the environment and weather conditions, or reduce the consumption of water or energy.
The more you reduce the consumption of resources, the more efficient you help preserving the environment.

- Soil Moisture Device

By Monitoring the soil moisture degree, you can switch on/off water irrigation and reduce the water consumption according to the actual needs which can varies as per the weather conditions.
Sensor:
- Soil Moisture sensor (see picture), Connected to 5v, GND and A0.
Device Code:
You will need the 2 files in the same folder:




- Rain Monitoring Device

The use case to alert or automate something about rain starting, like retail shops that have some products outdoors or in the ports where products need to be covered in that situation.
Sensor:
- Rain drops sensor (see picture), Connected to 5v, GND and A0.
Device Code:
Same code like the Soil Moisture device but here we will care more about detecting any wet condition.


- Pollution Monitoring Device (Air Quality Sensor)

To be posted soon.

- Garbage/Trash Filling Monitoring Device

By Monitoring the trash filling level using ultrasonic sensor, we can detect if the trash need urgent emptying or not.
Sensor:
- Ultrasonic sensor (see picture), Connected to D6, D7, GND and V5
Device Code:
You will need the 2 files in the same folder:
IoTDevice-TrashSensorDeviceOTA.ino and IoTDevice-Common.ino

4) Control Devices

- One/Two Control Device

Sensor:
- No Sensors, Only connect 1 or 2 relay modules as: Relay 1: GND & D5, Optionally Relay 2: GND & D8 or D7
Device Code:
You will need the 2 files in the same folder:

5) Medical Devices

- Pulse & ECG Device

The idea behind this device is to capture either the ECG and send to the IoT backend or simply (more convenient) to detect heart rate, disconnected leads and flat rate, and set the alert to bradycardia or tachycardia or flat rate.
 Sensor:
- AD8232 heart monitoring connected to 3.3V, GND, A0, D6 and D7
Leads must be placed over the left arm, right arm and right leg to record the 3 lead electricity.
D6 & D7 detect disconnected leads if both are high (1)
A0 contains the signal/electricity recorded which you can either capture over time and send to the backend server or do some processing using a threshold detection for heart beats and send the heart rate to the backend server.
Device Code:
The code is simple as reading from A0 the electricity and either send a series of a specific duration e.g. 3 seconds or do some advanced analysis to detect HR and send only HR to the IoT backend.
Should be carefully used and never use such devices as a medical device as medical devices must be very reliable and a lot of efforts should be done for noise filtration as well.

6) Others Devices

The use case here is to detect morning and automate some work, or detect night to switch off something, etc.

- Light Sensor Device

To be posted soon.

- Parking Sensor Device

By Monitoring the parking slot using ultrasonic sensor, we can detect if the slot is empty or filled with something i.e. car.
Sensor:
- Ultrasonic sensor (see picture), Connected to D6, D7, GND and V5
Device Code:
You will need the 2 files in the same folder:
IoTDevice-ParkingSensorDeviceOTA.ino and IoTDevice-Common.ino


- Smart Phone as an IoT Device

To be posted soon.


To Build Any Other devices, You need to pick the device with the same run-time requirement, and just change the sensor and may be other connections and build it in no time!