Monthly Archives: August 2019

Added Weather Underground support and version Alpha.26.324 released

I have added a new section in the Web Portal for 3rd party online services. Right now it supports a service called ‘Weather Underground’, which from my understandings is a website that hosts a collection of environmental readings provided by citizen donating the use of their weather stations. To get it working, you need an account with Weather Underground, then you can add a device on their website to get an ID and Key, which is what you need to get it working.

I also created a post about my Sensor Project on the Raspberry Pi forums. I’m hoping to get a bit of feedback.

This marks the final release of Alpha.26.324. Since I’m mostly making changes to the server and HTML side of things, I’m releasing Control Center versions that look like this “Alpha.26.x”, indicating it was released supporting the Alpha.26 branch.

HTTPS Enabled!

I am now using HTTPS instead of HTTP. I even have self-signed certificates generate automatically if they are not present in the ssl_files folder. This allows 3 things.

  1. If you don’t have your own certificates, it creates them when the program launches, creating a user-friendly experience. If they are already in the folder, it simply loads them.
  2. You can replace the certificate files in the ssl_files folder with your own to get the nice green bar in your browser.
  3. Simply delete all the files in the ssl_files folder, reboot the sensor and you have new certificates that are good for 5 years.

Initially, I thought that incorrect time on the sensor would not allow you to connect to the sensor through SSL, but I modified the time by 17 hours and it still connected just fine. So that’s good, as I was worried when the Pi’s reboot or shut down for a bit, the time would drift without internet and you would be unable to configure it after that. I’m glad I was wrong!

Now the sensors are actually decently secure! With HTTP authentication and unique SSL generation per sensor, you can rest assured your commands and logins will not be ‘sniffed’ off the network.

One last thing I wanted to do is redirect any HTTP traffic to HTTPS, but I’m not sure how to make that happen with the webserver module I’m using in Python (gevent’s pywsgi).

I have now started to work on updating documentation since a lot has changed. Once that’s done, I’ll probably release another version.

On another note, I used chromes developer console to see the difference of page delivery sizes with gzip enabled. It really helped on the plotly graph’s, as it cut the download size to 1/4 and since they are usually about 4MBs, it makes a difference.

Tweaking Installer Scripts

Since the sensor software is working fairly well, I’m making sure the installer scripts are where they should be. I want to be able to flash Raspbian, download the installer script, run it and have everything just work. So to that end, I made the following changes.

To start, I added in the CLI commands to enable SPI and i2c in the installer script, along with the rfkill unblock wifi to enable wifi on the Pi Zeros (Didn’t seem necessary on the Pi3B+, just the country code allowed it to work). I have also added a function in the Enviro+ sensor module to enable the serial connection for the PSM5003, if it is enabled. The only downfall of the PSM5003 settings is the system has to reboot before it takes effect. So if you enable the PSM5003, you need to allow the program to start up, then reboot the system. It also leaves a warning message in the primary log to reboot.

Thanks to the above-mentioned additions, you can just flash a fresh Raspbian image, download and run the Sensor installer script and everything starts to work! If you have the desktop version of Raspbian installed, there is even a shortcut to the web config in the menu that points to localhost. If you use the lite version of Raspbian without a desktop, you’ll need to access the web configuration from another device (computer, phone, tablet, etc) through its actual IP address OR run the edit-config script locally (Although the script to edit configurations just opens the text files, so it’s not as nice as the web interface).

Development Updates

I have been spending some time working on the web interface for my sensors. I’m pretty happy with the configuration section now, which no longer has any text editors for updating the configuration, it is all web checkboxes, textboxes, radios, and buttons, which all have validation checks in place to make sure user entries are valid (for the most part).

I have also updated the underlying networking configuration to use dhcpcd.conf instead of interfaces. This has the advantage of being able to set static entries per network interface while allowing the use of any other installed adapters. AKA you can still plug in the Ethernet cord into the Pi3b+ for example and get a DHCP address, even if the wireless is configured with static entries. I had to remove the dual wireless network connections in wpa_supplicant.conf, as certain configurations would kill networking altogether, so… better safe than sorry. I might go back and figure it out later, but it’s not really necessary, so it’s on the back burner.

I fixed a few bugs, like the graphing showing incorrect datestamp correlations if a sensor was added later or disabled temporarily. This was caused by my attempt to re-use the datetime recording column for all sensors because they all use the same column, but if a sensor was added later, there would be a big NULL gap, so the first datetime columns would line up with the first actual data of a sensor column. To fix it, I grab the datetime column based on the presence of each sensor reading. Luckily it didn’t seem to add TOO much extra time to render the graphs.

I also added gzip page compression to Flask, which downs the page transfer sizes decently. This will help if I set up some 900Mhz long-distance transmitters since their data rates are not great.

Other changes in no particular order include

  • Refactoring aspects of the web interface, such as using HTML tabs to go through configurations and log entries (This makes it a lot easier to look over things quickly, instead of having to bounce back to the management page to choose another configuration or log.
  • Adjusted plotly graphs to use a dark theme
  • Created file for cached variables to lessen disk reads
  • Updated Ohms Gas resistance to K Ohms for easier human readability
  • Standardized HTML element colors
  • Added links to many sections to help explain what it is (Sensor readings, for example, take you to the Wiki page for what it is)
  • Other misc. refactoring and bug fixes

I’m getting closer to releasing a beta version, as a lot of the core parts are pretty stable. The networking was also problematic since it used to disable all other networks and was not easily adjustable. Now it works well and allows it to be configured in such a way that the device can still be used online in other ways besides being a sensor.

The web app is coming along nicely, which will eventually overtake the PC Control Center App (I pretty much just have to add the ability to manage multiple sensors from the web app).

That’s it for today’s update.

New Release Ver. Alpha.25.252

Another release! I actually released this one awhile ago, and am already on development version Alpha.26.140, of which I have changed a fair amount again but I should probably start by saying whats new in 25.252.

To start, I have been spending a fair amount of time researching and implementing CSS with a framework called “MUI“. It has some great looking functions to create buttons, tabs, dropdown menus, etc. I’m also slowly figuring out how to adjust multiple HTML components by using style to target classes, names, ids, etc. So that’s coming along nicely and the web interface looks a lot nicer thanks to it. I actually don’t have any sensors running the previous version, so I kinda forget a bunch of what I did, but I’m pretty sure I added a bunch of functions, such as updating to standard or development editions, edit configuration files, reboot/shutdown/restart services and view, download and even clear logs.

In my Development build, I have added the following in no particular order.

  1. New CSS side menu
  2. New Log Viewer page
  3. New Configuration adjustment page
  4. Ability to create and view Plotly graphs from the local sensor webpage
  5. Other visual adjustments, enhancements & bug fixes

I’m still working on improving the look, feel and functionality of the web interface and to that end I’ll be putting in an option for different themes since I know not everyone is a fan of the dark theme I have going.

Another thing I have been working on for a few days is getting the Particulate Matter and GAS sensors working properly for recording and it’s now working fairly well. Since the PM and GAS need to “warm-up”, I created threads to constantly pull data every second to keep it alive for more accurate recordings. It seems to be working and I’m now gathering Air Quality data for both inside my house and out. Unfortunately, I did not have it working in time to get readings before and after a good smoke session came through from local forest fires, but Its recording now for future events.

The last thing I’ll say, is I’m planning on adding a link to a demo unit on my website, so people can check it out without installing it (not that it’s hard to install if you have a raspberry pi).

Until next time!