This chapter introduces an educational weather station provided by Kajaani University of Applied Sciences. The weather station is produced for learning IoT concept as in sensor-to-cloud manner prividing actual weather data from a specific location.
Before going into details, we need to understand some basics about sensors, edge computing (Chapter 3), locational (geospatial) data and data transfer and presentation with JSON.
Remote sensing is a way of collecting information about a location with sensors. Typically, weather conditions are measured and collected throughout the world from different locations to analyse, for example, the temperature, humidity, wind direction, air pressure, rainfall and amount of light. These measurements can then be used to analyse the local and global weather conditions and also to predict the weather for the near future (weather forecasts).
Requirements for the outdoor and indoor sensing equipment vary a bit, but as a principle, the sensors are put up together to form a weather station. In IoT context, this often needs a central unit capable of collecting data from the sensors and either store the data on the device itself, or to transmit the data to a more sophisticated device able to store the data. There are multiple commercial off-the-shelf (COTS) weather stations available on the market, but for this course, it is more important to understand the overall architecture and the details of the hardware and software layers.
Geospatial data is about having a point of interest (POI) on a specific geographical location on Earth. The point of interest contains information of that geographical location, e.g. street address, city, country, temperature, humidity, latitude, longitude, elevation and other attributes, which we are interested in. In short, geospatial data is data with a locational component. The location is often indicated with street address or more likely with the latitude (lat) and longitude (long) coordinates in the geographic coordinate system. It is also possible to add the third dimension, elevation, on the coordinate system, but it is not always needed.
Picture 2. Latitude and longitude coordinates.
Geospatial data is available in multiple file formats and data structures and it continues to evolve and grow with new data types and standards. Also, almost any kind of data may become geospatial data by adding the location information in it. Some common examples, where location data is present, are
Geospatial data can also be attached in many types of data formats and sources, like
Also to bear in mind that data can be enriched with metadata, i.e. data about data.
Geospatial data helps people to understand and make decisions about their whereabouts. Open services like OpenStreetmap allow us to easily plot markers on map with additional information. It is also possible to create thematic maps with special meaning to provide knowledge and understanding and tell a story about a specific issue or generalization of information.
In computer terms, geographic data may be constructed from points, lines, and polygons which are stored numerically as one point or a set of points, which come in (x,y) pairs or (x,y,z) tuples. The x represents the horizontal axis (e.g. latitude) on a graph or a map, while the y represents the vertical axis (e.g. longitude). The z represents terrain elevation.
Below you'll find a possibility to search a location setting latitude and longitude values and see the corresponding location on a map.
JSON (JavaScript Object Notation), or ECMA-404, is easy to understand data-interchange format. The data is ordered inside curly brackets { data }
as key-value pairs:
import simple_json
json = {
'key1': value1,
'key2': value2,
'key3': value3,
}
Basic data types (from Wikipedia):
Empty characters (whitespace, i.e. space, horizontal tab, line feed, and carriage return) are allowed and ignored around or between syntactic elements (values and punctuation, but not within a string value). JSON does not provide syntax for comments.
JSON provides a syntactic framework for data interchange and provides a semantic producer-consumer model with clear syntax
{
"school": "Kajaani University of Applied Sciences",
"address": {
"streetAddress": "Ketunpolku 1",
"city": "Kajaani",
"postalCode": "87100"
},
"website": "https://www.kamk.fi/en"
}
It is possible to add data structures, e.g. other objects { }
or arrays [ ]
or objects inside arrays [{ }]
or even arrays inside objects {[ ]}
.
One may use JSON validator for checking JSON syntax, for example JSONLint.
GeoJSON (RFC7946) is a format for encoding a variety of geographic data structures. It has a very simple syntax.
# this is a simple GeoJSON structure
gc = {"type": "GeometryCollection",
"geometries": [{"type": "Point",
"coordinates": [-89.33, 30.0]},
{"type": "LineString",
"coordinates": [[-89.33, 30.30],
[-89.36, 30.28]]}]}
print(gc)
GeoJSON has support for six different geometry types:
Geometric objects can be extended with Feature
objects, giving them additional properties for defining object contents. A set of features can be defined as FeatureCollection
object.
Below you'll find a GeoJSON definition for Kajaani University of Applied Sciences.
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [27.715072631835934, 64.21635658620721]
}
}
]
}
The definition above is taken from geojson.io and at simplest, the location can be defined as
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [27.715072631835934, 64.21635658620721]
}
}
We use the Folium with some other Python libraries to produce the location marker on a map.
You can see the marker on the map by executing the Python script on following Jupyter Notebook:
As an introduction to sensing equipment and IoT, we introduce an active weather station hosted by Kajaani University of Applied Sciences. The weather station provides information about local
The architecture of the weather station is presented in the picture 3 below.
Picture 3. Weather station architecture.
The sensor elements are attached to a circuit board, which is connected to a Raspberry Pi (3B+) card computer. The circuit board consists of transistors, resistors, analog-to-digital converters, etc. needed to interface the sensors to a Rasbperry Pi. The details of the sensors and the circuit board are defined in more detail in the later chapters of this course, but at this point we will study a bit about the temperature sensor DS18B20 as an example.
Temperature sensor DS18B20
The DS18B20 digital thermometer provides 9-bit to 12-bit Celsius temperature measurements and has an alarm function with nonvolatile user-programmable upper and lower trigger points. The DS18B20 communicates over a 1-Wire bus that by definition requires only one data line (and ground) for communication with a central microprocessor. In addition, the DS18B20 can derive power directly from the data line (“parasite power”), eliminating the need for an external power supply.
Each DS18B20 has a unique 64-bit serial code, which allows multiple DS18B20s to function on the same 1-Wire bus. Thus, it is simple to use one microprocessor to control many DS18B20s distributed over a large area. (ref: DS18B20 data sheet)
Reading the temperature data from a 1-Wire bus on a Raspberry Pi card computer is quite easy, but it is covered in the later chapters of this course. At this point it is only necessary to know, that from the software point of view, the temperature value provided by the sensor is available as a decimal value, e.g. 25.9783923487561.