The Oracle of Data

Page 1

The Pythia – Priestess and Oracle of Ancient Delphi. (And the Prophètès, who interprets the oracle’s speech….) The Pythia (or Oracle of Delphi, on the left) was the priestess who held court at Pytho, the sanctuary of the Delphinians, a sanctuary dedicated to the Greek god Apollo. Pythia were highly-regarded, for it was believed that she channeled prophecies from Apollo himself, while steeped in a dreamlike trance. Originally the god was channeled only once a year, but at the height of its popularity up to three Pythiai were known to hold office. The sanctuary at Delphi was constructed in the 8th century BC, and the final prophecy given around AD 393, after the Roman Emperor Theodosius ordered the closure of all pagan sanctuaries. The man at the right is the prophètès. He was the intermediate between the Pythia and the person who had a question.

Another a product that we develop:

“Prophetes” and “Pythia” are our two applications that form the suite:

1 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


Content The Pythia – Priestess and Oracle of Ancient Delphi. ............................................................................................................ 1 Abstract: “My Amazone Biotope Aquarium” ......................................................................................................................... 3 The project setup: .................................................................................................................................................................. 4 Requirements: .................................................................................................................................................................... 4 Sensors and material: ......................................................................................................................................................... 5 Start with the Arduino sketch. ........................................................................................................................................... 5 ThingSpeak: ............................................................................................................................................................................ 7 Create a “MathLab Visualization graph”: ........................................................................................................................... 8 Create a widget: ............................................................................................................................................................... 10 E-mail Setup: .................................................................................................................................................................... 11 Prophetes: ........................................................................................................................................................................ 12 Set up Prophetes: ................................................................................................................................................................. 14 And now the ultimate phase: ........................................................................................................................................... 14 A special feature: Stress Level. ............................................................................................................................................. 15 Tolerances in the Prophetes: ........................................................................................................................................... 15 Stress Level and tolerances in the Arduino sketch: ......................................................................................................... 15 The Stress Level explanation: ........................................................................................................................................... 16 Example of a typical mail from Prophetes: ...................................................................................................................... 17 Private Dashboard: ............................................................................................................................................................... 18

2 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


Abstract: “My Amazone Biotope Aquarium” I am an aquarium enthusiast and I have two aquariums that mimics the Amazonas biotope. I keep plants and fish from a specific region: Lake “Manacapuru”.

Especially the “manacapuru red back” angelfish.

This type of biotope (like any other for that matter) has specific water properties in terms of temperature, acidity, redox potential, hardness (temporary and permanent) and nitrate levels and lots of other minerals or dissolved substances. Some of them are necessary and good for the health of the livestock, others are dangerous or plain poison for fish or plants. And I am very curious about the water quality of my aquaria, so I decided to set up an experiment to measure as many water properties as I possibly can with limited resources and (cheap) sensoring equipment. Other applications of Prophetes can be:  Swimming pool monitoring.  Waste water quality management.  Farming purposes.  Whatever you can think of in terms of process monitoring.

3 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


The project setup: Requirements:        

A ThingSpeak account for your dashboards on ThingSpeak.com. A Gmail account for Prophetes to send the messages to. The Arduino and sensor hardware. Some electronic components such as resistors, LDR’s, temperature sensors, connection wires and a breadboard. A copy of my Prophetes software to convert the Arduino data and send them to ThingSpeak and email. A computer (maybe an obsolete laptop) to connect with the Arduino and to house the Prophetes application. The Arduino software and the Arduino connection to the sensors. This computer must have an internet connection for transmitting the data to ThingSpeak and sent emails.

Project components:

ORP sensor detail

All components together

pH sensor detail

4 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


Sensors and material: Sensor type 1: Light 2: Temperature 3: pH 4: ORP 5: Virtual rH sensor Hardware Arduino Microprocessor and sensor shield Search for: Arduino UNO Sensor Shield V8 Digital Analog Module

Purpose Light intensity; day and night. Water temperature. Acidity. Oxidation or Reduction Potential of the dissolved anions and cations. Calculated Oxidation/Reduction value with regards to ORP, temperature and pH. Image

