A hardware device based on microcontroller (Arduino or probably another, cheaper one).
- Make measurements
- Send results to the main module
- Microcontroller
- Several sensors to indicate:
- Temperature
- Humidity
- Air pressure
- CO2 concentration level
- O2 concentration level
- Luminosity
- Radio module – translator
- LED and audio indicators
- Autonomous power source
- The sensors make measurements in the infinite loop.
- The processor reads data, encodes it, and translates encoded data by radio channel.
A hardware Arduino-based device
- Collect data from several sensor boxes
- Store data in memory
- Provide access to stored data using http over Ethernet connection
- Microcontroller
- Radio module – receiver
- Flash (or other) memory module
- Ethernet module
- LED and audio indicators
- AC power supply
Thread 1: receives sensors data from radio module, decodes it, and stores into memory using cycling overwrite mode.
Thread 2: opens TCP socket and waits for connections. Creates new thread for each incoming connection.
Thread 3...N: receives http request for data from sensors, prepares answer using recently collected data from memory, and sends http response back to the socket.
Cross-platform daemon without GUI, works on server
Retrieve sensors data from single carrier and save it to DB
- Daemon is started by web service and receives all parameters through command line arguments:
- DB connection parameters
- Carrier id on DB
- Periodically daemon sends http request to its carrier, receives http response with sensors data, and inserts measurements results into DB.
DB with fast engine capable to work with compressed tables. MySQL, for instance.
- Store measurements from sensors.
- Compress old measurements.
- Perform SELECT queries as fast as possible.
- Carriers – dictionary of carriers
- Carrier id
- Carrier name
- Carrier description
- Last contact time
- Sensors – dictionary of sensor types
- Sensor id
- Sensor name
- Sensor description
- Measurements – main table with sensors data
- Carrier id
- Sensor id
- Measurement time
- Value
- Math processors – dictionary of statistics calculators and weather predictors
- Processor id
- Processor name
- Processor description
- Processor file name
- Statistics – set of tables, one per math processor, containing results of math processor calculations
- Calculation id
- Calculation time
- Calculation results, names and types of fields depend on math processor
Let’s suppose that we have 1 carrier with 10 outposts. Measurements are made each second. In case all value are changed each measurement, measurements table has 10 outposts * 6 sensors * 16 bytes per record = 960 bytes per second or 79.1 MB per day:
Period | Number of rows | Size of data |
---|---|---|
Daily | 5 184 000 | 79 MB |
Monthly | 155 520 000 | 2.3 GB |
Yearly | 1 892 160 000 | 28 GB |
However, the more realistic is that values are changed once per minute (or even less frequent), so data amount generated by a carrier may be estimated as follows:
Period | Number of rows | Size of data |
---|---|---|
Daily | 86 400 | 1.3 MB |
Monthly | 2 592 000 | 40 MB |
Yearly | 31 536 000 | 481 MB |
Having only 1 carrier, DB is small and does not need any optimization. Otherwise, if we plan to make the solution scalable, DB must compress old data that is unlikely to be often requested. We can create new table each month and compress all tables older than 2 months: in this case we always have plain data for last 30–60 days and may easily and fast enough access the compressed data from certain month.
Cross-platform C++ (or other proper language) program without GUI
- Calculate complex statistic characteristics involving strong math that requires fast calculations
- Find correlations and make predictions based on collected measurements
- Processor is called by web service and receives all parameters through command line arguments:
- DB connection parameters
- Processor id on DB
- Processor specific parameters to configure calculation parameters
- Processor connects to DB and gets all required data from there
- Processor calculates statistics or make predictions and store results into its own table on DB
- Processor’s return code notifies web service whether calculation has finished successfully or not.
Works on server, processes requests from client application and controls DB
- Upon start:
- Open connection to DB
- Start data collector script for each carrier registered on DB
- Upon accepting a client request, web service decides if it is able to process the request by itself:
- Simple request: enquire data from DB and return it to client
- Complex request: call math processor, wait till it finishes, extract its results from DB, and return them to client
Mobile/browser application
- Show status of carriers and outpost
- Register new carriers and delete old from the system
- Show current measurements from selected sensors
- Draw graph from sensor in real time
- Draw graph from sensor for past period
- Draw several curves from sensors of same type on single graph
- Find correlations between measurements
- Predict weather
- Module system – each component is as independent as possible, we also should have certain and transparent descriptions of communications protocols between modules.
- Scalability – most of system modules should be easily expandable:
- Number of outposts per carrier – limited by radio module restrictions, below the maximum frequencies limit we should be able to easily add new outposts.
- Carrier management – it should be easy to add a new carrier into the system. Since carriers communicate with server only by TCP, new carriers may be placed anywhere, for example, in my apartments. I can even place an outpost into my car, and it should be visible by either the office carrier or by my home carrier depending on where the car is now.
- Math processors – universal processor interface should allow ease adding of new processors calculating different statistics.
- Web service interface should simplify adding new clients of different kinds: mobile, browser, desktop, console apps.
- Publicity – all sources should be shared on github, and we must decide which license to use.