Monthly Archives: September 2018 - Page 2

GitHub & PyCharm

I finally got around to trying out GitHub (Hello-World setup) and shortly after uploaded my “Network Testers” python program, which essentially turns 2x raspberry pi’s with a E-Ink display into a Ethernet cable / line tester.  The process went well and I like how GitHub tracks changes with side by side comparisons.   You can check out my GitHub account here. 
https://github.com/chad-ermacora

After doing GitHub, I went over to PyCharm and started watching the setup and basic operational video’s they posted on YouTube.  That also went quite well, and I like how it’s automatically helping me with a multitude of things! It seems to apply something similar to pycodestyle automatically in the code, which is fabulous!  It also organizes the multitude of files on the side, so it’s easy to go between different .py files in a project.  Those files can be opened in a split window, then grouped in tabs per split for multiple open files.  I only started going through PyCharm about an hour ago, so still lots to learn, but it’s already looking pretty sweet.  O did I mention it has a dark theme?  I LOVE dark themes, due to the long nights of coding in dark rooms.  

I don’t think it will be long before I post my Sensor Project into GitHub, since PyCharm can integrate with it.  I just need to figure out and test the integration with the hello world repository I created on GitHub, before I move my KootNet Sensors over, and start using PyCharm with it full time.  

I’m excited to be working on the future stability and accessibility of my projects.  

Until next time. 

Sensors Tested!

I have now tested and fixed bugs for all sensors, minus the Trigger ones (still need to re-write the code for that one).  I’m happy to say, that it looks good!  They all passed sensor get and database write tests.  I also added a “round_decimal_to” variable at the top of each sensor that can use it, so I have a consistent round to, and the ability to change per sensor.  One of the light sensors, recorded the Colour values for Red, Green, Blue to like 14 decimal points!  Would these decimal placements make a difference? I’m guessing not, since it was like 34.00000000000001 when they did show, but usually showed whole numbers like 34.  Anywho, the round_decimal_to is set at 3 for now, which should be a decent balance between useful information and background noise. 

I already like my new system for selecting installed sensors.  Its very nice to just open the config file and change a few 0’s to 1’s and 1’s to 0’s as I test different sensors on the Breakout Garden sensor board.  

I think that’s it for today.  Time to relax, then goto bed. 

Soo many modifications….

OK, just finished a big overhaul of the code running on the sensors themselves and tested it on the Enivro PHAT sensor (current primary sensor).  After a bit of fiddling, it works very well! It’s also much easier to figure out what’s going on in the code.  

The Installer script has been updated to set and work with all the sensors I have, and seamlessly works with the sensor to database code.  

That took the past 3 days with moderate poking.  However, I still have to convert the Motion database code, which I will be renaming to “Trigger” Database, as its much more accurate to what it captures.  Updating the trigger database code will probably take longer because I have to add new types of sensors to it.  Right now, I’m only capturing acceleration, but I have to add the following sensors (to start) GAS resistance, gyroscope and Distance.  Not to mention I need to figure out what variance to set for the triggers themselves.  

Not much progress on actual new features, but I have started to make a features to do list, which can be accessed here.  It helps remind me of where the project is going, in case I get caught up in the smaller details. 

I think I’m going to continue on my “Clean Code” book, as it is really setting the stage for easier management BEFORE my code gets too large to want to clean.  I also have a surprising amount of files to get this all working, so I’ll be working towards putting the code on GitHub, to more easily manage things when I need to change different sections that might affect others.  

I suppose that’s it for now.  It’s still smokey here, but not AS bad as before.  Hopefully things will clear up in a few weeks.  

Adding Sensor Support

I decided to get more hardware support for different Sensors going.  In the process, I’m cleaning up and enhancing the sensor and database code.  This will allow recording of ONLY what sensors are present, so there’s no big list of “N/A” for things not there, just null columns.  

I think I have added / modified all the compatible sensors that I have, which include the Raspberry Pi Sense hat, and the following, that are all Pimoroni brand Sensors;  bh1745 (Light), BME680 (Temp, Pressure, Humidity and gas resistance), Enviro hat (temp, pressure, light, magnetometer, accelerometer), LSM303D (magnetometer, accelerometer), VL53L1X (Distance sensor /w lasers). 

Now to modify the SQL writer to work with them.  Although, I’m going to take a little time to rethink how it determines which sensors are available, as I would like to cut down on the amount of code needed to identify said available sensors… Not to mention make it simpler to understand and modify. 

30 min later …. 

I think I got it!  create a new line per sensor in the “Sensors installed” file, have a number as the first char, such as 0 = not installed, 1 = installed.  Then after that, put the name of the sensor, as it would only look at the line’s first char to check.

Example.
# The first char is 0 for disabled and 1 for enabled
0 = Pimoroni BME680
1 = Pimoroni Enviro
0 = Pimoroni bh1745
0 = etc.

This way, it’s easy to modify if you open the config up, as the names right there with simple instructions.  hmm… yeah I think that will do nicely. Time to work that into the installer script.