128 A&C: MIC     -     Meh In Charge .com (128.html)

Keywords: A&C MIC, Raspberry Pi, i2c, python, TMP102, PiR2, sensor, controller, home, area, inexpensive, iPhone, Google Home, Google Nest, MehInCharge.com, Meh In Charge, Me In Charge, RDC, Prime Intertec Smart plug

MehInCharge.com (MIC) is a website created by the author to control various devices in a person's home (or homes). This is inexpensively accomplished by installing, in various areas, a very low-cost Raspberry Pi computer (eg $35) with some inexpensive sensor and control devices attached to each of them. This results in little or no wiring and no monthly costs. The MIC website coordinates these multiple PiR2 controlled devices. The name of the website is a variant of the expression "Me In Charge". One of the main uses of the MIC website is to ensure that a person's iPhone is being charged each night while the peron is sleeping. A user of the MIC website usually has at least one Raspberry Pi computer, 1 PiR2 controller and a cell-phone. Each PiR2 controller is attached to a Raspberry Pi computer with the goal of controlling various sensors and control devices that are located in the area near the Pi computer. Each PiR2 controller can read values from nearby sensors such as:

a) the ambient temperature or
b) the current (amperage) being provided by an internal usb-charger to charge a personal device or
c) the ambient light

Each PiR2 controller can also make some adjustments to its environment by turning on or off one or more devices connected to the controller.

Each user of the MehInCharge.com website signs in with his/her user-id and password. Once signed in, the user can view the range of readings and control actions done by the PiR2 controller. The user can also send various control signals to one or more of his/her PiR2 controllers. A user can have Pi computers located in various geographic locations such as a main home and/or a chalet or a cottage. Each location is assigned a name and can contain 1 or more Raspberry Pi computers with a PiR2 controller usually attached to each Raspberry Pi computer.

The intent is to give the owner of a Raspberry Pi an inexpensive way to control his/her household. The PiR2 controller is also intended to permit control of a nearby Google Home or Nest device by recorded audio commands.

(To enlarge .....Click it)
thumb: The Raspberry Pi 3 with WiFi
The Raspberry Pi 3 with WiFi



The PiR2 controller is designed to use the i2c bus to communicate with most sensors.

The PiR2 Controller

(To enlarge .....Click it)
thumb: IMG_4569.JPG
IMG_4569.JPG



Each PiR2 controller (PiR2A prototype shown above) is attached to a single Raspberry Pi computer. The PiR2A's header pins (far left) are connected via a ribbon cable to the GPIO pins of any model of Raspberry Pi computer. The PiR2 controller is controlled by a main logging program that can constantly read data from its various sensors. The PiR2 controller can also control some devices with the goal of maintaining the environment in the area near the Raspberry Pi computer. The author expects that one PiR2 controller might exist in each of many rooms in a user's house: e.g. Bedroom, Kitchen or Basement. A home-owner might want the PiR2 to turn on the natural gas fireplace if the ambient temperature falls 10 degrees below a certain indoor temperature. The intent would probably be that the PiR2 would keep the house from freezing if the furnace fails. Another home-owner might wish that the PiR2 notify the owner by text (and/or an alarm bell) if his/her cell phone is not being charged any night when it is 1:00 am. Another home-owner might wish that a camera take a photo when motion is detected in the front yard. (Commercial systems can be purchased to do these things, but all commercial systems are expensive and often require a monthly payment.) Each PiR2 should be connected to the outside world via an Internet connection from the Raspberry Pi. This is normally done using an existing router with wifi and/or ethernet cables.

Because the Raspberry Pi is inexpensive (around $35) many of them can be used at each location. Inexpensive sensing devices (eg a temperature sensor) and controlled devices (eg a fan, a lamp or text mail) can be managed by the PiR2 controller. These devices can all be linked to the MIC website at no charge.

The PiR2 controller is intended to communicate with most ioDevices using the i2c bus. To date, the TMP102 temperature sensor (by ti: Texas Instruments) has been implemented on the i2c bus. The PiR2 controller software is written completely in the Python language. Some of the sources listed later explain more about Python. Python has many built-in functions; they are listed next:

Python's Built-in Functions

Python has many built-in functions that are always available. The photo below is a complete list of functions that accompany Python 3 as of 2020 D Apr 27:

(To enlarge .....Click it)

thumb: Python_Built-in_Functions.jpg
Python_Built-in_Functions.jpg



A person who is using Python as a programming language should review each of these functions. The concept of Class in Python is described about 90% through the youtube video in Source 04 below. A little later the same video explains the concept of Inheritance for a class. This video was created in 2018 so its details might be a little out of date.

MehInCharge.com (MIC) website

(To enlarge .....Click it)
thumb: The MehInCharge.com website
The MehInCharge.com website



