Hardware Programming
As a hardware engineer, my key task is to learn how to write programs that can collect data from sensors, acquire GPS coordinates, and publish live data to the channel via a GPRS module using REST API so that customers can access the latest information from the river.
Components Used:
- PH Sensor (H-101 pH Electrode)
- Temperature Sensor (DS18B20)
- Microcontroller (ESP32)
- GSM/GPRS Module (SIM 800L)
- GPS Module (Neo-6M)
Platform Used: Arduino IDE
IoT Platform Used: PubNub
Components
Hardware Intro
Circuit Diagram
- Water temperature sensor, pH sensor, and GPS module are interfaced to the microcontroller.
- The microcontroller process the data from the sensors and GPS module.
- The microcontroller will then publish the data to the PubNub channel using SIM800L GPRS Module.
GPRS
We included a library called TinyGsmClient.h for our SIM800L GPRS/GSM module. The module requires a nano-SIM card to access to the 2G network. After connecting to the server, we then use HTTP client function provided by the library to send out the data to our PubNub server.
GPS
We included a library called TinyGPS++.h for our NEO-6M GPS module. The Module is connected with a GPS antenna which provides a satellite search capability. By using the library we included, we can easily get the coordinates of our device.
Sensors
The pH Sensor sends analog data to the PIN. Thus, we need to use the analogRead to get the voltage from the PIN connected to the pH sensor and calculate the pH value using a library called DFRobot_ESP_PH.h. A temperature sensor is needed because the pH value and conductivity of the solution are closely related to temperature. When the temperature changes, the pH value and conductivity will change differently.