Kenya is a developing country with a population of 47,213,282 people this comprises of 56% low-income earners. Small businesses and crop production represent 23% of the income within the country, which is at risk as soils become less productive. Various factors have led to this, climate change and land overuse being leading causes. Without adaptation, the rural to urban migration will continue to increase.
Through Internet of Things (IoT) and specifically wireless sensor networks, we can change how we obtain and consume information. Small-scale farmers can collect data and in exchange receive useful information about their soils, temperature, humidity, and moisture content hence make better choices during crop production. Connected end devices bring in data, which is currently sparse in relation to small-scale farming. IoT will enable analysis and informed decision-making including crop selection, support equipment, fertilizers, irrigation, and harvesting. The cloud-based analysis will provide information useful for policy making and improvement.
This paper presents a wireless sensor network (WSN) in mesh topography using XBee communication module, communication, and raspberry pi, combined with a cloud-based data storage and analysis. We successfully set up a proof of concept to test a sensor node that sends information to a RPi and onto an online visualization platform.
- IoT (Internet of Things)
- WSN (wireless sensor networks)
- Cloud computing
- Climate change adaptation
This chapter was previously published non-open access with exclusive rights reserved by the Publisher. It has been changed retrospectively to open access under a CC BY 4.0 license and the copyright holder is “The Author(s)”. For further details, please see the license information at the end of the chapter.
Introduction: Background on Kitui County, Kenya
Kitui County is one of Kenya’s 47 counties located in the lower eastern region of the country. The county has eight subcounties, namely, Kitui Central, Kitui South, Kitui East, Kitui Rural, Kitui West, Mwingi North, Mwingi West, and Mwingi Central. There are three livelihood zones in the county, marginal mixed farming, mixed farming livelihood zone, and formal employment, contributing 44%, 52%, and 4% of the population, respectively. The county has a population of 1,136,187 (Kenya National Bureau of Statistics (KNBS) 2019) people and covers an area of 30,570 square kilometers, of which 6,370 square kilometers is covered by Tsavo National Park (Magee et al. 2017). A large part of this County constitutes arid and semiarid land, and therefore over 50% of the population practice mixed farming and hence cultivate small pieces of land, and therefore the farming is heavily dependent on rainfall.
Climate Change and its Impact in the Region
Africa is considered to be one continent with the highest growth in population at 3% annually (IMF 2019). It is projected that by the year 2050, it will constitute about 25% of the world population (World Bank 2019). In addition, the mortality rate has reduced thereby straining available resources. Sustaining this growth has led to increase in social problems like rural to urban migration and lower yield in the food basket among others. As a result the majority of the active working force has moved to cities and towns to look for alternative sources of income.
The smallholder farmers have not been influenced by the “Green Revolution” as they have continued with the practice of nonuse of chemical fertilizers, pesticides, and genetically modified organisms. These inherent practices are referred to as “traditional farming.” (Onwonga and Freyer 2006). In more recent years, farmers have become more reliant on extension officers. With the devolution of government services, extension officers have become few in some areas and highly concentrated in others (Franzel et al. 2014). These officers are expected to visit farmers to provide advisory services. It is usually tedious and time-consuming for both the farmer and the officer. There is thus need to investigate and keep record of weather conditions for better decision-making for small-scale famers who are the backbone of the economy in Kitui County (Magee et al. 2017). In addition assessment of cumulative health risk is a challenge in real-world situations because of limited data available for place and population-related pollution exposure (Solomon et al. 2016). With continued primary data collection, it is possible to create models that are more accurate in relation to this region.
The current weather stations within the country are a lot more concentrated in one half of the country and not so much on the other half. See map below (Fig. 1).
This study proposes to use a raspberry pi (RPi), a microcomputer quite popular now with IoT devices; it is of low-cost and easily adaptable to various conditions. The XBee is able to transmit information within short-range communication with very good accuracy and also low-power utilization and low-costs. The other parts of the paper will discuss methodology for the data collection, data transmission, storage, and visualization.
Studies have been done in agriculture and in pollution; however there is dearth in a studies combining pollution monitoring and agricultural parameters data collection. A review of previous studies has shown a gap in combination of these parameters which are of use to small-scale farming (Rehman et al. 2011) developed a WSAN with sensor and actuator nodes to provide controlled water supply; this is very geared toward precision agriculture. In 2016 (Raja et al. 2016) used various types of sensors to monitor temperature and moisture values of the soil. The data was shared to a central station periodically and concentrated on soil data. A similar study was undertaken in 2015 by (C and S 2015). This study builds on work done by (Rehman et al. 2011) where remote monitoring was done for data collection and information shared with research facilities (Vatsal and Bhavin 2017). Worked on a system showing real-time temperature and relative humidity and once again only concentrated in agricultural information for display locally.
There are several systems designed for precision agriculture. They, however, mostly solve the problem of irrigation or temperature control. Those in environment solve data collection challenges, while those in agriculture solve a single or at most two challenges.
The Internet of Things (IoT) is described as connecting everyday objects via sensors and actuators to the Internet where the devices are intelligently linked together enabling new forms of communication between things and people and between things themselves. This technology has advanced rapidly in the last few years and has become quite popular in environment monitoring. The basic concept is illustrated in the figure below (Fig. 2).
IoT offers new and innovative ways to monitor and manage remote operations. “It allows having eyes and ears in remote places, constantly feeding applications and data stores with information. The low-cost of ‘things’ allows observing and managing activities that were previously out of reach. With the Internet of Things, it is also possible to collect information about events that were once invisible, such as correlating weather patterns with industrial production” (“IoT in action – Towards Data Science” 2020). The advancement in wireless sensor networks is used in monitoring and controlling of various aspect in an agricultural field. In the same light, weather aspects for a station field. A wireless sensor network is composed of hardware and software. These are low-cost and low-power smart sensor nodes which monitor physical conditions. In our initial prototype test case, we monitored temperature, moisture, and pollution. These nodes can be spread across a large geographic area (Fig. 3).
A node: The main components of a sensor node are a microcontroller, transceiver, external memory, power source, and one or more sensors. The controller performs tasks, processes data, and controls the functionality of other components in the sensor node. The sensor node or mote can be deployed infield to form wireless sensor network for crop management and environment monitoring system (Fig. 4).
This study uses ZigBee, an IEEE 802.15.4 for the wireless sensor network of nodes. It is common in networking standard for personal area networks. The physical layer of ZigBee operates in the unlicensed industrial, scientific, and medical radio bands of 868 MHz, 915 MHz, and 2.4 GHz depending on the region. In this study, we adopt 2.4 GHz band because it is unlicensed in Kenya. The ZigBee protocol mainly focuses on low-cost and low-power consumption. The low-power consumption characteristic is necessary since sensors are usually placed at a remote location where battery power supply is virtually the only option. In order to attain a low-power consumption characteristic, the ZigBee protocol operates at low data rates (250 kbps at 2.4 GHz); this imposes its limitation where high data transmission applications are required. From node to the servers, it is thus more realistic to use other applications, for instance, Wi-Fi (802.11) which offer high data rates. This is only done from the coordinator node. Depending on the situation and environment, the networks can take three forms of topologies: star, cluster tree, and mesh. Our study uses the mesh topology. A mesh network is accomplished by allowing devices in the cluster tree to topology communicate with each other using multiple routes. Consequently, the devices are able to send and receive messages reliably even when their preferred path is down or congested. This is the major advantage of a mesh network over star and cluster-tree networks. However, a mesh network has no guarantee of bandwidth since no synchronization is used which requires disabling of beacon mode (Fig. 5).
Mesh topology, also referred to as a peer-to-peer network, consists of one coordinator, several routers, and end devices. The following are the characteristics of a mesh topology: A mesh topology is a multi-hop network; packets pass through multiple hops to reach their destination. The range of a network can be increased by adding more devices to the network. It can eliminate dead zones. A mesh topology is self-healing, meaning during transmission, if a path fails, the node will find an alternate path to the destination. Devices can be close to each other so that they use less power. Adding or removing a device is easy. Any source device can communicate with any destination device in the network. Compared with star topology, mesh topology requires greater overhead. Mesh routing uses a more complex routing protocol than a star topology” (“2.3 ZigBee Topologies | Introduction to the ZigBee Wireless Sensor and Control Network | InformIT” n.d.).
This study proposes the combination of solving challenges in environment and in agriculture with a single system at the same time contributing to data enhancement for policy issues in both precision agriculture and pollution primary data.
The building of pollution stations within the country present a problem of security and management. Having these stations placed at small farms and distributed keeps them safe. On the other hand, implementation of monitoring stations for local farmers is expensive and the communities lack the knowhow of management of the information collected. The cloud-based data management platform will provide this, while interested stakeholders (policy makers) will support the management of data. Kitui County is vast and most small farms lack connectivity to the main power grid. For the system to be self-sustaining in terms of power, the study uses solar photovoltaic and rechargeable batteries to power all electrical devices. The system incorporates a remote monitoring mechanism through a General Packet Radio Service modem to report soil temperature, soil moisture, WSN link performance, and photovoltaic power levels.
Having a system that encompasses data collection and data dissemination provides end to end solution for both small-scale farmers and policy makers.
The general workflow of the monitoring system consists of the following:
Taking temperature, humidity, and pollution data (PM 2.5 and PM 10) samples at predefined time intervals (Sensors)
Reading this data at a local level (Arduino Uno)
Sending data via a coordinator node (Raspberry Pi)
Visualizing data online
Going to sleep
Waking up and repeating the previous steps (Fig. 6)
Hardware needed for the end point of the system:
For the sensor node:
Raspberry pi 3B – this is a low-cost, credit-card sized computer that plugs into a computer monitor or TV and uses a standard keyboard and mouse. It is a capable little device that enables people of all ages to explore computing and to learn how to program in languages like Scratch and Python (Raspberrypi.org n.d.)
Arduino UNO – Arduino is an open-source electronics platform based on easy-to-use hardware and software (Arduino.cc n.d.)
Humidity and temperature sensor – DHT22 Sensor
Pollution sensor SDS011
Connectors – female-female, male-female, and male-male
Software used in this project:
XTCU – This was used in this system to setup the XBee radios so that they can transmit data between each other.
NOOBS – This is the operating system needed to setup a RPi.
ThingSpeak is a free online platform that was used for data visualization
System Implementation and Experiments
To set up and test this system, the XBee devices were first activated and set up using XCTU (a tool available online for free). They were all coded under the same network for ease of communication. The RPi was loaded with the necessary operating system (NOOBS) which comes with python – a coding language. In the project we also set up the Internet access for the raspberry pi as it acts as the gateway in this system.
On a laptop, we installed Arduino IDE (which is a development platform for Arduino boards) and also the sketches to run the two sensors for our prototype. JSON here is used as the shell to transfer data in a compact mode from the Arduino to the RPi.
On the RPi we run a program to call the data from the Arduino to the RPi and tested the same locally. Finally on ThingSpeak, we added the required APIs and run the visual data from our system.
The diagrams below further define our various steps (Figs. 7 and 8):
Once the codes were tested and found to be producing steady outputs, we put the sensors in a monitored environment – domestic fridge with proper calibration to test the humidity and temperature parameters and the results were displayed on the local Arduino software as 169% humidity and 12° Celsius continuously and repeatedly (Fig. 9).
We then transferred the tests to the natural environment and connected the router XBee connected to the raspberry pi. We were able to read the results from the temperature and humidity sensor as well.
We also run similar tests on the SDS011 – pollution sensor and obtained a consistent flow of results as below.
Once this was done, we then connected the end nodes to the router node for data aggregation. This was done using the python on the raspberry pi and wrapping the file using Json. We could then see our data collected using the IDs EN1, EN2, and EN3 from the three Arduino/XBee connected end nodes (Figs. 10, 11, 12, and 13).
The phase of the entire project included:
Coming up with a design to collect data from sensors via a sensor node.
Sending the data to an online visualization platform via a control node and this step has been successful.
Continuing work in this project involves adding a local database for localized data storage and adding a GSM module that allows ease of access of the online data remotely. The online platform and visualization will also be improved to be more robust with a private platform that can be more scalable in the future.
2.3 ZigBee Topologies | Introduction to the ZigBee Wireless Sensor and Control Network | InformIT (n.d.) Retrieved January 15, 2020, from http://www.informit.com/articles/article.aspx?p=1409785&seqNum=4
Arduino.cc (n.d.) Arduino – Introduction. Retrieved May 7, 2020, from https://www.arduino.cc/en/guide/introduction
C, A, & S, A (2015) A study on developing a smart environment in agricultural irrigation technique. Int J Ambient Syst Appl 3(2/3):11–17. https://doi.org/10.5121/ijasa.2015.3302
Franzel S, Sinja J, Simpson B (2014) Farmer-to-farmer extension in Kenya: the perspectives of organizations using the approach. ICRAF. https://doi.org/10.5716/WP14380.PDF
IMF (2019) World economic outlook (October 2019). Retrieved January 21, 2020, from https://www.imf.org/external/datamapper/datasets/WEO
IoT in action – Towards Data Science (2020) Retrieved January 15, 2020, from https://towardsdatascience.com/iot-in-action-a8b7fac83619
Kenya National Bureau of Statistics (KNBS) (2019) 2019 Kenya population and housing census volume I: population by county and sub-county (Vol. I). Retrieved from http://www.knbs.or.ke
Magee RV, Beerbower E, Bodhi B, Schindler S, Pfattheicher S, Reinhard M-A, … Gorski PC (2017) KITUI county 2016 short rains food security assessment report. ABA J 102(4):24–25. https://doi.org/10.1002/ejsp.2570
Onwonga R, Freyer B (2006) Impact of traditional farming practices on nutrient balances in smallholder farming systems of Nakuru District, Kenya. In Proceedings of the tropentag conference October, (Octuber 2014), 11–13. Retrieved from https://www.researchgate.net/publication/228372444_Impact_of_Traditional_Farming_Practices_on_Nutrient_Balances_in_Smallholder_Farming_Systems_of_Nakuru_District_Kenya/link/00b495156e425eb5ba000000/download on January 19, 2020
Raja R, Aruna P, Rajeshwaran N, Vignesh M, Vijayakumar M, Rajeshwaran N, … Coimbatore T (2016) Automatic irrigation control using wireless sensor network 1299–1302
Raspberrypi.org (n.d.) What is a raspberry pi? Retrieved May 7, 2020, from https://www.raspberrypi.org/help/what-is-a-raspberry-pi/
Rehman A, Ali G, Shaikh NA, Shaikh ZA (2011) Efficient irrigation water management using cost effective wireless sensor and actuator networks. Sarhad J Agric 27(3):423–435
Solomon G, Morello-Frosch R, Zeise L, Faust JB (2016) Cumulative environmental impacts: science and policy to protect communities. Annu Rev Public Health. https://doi.org/10.1146/annurev-publhealth-032315-021807
Vatsal S, Bhavin M (2017) Using raspberry pi to sense temprature and relative humidity. Int Res J Eng Technol (IRJET) 4(2):380–385. Retrieved from https://irjet.net/archives/V4/i2/IRJET-V4I276.pdf
World Bank (2019) World’s population will continue to grow and will reach nearly 10 billion by 2050. Retrieved January 21, 2020, from http://blogs.worldbank.org/opendata/worlds-population-will-continue-grow-and-will-reach-nearly-10-billion-2050
Editors and Affiliations
Rights and permissions
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.
The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.
© 2020 Springer Nature Switzerland AG
About this entry
Cite this entry
Mbandi, J., Kisangari, M. (2020). Data Collection Using Wireless Sensor Networks and Online Visualization for Kitui Kenya. In: Leal Filho, W., Oguge, N., Ayal, D., Adelake, L., da Silva, I. (eds) African Handbook of Climate Change Adaptation. Springer, Cham. https://doi.org/10.1007/978-3-030-42091-8_151-1
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-42091-8
Online ISBN: 978-3-030-42091-8
eBook Packages: Springer Reference Earth & Environm. ScienceReference Module Physical and Materials Science