The MehInCharge.com (MIC) website is a free website available to owners of a PiR2 controller. More information exists at the MIC site, itself. (To learn more, click on the buttons below the "_ABOUT_" word in the top-right corner of the website. Each PiR2 controller is attached to a Raspberry Pi computer that has access to the Internet from time to time. PiR2 software has been written to run on the Raspberry Pi. This software can communicate with various inexpensive electronic sensors and controllers via the PiR2 controller. This software can also communicate with the MIC website. The PiR2 software is used to log the data that is read from the PiR2 sensors and to send these log files to the MIC server. The PiR2 software can also control its environment. Such controls can be initiated from the MIC website, from the PiR2 controller itself, via email (future), from the owner of the PiR2 each time it starts up or from the software Control Panel of the PiR2 controller while it is running.

The logged data at the MIC website includes all the readings from the sensors and all the control actions that have been done. When signed onto the MIC website, the user can view all of the data that has been logged in its most raw form. Or . . . . on the MIC site, the user can view plotted graphs of various collections of data that has been logged.

Each owner of a PiR2 controller can view only his own data, because it is all password protected.

PiR2 ioDevices

The list of input/output Devices currently (as of 2019HAug 16) connected to the latest prototype of the PiR2 controller (complete with operational software) is:


The Raspberry Pi computer

The tiny inexpensive Raspberry Pi computer is available in various recent models, the Pi 2, the Pi 3B and the Pi 4B. The faster Pi 4B that was released in June 2019 has not yet been tested but is presumed to function very well. Each year a new model of Raspberry Pi computer is released (often around Feb 28). The price of each Raspberry Pi 4B with 1 Gigabyte of memory was approximately $35. The Pi 4B can be purchased with 1Gb, 2Gb or 4Gb of memory. In 2020, the price of the Pi 4B with 2Gb of memory was reduced to US$35. (But more memory costs more money). Each Raspberry Pi computer runs the Python programming language in addition to various other languages. The PiR2 software has been completely written solely in Python. Contact the WebMaster (below) for more information.

The PiR2/MIC software

The PiR2/MIC software was written by the WebMaster in 2019. One MehInCharge and two PiR2 modules exist:

a) pir2main.py
This software module communicates with all of the sensing and control devices via the PiR2 controller. This module communicates with the MehInCharge.com website (via the Internet) and with the PiR2 control panel (via files stored on the Raspberry Pi). It logs all of the readings and controls all the devices attached to the Raspberry Pi.

b) PiR2 Conotrol Panel
This software module (panelGUI.py) communicates with the user of the Raspberry Pi and with the PiR2 controller. This module provides a small number of pages on its control panel. Each page of the control panel is updated dynamically by the main PiR2 controller software. Control Panel updates are normally done at 10 second intervals. The user of the Raspberry Pi has direct access to both the Pi computer and the PiR2 controller devices. This user can use the Raspberry Pi to simultaneously view and operate all three software modules: the logging program (pir2main.py), the control program (pir2panel.py) and the MehInCharge.com website. All three modules can function in unattended mode (when no user is present). Updates occur when requested by the user.

The PiR2 Control Panel (which can be modified by the user) displays three types of sense & control data:
  1. Control Loops
  2. Current Data Readings
  3. Triggered Actions
c) MehInCharge.com
This software module communicates with the user via the internet (using any Internet devices eg tablet, cell phone, iPod, computer etc). It communicates with the Raspberry Pi computer via the Internet. This software is written in HTML and PHP.

Remote Desktop Connection

The Raspberry Pi computer (and the PiR2 controller) can be operated remotely from a laptop connected to the same router as the Raspberry Pi. The laptop can be running Windows-10 or Linux. On Windows-10, the Microsoft Remote Desktop Connection ( RDC ) software can be used to operate the Raspberry Pi remotely. When in this mode, the Raspberry Pi does not need a TV monitor nor a mouse nor a keyboard. In this mode, the Raspberry Pi software modules can be started up and run remotely from the laptop. Note that of all the software described herein is currently free, the only non-free software is Windows-10 itself. All Raspberry Pi software mentioned is free.

More Information

For more information, simply go the MIC website where only the author's data can be viewed (without a password). There are no restrictions on the viewing of the author's data. To see the PiR2 controller software in action, a person must have a Raspberry Pi computer. To get a copy of the current software for the PiR2 system, please contact the WebMaster below. This software will run on a Raspberry Pi computer even if no PiR2 controller is connected. In fact, the PiR2 software can even repeatedly log the temperature of the Pi processor when no PiR2 controller is present. If the Raspberry Pi computer is connected to the Internet, the owner of the Pi computer can send all logged data to the MIC website. To do this, the owner of the Raspberry Pi computer must receive the PiR2 software and a password from the WebMaster.

A list of many FAQ (Frequently Asked Questions) is displayed with answers when the Help button is clicked on the menu sublist titled "About". This sublist appears at the top of the right-most frame of the MehInCharge.com website.

Source 03 is an (up to date as of 2020 D Apr 13) description of the PiR2 CONTROLLER developed by David Cole. It is in PDF format so that it can be read using a maximum number of personal devices.

Note to Self: Today (2020 D Apr 13) I uploaded a zip file (named E.zip) containing the Desktop folder and the files in Home/pi into the 128 directory of this article. FileZilla can be used to download this backup of the PIR2 CONTROLLER programs.

References

Books/Newspapers

Books/Newspapers 1: none

Web Sources

Web Source S128:01: w3 Schools IS reference Date: 2019 B Feb 13
Web Source S128:02: IT: Python - A Popular Programming Language (132.html) Date: 2019 J Oct 22
Web Source S128:03: PIR2 CONTROLLER FUNCTIONALITY V8 Date: 2020 D Apr 27 by David@CC
Web Source S128:04: YouTube 4h Python Programming Course at freecodecamp.org by Mike Dane of Giraffe Academy, Discovered on Date: 2020 D Apr 27
Web Source S128:05: Python Standard Library Discovered on Date: 2020 D Apr 27


WebMaster: Ye Old King Cole

Click here to return to ePC Articles by Old King Cole

Updated 2021 D Apr 16
Created 2023 H Aug 06
(c) ICH180RR Corp.

/128.html