Export Sensor Data from the PSLab Android App

The PSLab Android App allows users to log data from the sensors connected to the PSLab hardware device. Sensor Data is stored locally but can be exported in various formats. Currently the app supports exporting data in .txt and .csv (comma-separated values) format. Exported data can be used by other users or scientists to study or analyze the data. Data can also be used by other softwares like Python, GNU octave, Matlab to further process it or visualise it in 3D. In this post, we will discuss how to export the locally stored realm data in .txt or .csv format. We will take the data of MPU6050 sensor as an example for understanding how locally logged data is exported. Query Local Realm Data We have attached a long click listener to sensor list view that detects which list item is selected. Clicking any sensor from sensor list for slightly longer than usual would result in a dialog popping up with the option to Export Data: Results in exporting data in a format which is selected in App settings Share Data: Shares sensor data with other users or on social media (yet to be implemented) As soon as the Export Data option is selected from the dialog, sensor data of the corresponding sensor is queried. The data model of the sensor and how it's saved in the local realm database is discussed in the post Sensor Data Logging in the PSLab Android App. RealmResults<DataMPU6050> results = realm.where(DataMPU6050.class).findAll(); Once we get the required data, we need to write it in .txt or .csv format depending on what the user has selected as a preference in App Settings. Getting User Preference from App Settings The format in which the sensor data should be exported is presented to the user as a preference in App Settings. Currently the app supports two formats .txt and .csv. private String format; SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); String formatValue = preferences.getString("export_data_format_list", "0"); if ("0".equals(formatValue))   format = "txt"; else   format = "csv"; Export Data in .txt Format To export the sensor data in .txt format, we need to create a .txt file in the external storage. folder variable is a path to PSLab Android folder in the external storage. If the folder doesn’t exist, it will be created. File folder = new File(Environment.getExternalStorageDirectory() + File.separator + "PSLab Android"); After getting reference of the app folder in the external storage, we would create a text file in the PSLab Android folder. As soon as the text file is created, we initialize the FileOutputStream object to write data into the text file. The sensor data that was queried in the previous section is written into the text file just created. Finally after the complete sensor data is written, the stream is closed by stream.close() method. FileOutputStream stream = null; File file = new File(folder, "sensorData.txt"); try {   stream = new FileOutputStream(file);   for (DataMPU6050 temp : results) {       stream.write((String.valueOf(temp.getAx()) + " " + temp.getAy() + " " + temp.getAz() + " " +               temp.getGx()…

Continue ReadingExport Sensor Data from the PSLab Android App

How Switch Case improve performance in PSLab Saved Experiments