Thermometer Search for: DS18B20 Digital Temperature Sensor

pH sensor and adapter Search for: pH Sensor Phidgets 1130 pH/ORP Adapter ORP sensor and adapter Search for: ORP Sensor Phidgets 1130 pH/ORP Adapter Light sensor Search for: LDR Electronics Search for: Breadboard Solder material

All these components are easily to find and buy on the Internet. Building it all together is not that difficult. Just plug in the sensor shield on top of the Arduino and connect the two pH/ORP adapters to the sensor shield. The temperature sensor might be a bit more tricky, but when you use the breadboard (the most right one in the “electronics” row) there is not really much to it. Lots of information about how to use this components and how they are put together can be found on the Internet, especially on the Arduino website: https://www.arduino.cc/ In the end you should have something that resembles the picture at the top of the previous page. Now you are ready to continue with the interesting part: programming and testing the Arduino sensoring system. Install the hardware components and all of the software on the computer and start having fun! Put your temperature, pH and ORP sensors in a test environment or calibration setup to learn how things work out. The light sensor is not supposed to be submerged, but mounted in the vicinity of the lightning of the aquarium. Start with the sketch that I provided and load it into your Arduino and open the “Serial Monitor”. Observe the data that is coming in. This is the start of your water monitoring project!

Download the Arduino sketch at: http://www.rca-pythia.net/OurTutorials/ArduinoTutorials/TheSketch.aspx Download Prophetes at: http://www.rca-pythia.net/OurTutorials/ProphetesTutorials.aspx

5 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


Start with the Arduino sketch. This is the first level of control. Here you determine the water properties that are monitored by setting the respective channels on or of. (in the code 'true' of 'false'): bool setChannelToSQL = false; //Channel Arduino output to Gobetwino. String cmdToSQL = "#S|SQL|"; bool setChannelToCSV = false; //Channel Arduino output to CSV lets Prophetes create a comma separated file. Used for use in Excel or other applications that can import CSV files. String cmdToCSV = "#S|CSV|"; bool setChannelToREQ = false; //Channel Arduino output to Prophetes and from there to a HTTP Request. Used for display graphs in ThinSpeak String cmdToREQ = "#S|REQ|"; bool setChannelToTXT = false; //Channel Arduino output to TXT lets Prophetes create a text separated file. Used in any application that can read text files. String cmdToTXT = "#S|TEXT|"; bool setChannelToEMAIL = false; //Channel Arduino output to TXT lets Prophetes create a text separated file. Used in any application that can read text files. String cmdToMAIL = "#S|EMAIL|"; bool setChannelToThingSpeak = true; //Channel Arduino output to ThingSpeak. String cmdToTSAPI = "[TS_API]";

As you can see in my sketch, I have all set to 'false', except the last one: bool setChannelToThingSpeak = true; //Channel Arduino output to ThingSpeak. Note: in the FreeWare versions, Prophetes will send data also to a CSV file as well. You can switch this on or off by setting the setChannelToREQ =[ false] or [true]. Default is ‘false’.

