Monthly Archives: July 2018

Converting my Code to a WebApp

I'm converting my program to a webpage!  Using Python + Django.

Since I'm a Network Admin, I know keeping programs up to date can be annoying.  A Web app on the other hand, can be updated once and its everywhere!  Not to mention the compatibility of just needing a new'ish web browswer to run the thing.  

Well, here it is after about 4 days, learning what I needed, how to use what I needed and actually making the program.  Here's a screen shot.

WebApp1

I have it displaying multiple sensors, which the readings get updated every time you goto the page. Most of it is self explainitory, although the funny dashes and colour after "Colour: ", is the actual colour representation of the RGB light sensor.  

Now I have to bring over the other stuff like updating sensors, rebooting devices and downloading the longer term sensor logs.  

 

 

 

Using Python3 to collect and manipulate SenseHAT Sensor data

So, as I said in my last post, I want to digitize the world around me, starting with the sensors on my Raspberry Pi 3B+ and SenseHAT attachment.  

After much thinking, writing down ideas and generally trying things out, I finally got things working the way I wanted for the most part.  Here's what I have so far.

1.  Sensor Units: These are the Pi's with the SenseHAT and have the following programs running to enable the features I want (Only the HTTP server is not done by me, I just installed one). 

  • Sensor Readings to File: A simple program that reads "all" the sensors and writes the results as a string, each value separated by a ",". It creates one line each time its run.  It auto runs every 5 min through cron (Linux scheduler).  You could also do something similar with Windows "Task Scheduler".
  • HTTP Server:  The HTTP server just lists and allows downloads of the sensor data files. 
  • SenseHAT Joystick Controls: A small program auto runs with the pi and allows you to use the 5 "button" joystick to run commands and display info on the 8×8 LED grid.  It currently does the following, which helps a great deal when there is nothing attached but the SenseHAT and power.  I also have VNC / SSH enabled on the Pi's to connect remotely.  
    • 1. Display IP
    • 2. Display CPU Temp
    • 3. Display SenseHAT Temp
    • 4. Shutdown
  • Sensor Data over WiFi: Another small program runs automatically and listens on the network for my client app to request data.  

2.  Portable Sensor Data Display and File Downloader:  This is a PI with a 2.7" E-Ink display with 4 buttons.  It simply runs one program on boot to do the following.

  • Show it's own system information, including IP
  • Display Current Sensor Readings
  • Download Sensor Data Files
  • Shutdown

3.  PC: I made a more in depth GUI app for the PC, that can connect remotely to the units to gather information.  It has a lot more options, and is a bit easier to show a picture. 

Its still a work in progress, but as you can see, I can already compare Sensor readings over time.  I can also specify how many entries to skip when graphing the data files, as there should be about 288 entries for a day, after which, the program creates a new file for that day.  Plotting 288 points can not only take a bit of resources, but also isn't needed for most things being looked at. So I set it at 12 by default, so it shows a reading every hour.  

All these separate systems, apps and scripts connect through a mini router I got for $35 that's powered by USB.  This enables me to take the E-Ink pi and the mini router, power them both up off a USB battery Bank and wait about 2 min for the Units to boot and the Sensor Units to auto connect to WiFi, and I can then pull data remotely from the units, up to however far the router's and pi's range are (50-100 meters?).  Great for putting Sensors on tree's, in water, down a hole, etc, etc.  

I also enabled a OpenVPN server on the router itself, allowing me to connect through the internet and grab the sensor data with my PC program.  This can be done, even from remote sites through 3G or 4G connectivity (AKA cell phone service). Simply add a USB dongle for 3G / 4G to the router, and BAM, I can suddenly connect a lot of units, within a decent range to the internet for remote monitoring and maintenance!  

That's pretty much were I am at now.  I'm also working on other aspects like Pi Cases for weather proofing or even water and underwater deployment.  High altitude balloons are also in the future.  

I think that about does it for this post.  I'll eventually post my Python code too, but I wanted to clean it up and add some comments to explain things first (being my first Python project and all). 

 

 

A Raspberry Pi 3B+ Python Project!

I now have a use for this domain 🙂  My Python + Raspberry Pi development. 

So, about a month ago, I got a few raspberry pi 3B+ with 2x senseHAT's.  Long story short, the senseHAT is an attachment that is loaded with sensors, a 5 'button' joystick and 8×8 LED grid.  By making your own programs, you can access the hardware and get readings or have the LED's light up in any way you like, including animations.  

The raspberry pi peaked my interest for a few reasons.  

1.  They are pretty cheap at about $50 Canadian.

2.  They are small and power efficient.  AKA I can power them for a long time (few days) off a USB battery bank.  

3.  Decent support to help learn programming.  Check out their website www.raspberrypi.org

However, I was more interested in what kind of environmental data I could digitize through the sensors.  AKA more accurate local weather type information.  Before I could start however, I needed to think of how I could get and store information from the sensors and ways I could manipulate that data to find cool patterns (like when its the coldest time of day, and how and when that changes over days, months, years, etc).  

I have tried a few times to learn programing (C++, Java), but ultimately failed the self taught way, due to a lack of direction to assist with learning (AKA motivation).  But now, for about $150, I can get the pi + senseHAT to do a lot! 

I have actually come pretty far already considering I only got them a month ago, but I'll post about that later.  

This site will be active! 

w00t!