PSLab android application contains nearly 70 experiments one can experiment on using the PSLab device and the other necessary circuit components and devices. These experiments span over areas such as Electronics, Electrical, Physical and High school level. All these experiments are accessible via an android adapter in the repository named “PerformExperimentAdapter”. This adapter houses a tab view with two different tabs; one for the experiment details and the other for actual experiment and resultant graphs. The adapter extends an inbuilt class FragmentPagerAdapter; public class PerformExperimentAdapter extends FragmentPagerAdapter This class displays every page attached to its viewpager as a fragment. The good thing about using fragments is that they have a recyclable life cycle. Rather than creating new views for every instance of an experiment, the similar views can be recycled to use once again saving resources and improving performance. FragmentPagerAdapter needs to override a method to display the correct view on the tab select by user. @Override public Fragment getItem(int position) { } Depending on the value of position, relevant experiment documentation and the experiment implementation fragments are displayed determined using the experiment title. Performance can be critical in this place as if it takes too long to process and render a fragment, user will feel a lag. The previous implementation was using consecutive if statements. @Override public Fragment getItem(int position) { switch (position) { case 0: if (experimentTitle.equals(context.getString(R.string.diode_iv))) return ExperimentDocFragment.newInstance("D_diodeIV.html"); if (experimentTitle.equals(context.getString(R.string.zener_iv))) return ExperimentDocFragment.newInstance("D_ZenerIV.html"); ... case 1: if (experimentTitle.equals(context.getString(R.string.diode_iv))) return ZenerSetupFragment.newInstance(); if (experimentTitle.equals(context.getString(R.string.zener_iv))) return DiodeExperiment.newInstance(context.getString(R.string.half_wave_rectifier)); ... default: return ExperimentDocFragment.newInstance("astable-multivibrator.html"); } } This setup was suitable for applications where there is less than around 5 choices to chose between. As the list grows, the elements in the end of the if layers will take more time to load as each of the previous if statements need to be evaluated false in order to reach the bottom statements. This is when this implementation was replaced using switch case statements instead of consecutive if statements. The theory behind the performance improvement involves algorithm structures; Hash Tables Hash Tables Hash tables use a hash function to calculate the index of the destination cell. This operation on average has a complexity of O(1) which means it will take the same time to access any two elements which are randomly positioned. This is possible because java uses the hash code of the string to determine the index where the target is situated at. This way it is much faster than consecutive if statement calls where in the worst case it will take O(n) time to reach the statement causing a lag in the application. Current application uses switch cases in the PerformExperimentAdapter; @Override public Fragment getItem(int position) { switch (position) { case 0: switch (experimentTitle) { case "Diode IV Characteristics": return ExperimentDocFragment.newInstance("D_diodeIV.html"); case "Zener IV Characteristics": return ExperimentDocFragment.newInstance("D_ZenerIV.html"); case "Half Wave Rectifier": return ExperimentDocFragment.newInstance("L_halfWave.html"); } case 1: switch (experimentTitle) { case "Diode IV Characteristics": return ZenerSetupFragment.newInstance(); case "Zener IV Characteristics": return ZenerSetupFragment.newInstance(); case "Half Wave Rectifier": return DiodeExperiment.newInstance(context.getString(R.string.half_wave_rectifier)); } default: return ExperimentDocFragment.newInstance("astable-multivibrator.html"); } } There…

Continue ReadingHow Switch Case improve performance in PSLab Saved Experiments

Coloring Waveforms in PSLab Charts

Charts are used to display set of data in an analytical manner such that an observer can easily come to a conclusion by just looking at it without having to go through all the numerical data sets. Legends are used to differentiate a set of data set from another set. Generally, different colors and different names are used to form a legend in a chart. MPAndroidChart is an amazing library with the capability of generating different types of graphs in an Android device. In PSLab several user interfaces are implemented using LineCharts to display different waveforms such as readings from channels attached to PSLab device, logic levels etc. When several data sets are being plotted on the same graph area, legends are used. In PSLab Android application, Oscilloscope supports four different type of waveforms to be plotted on the same graph. Logic Analyzer implements one to four different types of logic level waveforms on the same plot. To identify which is which, legends with different colors can be used rather than just the names. For the legends to have different colors, it should be explicitly set which color should be held by which data set. Otherwise it will use the default color to all the legends making it hard to differentiate data lines when there are more than one data set is plotted. Assume a data set is generated from a reading taken from a probe attached to PSLab device. The set will be added as an Entry to an array list as follows; ArrayList<Entry> dataSet = new ArrayList<Entry>(); The next step will be to create a Line Data Set LineDataSet lineData = new LineDataSet(dataSet, "DataSet 1"); This LineDataSet will contain sample values of the waveform captured by the microprocessor. A LineDataSet object support many methods to alter its look and feel. In order to set a color for the legend, setColor() method will be useful. This method accepts an integer as the color. This method can be accessed as follows; lineData.setColor(Color.YELLOW); MPAndroidChart provides different sets of colors under ColorTemplate. This class has several predefined colors with five colors in each color palette are added by the developers of the library and they can be accessed using the following line of code by simply calling the index value of the palette array list. set1.setColor(ColorTemplate.JOYFUL_COLORS[0]); Set of color palettes available in the ColorTemplate class are; LIBERTY_COLORS JOYFUL_COLORS PASTEL_COLORS COLORFUL_COLORS VORDIPLOM_COLORS MATERIAL_COLORS The following demonstrates how the above activities produce a line chart with three different data sets with different colored legends. This implementation can be used to enhance the readability of the waveforms letting user being able to differentiate between one waveform from another in PSLab Android application. Resources: MPAndroidChart Repository: https://github.com/PhilJay/MPAndroidChart Line Charts: https://en.wikipedia.org/wiki/Line_chart MPAndroidChart Line Chart Tutorial: https://www.numetriclabz.com/android-line-chart-using-mpandroidchart-tutorial/ MPAndroidChart Legends tutorial: https://www.studytutorial.in/android-line-chart-or-line-graph-using-mpandroid-library-tutorial PSLab official web site: https://pslab.fossasia.org/