This means that I let Arduino only send data to Prophetes that is destined for ThingSpeak.com The 'String cmdToTSAPI = "[TS_API]";' command is used by Prophetes to direct the data to the right address in the ThingSpeak channel. DO NOT CHANGE THIS COMMAND! It is used by Prophetes and will not be recognized when changed here. Arduino reads the data from the sensor probes and pushes them every minute to the USB port: void logDataThingSpeak(double Light, double Temperature, double PH, double ORP, double RH, double PCL) { Serial.print(cmdToTSAPI); //Initialize HTTP request command. String WaterPH, String LoopTimeWaterPH Serial.print("&field1="); Serial.print(String(Light, 2)); //#01 (Field1) Serial.print("&field2="); Serial.print(String(Temperature, 2)); //#02 (Field2) Serial.print("&field3="); Serial.print(String(PH, 2)); //#03 (Field3) Serial.print("&field4="); Serial.print(String(ORP, 2)); //#04 (Field4) Serial.print("&field5="); Serial.print(String(RH, 2)); //#05 (Field5) Serial.print("&field6="); Serial.print(String(PCL, 2)); //#06 (Field6) Serial.println(); readSerialString(serInString, 1000); //Convert the values to strings. }//void logDataWeb.

As you can see here, the respective sensor names are substituted with common field names. These fieldnames are directed by ThingSpeak. They represent (six parameters in this project, that is…) six of the eight fieldnames that can exist in any ThingSpeak channel that you create there. Now, when you have installed all of the sensors and Arduino together and connected the Arduino to the computer that is destined to be the Prophetes monitor, you can test this part of your installation by using the Arduino software and use the on-board monitor to see whether Arduino sends data or not. Assuming that this part of your installation is running well, continue with the dashboard part on ThingSpeak.com If you have not done so already, create an account to get entrance to the ThingSpeak portal. Now set up your monitor channel. Give it an appropriate name. (Mine is 'Amazone Biotope Aquarium') Now, depending on the sensors that you have in your Arduino system, in the channel settings, create a field for every one of the fields that you have in your Arduino sketch. Give them the same name as well.

6 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


ThingSpeak: Assuming that the Arduino part of your project is running well, continue with the dashboard part on ThingSpeak.com If you have not done so already, create an account to get entrance to the ThingSpeak portal. Now set up your monitor channel. Give it an appropriate name. (Mine is 'Amazone Biotope Aquarium')

Now, depending on the sensors that you have in your Arduino system, in the channel settings, create a field for every one of the fields that you have in your Arduino sketch. Give them the same name as well.

(According to the ThingSpeak website) Channel Settings: •Channel Name: Enter a unique name for the ThingSpeak channel. •Description: Enter a description of the ThingSpeak channel. •Field#: Check the box to enable the field, and enter a field name. Each ThingSpeak channel can have up to 8 fields. •Metadata: Enter information about channel data, including JSON, XML, or CSV data. •Tags: Enter keywords that identify the channel. Separate tags with commas. •Link to External Site: If you have a website that contains information about your ThingSpeak channel, specify the URL. •Show Channel Location: ◦Latitude: Specify the latitude position in decimal degrees. For example, the latitude of the city of London is 51.5072. ◦Longitude: Specify the longitude position in decimal degrees. For example, the longitude of the city of London is -0.1275. ◦Elevation: Specify the elevation position meters. For example, the elevation of the city of London is 35.052. •Video URL: If you have a YouTube™ or Vimeo® video that displays your channel information, specify the full path of the video URL. •Link to GitHub: If you store your ThingSpeak code on GitHub®, specify the GitHub repository URL.

Now set the channel to public sharing: 'Share channel view with everyone'. And finally get the channel API key that is needed for communication with other applications such as Prophetes. ATTENTION: ThingSpeak will create this individual channel API key. Make a note of this for future use because Prophetes needs this to connect with this channel. I have created two views: the “Private” view contains the actual sensor values that are sent to ThingSpeak, and the “Public” view that allows the world to see my aquarium water monitor. “Public” view graphics are created in the “MathLab Visualization” section on your ThingSpeak channels. I separated the ThingSpeak channels from the MathLab visualizations. The channels are on the “Private” section, whilst the “Visualizations” are “Public”. Private channel

Public channel

7 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


Create a “MathLab Visualization graph”: To create a MathLab graph click on the green “Visualizations” button at the right hand top of the screen. You will be presented a screen in which you can create a new graph or edit an existing one. Create a new graph: Leave the settings as they are: Templates: Custom (no starter code) (Checked!)

Here you can build your personal graph on the data from your Arduino data.

The NAME of your graphic comes here. The code that will construct and present the data will come in this part.

Click “Save and Run” to see the effect of your code and edit if necessary.

ThingSpeak shows your channel information for your convenience: I use three types of graphs and a widget in my monitor:  Just the plain values from Arduino.  Graphs to see the correlation between two parameters.  Widgets to show the actual process value.

My API KEYS are here.

Below is the screen with the code for the temperature/pH correlation:

Click “Save and Run” will show the result below the code, as shown on the right: You can make adjustments to the code and rerun again until it is as you want it to be.

Check the box for the “Public URL”. Create a public URL: Check this box to make this visualization public and generate a public URL to share your MATLAB visualization. If this box is checked, you can also add the visualization to the public view of your public channels.

8 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


Here is the one that shows the pH of my aquarium:

And this one creates the correlation between the temperature and the pH:

% Aquarium pH % The first data segment - note that this should contain less than 8000 points end1 = datetime('now'); start1 = end1 - days(2);

% Temperature and pH Correlation % Channel ID to read data from readChannelID = 531447; % pH Field ID pHFieldID = 3; % Temperature Field ID TempFieldID = 2;

% Second data segment - note that this should contain less than 8000 points end2 = start1; start2 = end2 - days(2); % Read the first data segment: Value and Reference [data1, time1] = thingSpeakRead(531447, 'DateRange', [start1, end1], 'Fields', [3]); % Read the second data segment High and Low Tolerances [data2, time2] = thingSpeakRead(531447, 'DateRange', [start2, end2], 'Fields', [3]);

% Channel Read API Key % If your channel is private, then enter the read API % Key between the '' below: readAPIKey = 'CIPCD1HISP7S68K0'; [data,timeStamps] = thingSpeakRead(readChannelID,'Fields',[pHFieldID TempFieldID], ... 'NumPoints',900, ... 'ReadKey',readAPIKey); PHData = data(:,1);

% join the two data sets data = [data2; data1]; time = [time2; time1]; % Plot the data thingSpeakPlot(time,data,'Grid','on') Below the graph:

% Read Temperature Data TempData = data(:,2); thingSpeakPlotYY(timeStamps,PHData,timeStamps,TempData,'Ylabel1','pH','Ylab el2','Celsius','Grid','on');

Below the Widget:

How to create the “Actual Temperature� widget is on the next page.

9 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


Create a widget: Create a widget to show the actual (i.e. the last received) value:

Click on the button “Add Widgets� and set the values for this widget. See the screen with my widget settings on the right as an example: Setting the colors may be a bit tricky. You have to enter each color for each section individually and save them as you go. You might try to add a number of new sections in one input session, but my experience is that this will result in disaster because the widget will make a mess of the input, and you will have to start over and over again. To make things easier I have found some HTML color information and I listed the colors I want to use in advance. Now I only have to select the wanted color HEX code and copy/paste it in the next widget section. Color codes: https://htmlcolorcodes.com/color-names/ ColorCode/Parameter: #008000 Green #00FF00 Lime #32CD32 LimeGreen #0000FF Blue #FFA500 Orange #FF4500 OrangeRed #FF0000 Red #FFFF00 Yellow #FFD700 Gold #FF1493 DeepPink #00FFFF Aqua #D3D3D3 LightGray #808080 Gray #708090 SlateGray #000000 Black

This concludes the part of the ThingSpeak implementation for your monitoring project.

10 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


E-mail Setup: Create a Gmail account to handle the mail that Prophetes will send. Now use Prophetes to set controls on your Arduino data and send you email messages when things go wrong! Prophetes uses GMAIL as the carrier for email messages In order to make this happen you must provide Prophetes with its own GMAIL ACCOUNT. So, open GMAIL and crate the account for your Prophetes monitor application. This account will be the gateway for all the messages that Prophetes will send to you or anyone you choose to receive them. Therefore give the account an appropriate name, like: 'MailProphetes' or 'MailFromMyProcess'. (Better to keep this mail address for yourself, somebody may think it's funny to send mail to it..... You may also set a filter to prevent this from happening.) Now set the mail properties to let Gmail forward all mail from Prophetes to your chosen mail addresses. Enter the Gmail settings page and (again) select 'settings'. There you can set the re-direct to your own email address, and to others as well if you want to. Set the 'Keep Mail' on 'Destroy the mail at Gmail', otherwise this mailbox will clutter up and maybe will stop functioning all together. No POP and No IMAP settings. And finally, (applies when you are using Outlook) prevent doubling of your received emails. Go into your outlook and open the account on which your mail will be received. Follow these steps: 1: Open the account and open the 'Change Account' tab. 2: Navigate to the 'Email' tab and click 'Change Email'. 3: Click on 'More Settings' and click on the tab: 'Advanced'. 4: Uncheck the box: 'Keep a copy on the server'. 5: Click 'OK' and close the account settings. Set the account to: "Third-party sites & apps with access to your account". Test the account by sending an email to your newly created account and watch it being dropped in the Gmail mail server. You might (as I did) set up your Outlook (if any other) to re-direct the mails from the Gmail Prophetes account into a specific Outlook folder in order to keep them separated from your regular mail.

OK, all of the main requirements are fulfilled by now.

Next section of this manual: How to get the Arduino data into the ThingSpeak dashboard? I have seen a number of posts in various portals like the Arduino portal (https://www.arduino.cc/) and others. It turns out that people (and like myself) find it hard to transport the data from their Arduino sensors into the ThingSpeak graphical dashboards. But I needed more: I want a notification when certain levels of my aquarium water properties run outside tolerances. ThingSpeak offers a way to get this done: thru IFTTT (https://www.makeuseof.com/tag/ifttt-connect-anything-maker-channel/). So I went for this option, but I found that is rather complicated and I had to setup a lot of parameters and properties. And in the end I still did not got what I was looking for, also due to some restrictions that IFTTT has put on to its service. (Which is, by the way, very good and relatively easy to use….. But I needed just a little bit more….) I decided to develop my own application that does the job and named it “Prophetes”, after the guy who is the mediator between a customer and the “Pythia”, the Oracle of Delphi.

11 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


Prophetes: I have developed two versions of Prophetes:  

A Windows XP and XP-Pro version. A Windows Vista/7/8.x/10 version.

Both come in a FreeWare version with restricted functions and in a payed FullFunction version. The only difference between the FullFunction and the FreeWare version is the number of fields that you can propagate; the FreeWare version has a restriction of two fields that can set by the user, and will always send the Arduino data to a CSV file on your computer, at least, when you set the CSV command in your Arduino sketch to ‘true”. The FullFunction version has no restrictions. In order to eliminate errors and enhance Prophetes we want to know when Prophetes encounters an error or run into problems. Prophetes will send error messages to Visual Data Webservices when they arise. That is why ask your consent before use of Prophetes before really starting the program. Below is a screenshot of the Windows XP and XP-Pro version (FreeWare version).

As I mentioned earlier, Prophetes serves three main functions: 1. Sending Arduino data directly to your ThingSpeak monitor dashboard. 2. Sending Arduino data to an external file on your computer. 3. Sending emails to you when certain parameters are drifting outside the tolerances. Differences between the FreeWare version and the FullFunction versions are:

Windows XP/XP-Pro Prophetes: 

FreeWare version: o Has a maximum of two parameter fields that can actively be monitored by the user. o Will always and only send data to a CSV file. This cannot be changed. o Sends mail every two hours to the user. FullFunction versions: o Has up to eight parameters parameter fields that can actively be monitored by the user.

12 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


Below is a screenshot of the Windows Vista/7/8.x/10 version (FullFunction version).

Windows Vista/7/8.x/10 Prophetes: ďƒź

ďƒź

FreeWare version: o Has a maximum of two parameter fields that can actively be monitored by the user. o Will always and only send data to a CSV file. This cannot be changed. o Sends mail every two hours to the user. This cannot be changed. FullFunction has no restrictions.

However, all Prophetes versions will send all your Arduino data to your ThingSpeak channels and will email you when certain parameter run outside tolerances!

13 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


Set up Prophetes: In order to let Prophetes communicate with your ThingSpeak channel and sending emails you have to set up a couple of parameters in Prophetes. The main properties for communication with ThingSpeak are equal for all Prophetes versions. I show the Vista/7/8.x/10 version as example: (Only the fields that can be edited are explained here) Your path end input and output filenames

Checkbox for “Exception mail only�

ThingSpeak secret Channel KEY

Your Prophetes Gmail adres

Your Prophetes Gmail password

Selection box for periodic mail to be send by Prophetes. Selection box for periodic Arduino data reading by Prophetes. Your Arduino fieldnames (same as in ThingSpeak)

Your Low (left) and High (right) tolerances per parameter.

And now the ultimate phase: Let Prophetes connect between Arduino and ThingSpeak and make your monitor available on the Internet! Get your free Prophetes copy form my website below and unzip the application in an appropriate folder on your monitor computer. Start Prophetes and set up the ThingSpeak properties: Copy and paste the channel API key into the API key field in Prophetes. Save the setting. Basically; that's it!

Download Prophetes at: http://www.rca-pythia.net/OurTutorials/ProphetesTutorials.aspx When you start your monitor computer, the Arduino will start immediately measuring the values of the sensors that are attached to it and pushes them to the USB port. Start Prophetes monitoring the USB port and send the data to ThingSpeak by clicking the [Connect Arduino] button. At first not much seems to happen; Prophetes is initializing. Then the time bar will start to run and Prophetes will send the received data to ThingSpeak, one each minute. In effect, ThingSpeak will show the data in the respective fields (Named '&field1' up to '&field8') as graphs. Now use Prophetes to set controls on your Arduino data and send you email messages when things go wrong!

14 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


A special feature: Stress Level. Because I can only set a warning on one process parameter, I had to come up with an idea to overcome this problem. This is the “Stress Level” part of the Arduino sketch because it is there where sensor data originates. The Arduino sketch has, as has Prophetes, a low and a high tolerance level, although, in the Arduino sketch, they have a complete other purpose: They are there to calculate the stress level of the combined sensor data that are in your project before sending them to Prophetes. As we saw in the setup of the ThingSpeak channel, there are only eight fields per channel available. And that is why I have to be careful with the number of process parameters that I want to send to my ThingSpeak dashboard. And this is why I have developed the concept of “Stress Level”. I invented the stress level for three purposes: 1. Create an overall measurement for a complex set of sensor readings. 2. Use only one of the eight fields in my ThingSpeak monitor and being able to react on it. 3. Prophetes has to send emails on only one parameter value. This gives me seven free process parameters that I can assign to any Arduino sensoring project and just cost me one field for actual sensor data but let me trigger on the combination of all the measured sensor values. Below the Stress Level graph:

Below the Stress Level Widget:

Tolerances in the Prophetes: The tolerances within the Prophetes application are needed to get the email send on the right moment and value, and have no interaction whatsoever with the tolerances in the Arduino sketch. Stress Level and tolerances in the Arduino sketch: The main variables in the Arduino sketch are the parameter values that are really measured by reading the sensor probes. In order to know whether or not these readings are the optimal values they have to be compared with the tolerances that you set on each of them. I have written an algorithm that calculates the stress level for each of the measured parameters as a percentage of the deviation of that value from the low or high tolerance for that parameter. The greater the deviation is, the higher is the stress level. Now the clever bit: Because the build-up of the stress level is based on the position of each single parameter digit, you have to decide what is the most significant process parameter, and what is the least significant process parameter. Thus: what do you think, has the most impact, and what has the least. I decided for this set of significance: (Remember: the significance index is zero based!) Significance:

(0) (1) (2) (3) (4) | | | | | | | | | +---> Light | | | +---+-----> ORP | | +---+---+-----> rH | +---+---+---+----> Temperature +-------+---+---+---> pH

LightStressSignificanceIndex = 4 ORPSignificanceIndex = 3 RHStressSignificanceIndex = 2 TempStressSignificanceIndex = 1 PHStressSignificanceIndex = 0

I assign a certain significance to every process parameter and let the value, that the algorithm has calculated, place on the respective location in the resulting “Stress Level” for the process. Assume that there are five sensors (as in my aquarium project). Then Arduino will calculate a stress level that with a format of 5 digits: “12345” This results in a value that can lie between “00000”and “99999”. First determine the exponent that will be used to calculate the end result of the stress level that has to be sent to Prophetes. This is done by counting the number of parameters (5 in this case) and subtract 2 from that number. This gives me a power of 5-2 = 3. Now, to prevent the ThingSpeak graphs jump between these (potentially BIG) low and high values, I divide this result by a power (=3) of 10 in order to force the possible stress level between a minimum of 0.00 and a maximum of 99.99 (See below and the sketch I provide in this document and on my website).

15 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


The Stress Level explanation: /* ProcessStressLevel to Prophetes. ProcessStressLevel is based on the significance of all of the measured parameters of the process. The StressSignificanceIndex is the variabele that sets this significance. The process impact level is a one-value result of the combined measurements for all the connected sensors. Each sensor measures a perticular process parameter, but the impact of each parameter has it's own level on the total of the process quality. Each of the seven (maximum number of sensors) is awarded with its own 'StressImpactLevel' and a 'StressSignificanceIndex' wich can be between 0 an 9. Thus, when all seven parameters ar in use, the stress levels of each parameter are combined by multiplying the actual sensor's measurement with the StressImpactLevel and added to the ProcessStressLevel. Each individual parameter stresslevel is calculated by taking the actual measurement and determine wether it is within tolerances. If so, the stress level is zero. When a measurement is outside, either low or high, tolerance, the StressImpactLevel is calculated to a result between 0 and 9. Example: My process for monitoring water quality has 3 parameters with the significance that I attatched to them: 1: Light Low significance LightStressSignificanceIndex = (1); High tolerance: 500; Low tolerance: 100 2: Temperature Medium significance TempStressSignificanceIndex = (2); High tolerance: 24.00; Low tolerance: 20.50 The stress level is always the last parameter that Arduino sends to the output string. 3: Stress Level High significance PHStressSignificanceIndex = (intNumberOfParameters + 1); High tolerance: 6.82; Low tolerance: 6.20 Calculate the StressImpactLevel for each parameter: Take the temperature as an example: The actual measurement is 27.32 degrees Celcius. This is 27.32 - 24.00 = 3.32 degrees above the high tolerance. So it is (3.32 / 27.32) * 100 = 12.15% above the high tolerance value. Because the StressImpactLevel is a one-digit value between 0 and 9, this 12.15% has to be converted to a value within this 0 to 9 range. This is done by 'Mapping'. Because the MAP() function only accepts integer values, the percentage have to multiplied by 100 in order to get the integer of the decimal measurement. Recalculate the above percentage to the integer value: 12.15 * 100 = 215 -=> the integer that the MAP() function will use is 1215. So the percentage input range for the map is between 0 and 99999 and we need an output from the MAP() function between 0 and 9. (Remember: there are 2 sensor parameters, so the ProcessStressLevel is a 2 digit value. This can change if there are less or more, up to seven, sensors in the project) This is the MAP() construct: TempStressImpactLevel = map(1215, 0, 99999, 0, 9); Output example is '2' and the significance is (5). When this mapping is done for all the present parameters this ProcessStressLevel result could come out: '36'. Meaning:

Significance: charProcessStressLevel[] StressImpactLevel:

High significance Low significance (0) (1) (2) (3) (4) | | | | | "0 0 0 0 0" 3 6 4 2 2 (example values) | | | | | | | | | +---> Light | +---+---+---+----> Temperature +-------+---+---+---> pH | | | +---+-----> ORP | | +---+---+-----> rH

LightStressSignificanceIndex = 4 TempStressSignificanceIndex = 1 PHStressSignificanceIndex = 0 ORPSignificanceIndex = 3 RHStressSignificanceIndex = 2

Now, how to place the mapped results in their respective place (=significance value) in the ProcessStressLevel? The charProcessStressLevel array will hold the individual process stress levels on the right spot, from the most significant value on the left, to the least significant value on the right. charProcessStressLevel[2 + 1]; //An array big enough for a 'intNumberOfParameters'; charProcessStressLevel[intNumberOfParameters] = '/0'; // terminate the string. Now the charProcessStressLevel has to be converted to the ultimate StressImpactLevel: StressImpactLevel = charProcessStressLevel.ToInt(); Because this can be a rather big integer number ( i.e. 9999999), it will be converted to a decimal value between 0 and 99. Now it is clear that the two most relevant process parameters result in the highest stress level, because they are at the left of the string. Now, how to place the mapped results in their respective place (=significance value) in the ProcessStressLevel? The charProcessStressLevel array will hold the individual process stress levels on the right spot, from the most significant value on the left, to the least significant value on the right. charProcessStressLevel[2 + 1]; //An array big enough for a 'intNumberOfParameters'; charProcessStressLevel[intNumberOfParameters] = '/0'; // terminate the string. Now the charProcessStressLevel has to be converted to the ultimate StressImpactLevel: StressImpactLevel = charProcessStressLevel.ToInt(); Because this can be a rather big integer number ( i.e. 99), it will be converted to a decimal value between 0 and 99. Now it is clear that the two most relevant process parameters result in the highest stress level, because they are at the left of the string. */

16 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


Example of a typical mail from Prophetes: (sorry, it is part in Dutch!)

Van: Aquarium (from ASUS) [mailto: **********@gmail.com] Verzonden: zondag 12 augustus 2018 12:16 Aan: **********@gmail.com Onderwerp: **** WARNING! Measurement(s) outside tolerance(s) ****; Aquarium (from ASUS)

The parameters are fine! Nothing outside tolerances. ======================================================== Light; field 1 is fine. Value: 539.11 ======================================================== Temperature Value above high tolerance High Tolerance: 24.8 Field 2 out of tolerance. Value: 26.13 Low Tolerance: 22.5 ======================================================== pH; field 3 is fine. Value: 6.63 ======================================================== ORP Value above high tolerance High Tolerance: 350 Field 4 out of tolerance. Value: 439.94 Low Tolerance: 325 ======================================================== rH; field 5 is fine. Value: 35.20 ======================================================== Stress Level Value above high tolerance High Tolerance: 5 Field 6 out of tolerance. Value: 11.00 Low Tolerance: 0 ========================================================

17 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


Private Dashboard: How to create a dashboard on your own website? Now you have a water quality monitor for my Amazone biotope aquarium. But you want it to show on your own website, or any other one for that matter. How do to do this? Easy: Use the “IFRAME” function that ThingSpeak supplies at every view that you have created!

The IFrame script icon. Click here…

By the way.... Clicking this icon let you edit this particular chart properties...

Take my example for the pH sensor value:

When you click on the Iframe script icon you will get a HTML script for your web page:

Create your personal dashboard on your website like I did. Put a table in a website’s page with a Iframe script in each table cell: <table> <tbody> <tr><td> Temperature Correlation data </td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/apps/matlab_visualizations/239046"></iframe> </td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/apps/matlab_visualizations/240083"></iframe> </td></tr> <tr><td> Acidity Correlation data </td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/apps/matlab_visualizations/239055"></iframe> </td>td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/apps/matlab_visualizations/243780"></iframe> </td><td></tr><tr><td> Stress Level data </td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/apps/matlab_visualizations/239053"></iframe> </td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/531447/maps/channel_show"></iframe> </td></tr><tr><td> Light data </td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/apps/matlab_visualizations/240379"></iframe> </td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/531447/widgets/9882"></iframe> </td></tr><tr> <td>Temperature data

18 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


</td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/apps/matlab_visualizations/240380"></iframe> </td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/531447/widgets/9883"></iframe> </td></tr><tr> <tr><td> Acidity data </td><td><iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/apps/matlab_visualizations/243823"></iframe> </td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/531447/widgets/9884"></iframe> </td></tr><tr><td> Oxidation&Reduction data </td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/apps/matlab_visualizations/243824"></iframe> </td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/531447/widgets/9885"></iframe></td> </tr><tr><td> Redox data </td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/apps/matlab_visualizations/243830"></iframe> </td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/531447/widgets/9886"></iframe> </td><tr><td> Stress Level data </td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/apps/matlab_visualizations/243832"></iframe> </td><td> <iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/531447/widgets/9887"></iframe> </td></tr></tbody> </table>

That’s it! This is how I developed this project. Have fun with it when you try to build it as well!

More information about this suit can be found at our website: http://www.rca-pythia.net/ For any advice, help, information or pricing of Prophetes or Pythia, please mail to: info@visualdata.nl Download the Arduino sketch at: http://www.rca-pythia.net/OurTutorials/ArduinoTutorials/TheSketch.aspx Download Prophetes at: http://www.rca-pythia.net/OurTutorials/ProphetesTutorials.aspx

19 Visual Data Webservices http://www.rca-pythia.net/Home.aspx; Mail: info@visualdata.nl


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.