Chapter Three
Chapter Three
3.1 Introduction
This chapter explains the design and the implementation of the proposed Model.
This chapter contains the block diagram of Autism Kids Keeper Device using an
Internet of Things (IoT) system and the details of the hardware and software.
The NEO-6M GPS module is shown in Figure (3.4). This module is a high-
performance GPS receiver designed for Arduino projects. It features high
sensitivity, fast time-to-first-fix, and support for multiple satellite navigation
systems. With a built-in ceramic antenna and EEPROM for configuration
storage, this module provides accurate positioning and timing data. Its UART
interface makes it easy to connect to Arduino boards for applications such as
tracking, mapping, and location-based services. Popular among hobbyists and
professionals alike, the NEO-6M GPS module is a reliable and versatile choice
for adding GPS functionality to a wide range of projects.
Figure (3.4) NEO-6M GPS Module
The Type-C USB 5V 2A Step-Up Boost Converter with USB Charger is shown
in Figure (3.6). This module is a compact and versatile module that converts
lower voltage inputs to higher voltage outputs for charging devices, featuring a
Type-C USB connector for efficient charging of Type-C devices. It boosts 5V
inputs to a 5V 2A output, ideal for charging smartphones, tablets, and other
USB-powered devices. Additionally, it functions as a portable charger for on-
the-go power needs, making it a practical solution for powering and charging
Type-C devices.
Figure (3.6) Type-C USB
These lines include necessary libraries for the code, such as ThingerESP8266 for
connecting to the Thinger.io platform, TinyGPS++ for parsing GPS data, Software
Serial for working with software serial communication, Wire for I2C
communication, and Adafruit_SHT31 for interacting with the SHT31 temperature
and humidity sensor.
These lines define variables used in the code, such as flags for the heater status,
loop count, and variables for storing temperature, humidity, and time intervals for
sensor readings.
These lines set up the software serial communication pins for the GPS module,
create a Software Serial object named ss, initialize the TinyGPSPlus object for
parsing GPS data, and specify the baud rate for the GPS module.
This line initializes the ThingerESP8266 object for connecting to the Thinger.io
platform with the provided credentials (USERNAME, DEVICE_ID,
DEVICE_CREDENTIAL).
These lines define variables to store GPS data such as latitude, longitude, and a
flag for GPS validity.
The setup function begins by initializing serial communication at a baud rate of
9600 and the GPS module at a specific baud rate (GPSBaud).
The code then adds WiFi credentials for connecting to a network and initializes
the SHT31 temperature and humidity sensor at a specific address (0x44). If the
sensor initialization fails, it prints an error message stating that the SHT31 sensor
could not be found and enters an infinite loop.
Next, the code uses the ThingSpeak library to define properties for the IoT
device. It creates properties for millis (current time in milliseconds), location
(latitude and longitude coordinates), and SHT31 sensor data (temperature and
humidity).
In the loop function, the code continuously checks for incoming GPS data. If data
is available, it is read and processed using the GPS library's encode function. If
valid GPS data is obtained, the displayInfo function is called to display the latitude
and longitude coordinates.
If more than 5 seconds have passed and the GPS data has not been processed
(indicated by gps.charsProcessed() < 10), the code prints a warning message
indicating that no GPS data has been detected and enters an infinite loop.
The code then calls the get_temp function to read temperature and humidity
data from the SHT31 sensor and handles any properties defined earlier using the
thing.handle() method.
If the GPS data is valid, the code streams the location property using the
thing.stream("location") method. If the GPS data is invalid, it sets the latitude and
longitude values to 0.0.
The SHT31 sensor data is also streamed using the thing.stream("SHT31") method
in the loop function.
The displayInfo function is called when valid GPS data is available. It checks if the
GPS location is valid using the gps.location.isValid() method. If the location is
valid, it updates the latitude and longitude variables with the current GPS
coordinates. It also sets the gpsValid flag to true and prints the latitude and
longitude values with 6 decimal places to the serial monitor. If the GPS data is
invalid, it sets the gpsValid flag to false and prints "INVALID" to the serial monitor.