Continue ReadingColoring Waveforms in PSLab Charts

Performing Diode Clipping and Clamping Experiment in PSLab Android

We can perform experiments like diode clipping and clamping using PSLab Android. A circuit which removes the peak of a waveform is known as a clipper. Diode clipper cuts off the top half or lower half or both top and lower half of the input signal.  Different types of clipping circuits listed below Different Clipping Experiments A clamper circuit adds the positive dc component to the input signal to push it to the positive side. Similarly, a clamper circuit adds the negative dc component to the input signal to push it to the negative side. It basically shifts the input signal without changing the shape of the signal. Different Clamping Experiments Apparatus Diode, Resistance, Capacitor (only for diode clamping), Breadboard, Wires and PSLab Adding Diode Clipping Experiment support in PSLab Android App To support Diode Clipping Experiment we require generating a sine wave and a dc component. This can be done using W1 and PV1 pins in PSLab device. Both input and output signals can be read using CH1 and CH2. So, when the Diode Clipping Experiment needs to be performed the following code needs to be implemented scienceLab.setSine1(5000); scienceLab.setPV1(//progress of the seekbar); The signals are recorded using Oscilloscope Activity. Adding Diode Clamping Experiment support in PSLab Android App Diode Clamping Experiment was implemented similarly to Diode Clipping Experiment. The following are the screenshots of the experiment.      The following is a glimpse of Diode Clamping Experiment performed using PSLab device using PSLab Android App. Resources Read more about Clipper Circuits - http://www.circuitstoday.com/diode-clippers http://www.physics-and-radio-electronics.com/electronic-devices-and-circuits/rectifier/clippercircuit-seriesclippersandshuntclippers.html Read more information about Clamping Circuits - http://www.physics-and-radio-electronics.com/electronic-devices-and-circuits/rectifier/clampercircuits.html http://www.circuitstoday.com/diode-clamping-circuits

Continue ReadingPerforming Diode Clipping and Clamping Experiment in PSLab Android

Including a Graph Component in the Remote Access Framework for PSLab

The remote-lab software of the pocket science lab enables users to access their devices remotely via the Internet. It includes an API server designed with Python Flask, and a web-app designed with EmberJS that allows users to access the API and carry out various tasks such as writing and executing Python scripts. In a series of blog posts, various aspects of this framework such as  remote execution of function strings, automatic deployment on various domains, creating and submitting python scripts which will be run on the remote server etc have already been explored.  This blog post deals with the inclusion of a graph component in the webapp that will be invoked when the user utilises the `plot` command in their scripts. The JQPLOT library is being used for this purpose, and has been found to be quite lightweight and has a vast set of example code . Task list for enabling the plotting feature Add a plot method to the codeEvaluator module in the API server and allow access to it by adding it to the evalGlobals dictionary Create an EmberJS component for handling plots Create a named div in the template Invoke the Jqplot initializer from the JS file and pass necessary arguments and data to the jqplot instance Add a conditional statement to include the jqplot component whenever a plot subsection is present in the JSON object returned by the API server after executing a script Adding a plot method to the API server Thus far, in addition to the functions supported by the sciencelab.py instance of PSLab, users had access to print, print_, and button functions. We shall now add a plot function. def plot(self,x,y,**kwargs): self.generatedApp.append({"type":"plot","name":kwargs.get('name','myPlot'),"data":[np.array([x,y]).T.tolist()]})   The X,Y datasets provided by the user are stacked in pairs because jqplot requires [x,y] pairs . not separate datasets. We also need to add this to evalGlobals, so we shall modify the __init__ routine slightly: self.evalGlobals['plot']=self.plot Building an Ember component for handling plots First, well need to install jqplot:   bower install --save jqplot And this must be followed by including the following files using app.import statements in ember-cli-build.js bower_components/jqplot/jquery.jqplot.min.js bower_components/jqplot/plugins/jqplot.cursor.js bower_components/jqplot/plugins/jqplot.highlighter.js bower_components/jqplot/plugins/jqplot.pointLabels.js bower_components/jqplot/jquery.jqplot.min.css In addition to the jqplot js and css files, we have also included a couple of plugins we shall use later. Now we need to set up a new component : ember g component jqplot-graph Our component will accept an object as an input argument. This object will contain the various configuration options for the plot Add the following line in templates/components/jqplot-graph.hbs: style="solid gray 1px;" id="{{data.name}}"> The JS file for this template must invoke the jqplot function in order to insert a complete plot into the previously defined <div> after it has been created. Therefore, the initialization routine must override the didInsertElement routine of the component. components/jqplot-graph.js import Ember from 'ember'; export default Ember.Component.extend({ didInsertElement () { Ember.$.jqplot(this.data.name,this.data.data,{ title: this.title, axes: { xaxis: { tickInterval: 1, rendererOptions: { minorTicks: 4 } }, }, highlighter: { show: true, showLabel: true, tooltipAxes: 'xy', sizeAdjust: 9.5 , tooltipLocation :…

Continue ReadingIncluding a Graph Component in the Remote Access Framework for PSLab

Sensor Data Logging in the PSLab Android App

The PSLab Android App allows users to log data from sensors connected to the PSLab hardware device. The Connected sensors should support I2C, SPI communication protocols to communicate with the PSLab device successfully. The only prerequisite is the additional support for the particular sensor plugin in Android App. The user can log data from various sensors and measure parameters like temperature, humidity, acceleration, magnetic field, etc. These parameters are useful in predicting and monitoring the environment and in performing many experiments. The support for the sensor plugins was added during the porting python communication library code to Java. In this post,  we will discuss how we logged real time sensor data from the PSLab Hardware Device. We used Realm database to store the sensor data locally. We have taken the MPU6050 sensor as an example to understand the complete process of logging sensor data. Creating Realm Object for MPU6050 Sensor Data The MPU6050 sensor gives the acceleration and gyroscope readings along the three axes X, Y and Z. So the data object storing the readings of the mpu sensor have variables to store the acceleration and gyroscope readings along all three axes. public class DataMPU6050 extends RealmObject {   private double ax, ay, az;   private double gx, gy, gz;   private double temperature;   public DataMPU6050() {  }   public DataMPU6050(double ax, double ay, double az, double gx, double gy, double gz, double temperature) {       this.ax = ax;       this.ay = ay;       this.az = az;       this.gx = gx;       this.gy = gy;       this.gz = gz;       this.temperature = temperature;   }  // getter and setter for all variables } Creating Runnable to Start/Stop Data Logging To sample the sensor data at 500ms interval, we created a runnable object and passed it to another thread which would prevent lagging of the UI thread. We can start/stop logging by changing the value of the boolean loggingThreadRunning on button click. TaskMPU6050 is an AsyncTask which reads each sample of sensor data from the PSLab device, it gets executed inside a while loop which is controlled by boolean loggingThreadRunning. Thread.sleep(500) pauses the thread for 500ms, this is also one of the reason to transfer the logging to another thread instead of logging the sensor data in UI thread. If such 500ms delays are incorporated in UI thread, app experience won’t be smooth for the users. Runnable loggingRunnable = new Runnable() {   @Override   public void run() {       try {           MPU6050 sensorMPU6050 = new MPU6050(i2c);           while (loggingThreadRunning) {               TaskMPU6050 taskMPU6050 = new TaskMPU6050(sensorMPU6050);               taskMPU6050.execute();              // use lock object to synchronize threads               Thread.sleep(500);           }       } catch (IOException   InterruptedException e) {           e.printStackTrace();       }   } }; Sampling of Sensor Data We created an AsyncTask to read each sample of the sensor data from the PSLab device in the background thread. The getRaw() method read raw values from the sensor and returned an ArrayList containing the acceleration and gyro values. After the values were read successfully, they were updated in the data card in the foreground which was visible to the user. This data card acts as a…

Continue ReadingSensor Data Logging in the PSLab Android App

Enhancing the Functionality of User Submitted Scripts in the PSLab-remote framework

The remote-lab framework of the pocket science lab enables users to access their devices remotely via the internet. Its design involves an API server built with Python-Flask and a webapp that uses EmberJS. This post is the latest in a series of blog posts which have explored and elaborated various aspect of the remote-lab such as designing the API server and testing with Postman, remote execution of function strings, automatic deployment on various domains etc. It also supports creating and submitting python scripts which will be run on the remote server, and the console output relayed to the webapp. In this post, we shall take a look at how we can extend the functionality by providing support for object oriented code in user submitted scripts. Let’s take an example of a Python script where the user wishes to create a button which when clicked will read a voltage via the API server, and display the value to the remote user. Clearly, an interpreter that only provides the console output is not enough for this task. We need the interpreter to generate an app structure that also includes callbacks for widgets such as buttons, and JSON objects are an obvious choice for relaying such a structure to the webapp. In a nutshell, we had earlier created an API method that could execute a python script and return a string output, and now we will modify this method to return a JSON encoded structure which will be parsed by the webapp in order to display an output. Let’s elaborate this with an example : Example.py print ('testing') print ('testing some changes..... ') print_('highlighted print statement')   JSON returned by the API [localhost:8000/runScriptById] , for the above script: {"Date": "Tue, 01 Aug 2017 21:39:12 GMT", "Filename": "example.py", "Id": 4, "result": [ {"name": "print", "type": "span", "value": "('testing',)"}, {"name": "print", "type": "span", "value": "('testing some changes..... ',)"}, {"class": "row well", "name": "print", "type": "span", "value": "highlighted print statement"} ], "status": true} Screenshot of the EmberJS webapp showing the output rendered with the above JSON Adding Support for Widgets In the previous section, we laid the groundwork for a flexible platform. Instead of returning a string, the webapp accepts a JSON object and parses it. We shall now add support for a clickable button which can be associated with a valid PSLab function. An elementary JS twiddle has been made by Niranjan Rajendran which will help newbies to understand how to render dynamic templates via JSON objects retrieved from APIs. The twiddle uses two API endpoints; one to retrieve the compiled JSON output, and another to act as a voltmeter method which returns a voltage value. To understand how this works in pslab-remote, consider a one line script called button.py: button('get voltage',"get_voltage('CH1')") The objective is to create a button with the text ‘get voltage’ on it , and which when clicked will run the command ‘get_voltage(‘CH1’)’ on the API server, and display the result. When this script is run on the API server, it returns…

Continue ReadingEnhancing the Functionality of User Submitted Scripts in the PSLab-remote framework

Fascinating Experiments with PSLab

PSLab can be extensively used in a variety of experiments ranging from the traditional electrical and electronics experiments to a number of innovative experiments. The PSLab desktop app and the Android app have all the essential features that are needed to perform the experiments. In addition to that there is a large collection of built-in experiments in both these experiments. This blog is an extension to the blog post mentioned here. This blog lists some of the basic electrical and electronics experiments which are based on the same principles which are mentioned in the previous blog. In addition to that, some interesting and innovative experiments where PSLab can be used are also listed here. The experiments mentioned here require some prerequisite knowledge of electronic elements and basic circuit building. (The links mentioned at the end of the blog will be helpful in this case) Op-Amp as an Inverting and a Non-Inverting Amplifier There are two methods of doing this experiment. PSLab already has a built-in experiment dedicated to inverting and non-inverting amplification of op-amps. In the Android App, just navigate to Saved Experiments -> Electronics Experiments -> Op-Amp Circuits -> Inverting/ Non-Inverting. In case of the Desktop app, select Electronics Experiments from the main drop-down at the top of the window and select the Inverting/Non-inverting op-amp experiment. This experiment can also performed using the basic features of PSLab. The only advantage of this methodology is that it allows much more tweaking of values to observe the Op-Amp behaviour in greater detail. However, the built-in experiment is good enough for most of the cases. Construct the above circuits on a breadboard. For the amplifier, connect the terminals of CH1 and GND of PSLab on the input side i.e. next to Vi and the terminals of CH2 and GND on the output side i.e next to Vo. Usually, an Op-Amp like LM741 have a set of pins, one dedicated for the inverting input and the other dedicated for the non-inverting input. It is recommended to consult the datasheet of the Op-Amp IC used in order to get the pin number with which the input has to be connected. The terminals of W1 and GND are also connected on the input side and they are used to generate a sine wave. The resistors displayed in the figure have the values R1 = 10k and R2 = 51k. Resistance values other than these can also be considered. The gain of the op-amp would depend on the ratio of R2/R1, so it is better to consider values of R2 which are significantly larger than R1 in order to see the gain properly. Use the PSLab Desktop App and open the Waveform Generator in Control. Set the wave type of W1 to Sine and set the frequency at 1 kHz and magnitude to 0.1 V. Then go ahead and open the Oscilloscope. CH1 would display the input waveform and CH2 will display the output waveform and the plots can be observed. If the input is connected…

Continue ReadingFascinating Experiments with PSLab

Basics behind school level experiments with PSLab

Electronics is a fascinating subject to most kids. Turning on a LED bulb, making a simple circuit will make them dive into much more interesting areas in the field of electronics. PSLab android application with the help of PSLab device implements a set of experiments whose target audience is school children. To make them more interested in science and electronics, there are several experiments implemented such as measuring body resistance, lemon cell experiment etc. This blog post brings out the basics in implementing these type of experiments and pre-requisite. Lemon Cell Experiment Lemon Cell experiment is a basic experiment which will make school kids interested in science experiments. The setup requires a fresh lemon and a pair of nails which is used to drive into the lemon as illustrated in the figure. The implementation in PSLab android application uses it’s Channel 1. The cell generates a low voltage which can be detected using the CH1 pin of PSLab device and it is sampled at a rate of 10 to read an accurate result. float voltage = (float) scienceLab.getVoltage("CH1", 10); 2000 instances are recorded using this method and plotted against each instance. The output graph will show a decaying graph of voltage measured between the nails driven into the lemon. for (int i = 0; i < timeAxis.size(); i++) { temp.add(new Entry(timeAxis.get(i), voltageAxis.get(i))); } Human Body Resistance Measurement Experiment This experiment attracts most of the young people to do electronic experiments. This is implemented in the PSLab android application using Channel 3 and the Programmable Voltage Source 3 which can generate voltage up to 3.3V. The experiment requires a human with drippy palms so it makes a good conductance between device connection and the body itself. The PSLab device has an internal resistance of 1M Ohms connected with the Channel 3 pin. Experiment requires a student to hold two wires with the metal core exposed; in both hands. One wire is connected to PV3 pin when the other wire is connected to CH3 pin. When a low voltage is supplied from the PV3 pin, due to heavy resistance in body and the PSLab device, a small current in the range of nano amperes will flow through body. Using the reading from CH3 pin and the following calculation, body resistance can be measured. voltage = (float) scienceLab.getVoltage("CH3", 100); current = voltage / M; resistance = (M * (PV3Voltage - voltage)) / voltage; This operation is executed inside a while loop to provide user with a continuous set of readings. Using Java threads there is a workaround to implement the functionalities inside the while loop without overwhelming the system. First step is to create a object without any attribute. private final Object lock = new Object(); Java threads use synchronized methods where other threads won’t start until the first thread is completed or paused operation. We make use of that technique to provide enough time to read CH3 pin and display output. while (true) { new MeasureResistance().execute(); synchronized (lock) { try { lock.wait();…

Continue ReadingBasics behind school level experiments with PSLab

PSLab Remote Lab: Automatically deploying the EmberJS WebApp and Flask API Server to different domains

The remote-lab software of the pocket science lab enables users to access their devices remotely via the internet. Its design involves an API server designed with Python Flask, and a web-app designed with EmberJS that allows users to access the API and carry out various tasks such as writing and executing Python scripts. For testing purposes, the repository needed to be setup to deploy both the backend as well as the webapp automatically when a build passes, and this blog post deals with how this can be achieved. Deploying the API server The Heroku PaaS was chosen due to its ease of use with a wide range of server software, and support for postgresql databases. It can be configured to automatically deploy branches from github repositories, and conditions such as passing of a linked CI can also be included. The following screenshot shows the Heroku configuration page of an app called pslab-test1. Most of the configuration actions can be carried out offline via the Heroku-Cli   In the above page, the pslab-test1 has been set to deploy automatically from the master branch of github.com/jithinbp/pslab-remote . The wait for CI to pass before deploy has been disabled since a CI has not been setup on the repository. Files required for Heroku to deploy automatically Once the Heroku PaaS has copied the latest commit made to the linked repository, it searches the base directory for a configuration file called runtime.txt which contains details about the language of the app and the version of the compiler/interpretor to use, and a Procfile which contains the command to launch the app once it is ready. Since the PSLab’s API server is written in Python, we also have a requirements.txt which is a list of dependencies to be installed before launching the application. Procfile web: gunicorn app:app --log-file - runtime.txt python-3.6.1 requirements.txt gunicorn==19.6.0 flask >= 0.10.1 psycopg2==2.6.2 flask-sqlalchemy SQLAlchemy>=0.8.0 numpy>=1.13 flask-cors>=3.0.0 But wait, our app cannot run yet, because it requires a postgresql database, and we did not do anything to set up one. The following steps will set up a postgres database using the heroku-cli usable from your command prompt. Point Heroku-cli to our app $ heroku git:remote -a pslab-test1 Create a postgres database under the hobby-dev plan available for free users. $ heroku addons:create heroku-postgresql:hobby-dev Creating heroku-postgresql:hobby-dev on ⬢ pslab-test1... free Database has been created and is available ! This database is empty. If upgrading, you can transfer ! data from another database with pg:copy Created postgresql-slippery-81404 as HEROKU_POSTGRESQL_CHARCOAL_URL Use heroku addons:docs heroku-postgresql to view documentation The previous step created a database along with an environment variable HEROKU_POSTGRESQL_CHARCOAL_URL . As a shorthand, we can also refer to it simply as CHARCOAL . In order to make it our primary database, it must be promoted $ heroku pg:promote HEROKU_POSTGRESQL_CHARCOAL_URL The database will now be available via the environment variable DATABASE_URL Further documentation on creating and modifying postgres databases on Heroku can be found in the articles section . At this point, if the app is…

Continue ReadingPSLab Remote Lab: Automatically deploying the EmberJS WebApp and Flask API Server to different domains