Close

Progress to date

A project log for Raspberry Pi Sensor Network

A scalable, expandable home monitoring system designed for ease of use.

staticdet5staticdet5 02/19/2016 at 22:540 Comments

The code up on GitHub works... Kinda. The multi-threading is definitely broken.

Currently, the system is started up using two terminal windows (I'm running the Pi's headless, over TightVNC). The first window is opened, and test.py is run. All this does is turn on the logging routines. When data is received, you'll see the Python dictionary displayed in this window.
The second window runs Node.py. This is the "meat" of the system. When the program is first run, it will ask for the logging IP, and then a series of questions based upon the sensors that the Node is recognizing. Once that is done, the Node (is supposed to) start a thread for each sensor. Each thread continuously polls the sensor, as quickly as possible, and kicks out sensor data when it meets criteria (too hot or too cold, for the BMP180 thermal sensor, and once a minute for all the other sensors). Right now, that's the whole thing.
A ton of effort was put into the auto-configuration of the Node. The system currently runs an i2cdetect and pulls out the answering I2C addresses. If new addresses are detected, the user is prompted to identify the sensor, which is then saved in the configuration file. The same is going to be possible for DS18B20 thermal sensors because each of them carries a unique identifier.
Data is reported as a Python dictionary, and then "Pickled", a method for serializing objects in Python. The data reporting may change in the future, but is currently preferred because of the ability to identify values easily, and not have to deal with maintaining sequencing in the data stream. This allows one section of the program stack (IE: a sensor object) to create a report, and pass it off to the next step (IE: the node) which then appends some more data, before sending it over the network where it is received, and the receiving Node can append more data to the dictionary (Examples: Nodes can have sensors. Nodes can also store data in memory. Ideally, a sensor is being run in its own thread. When a sensor thread kicks out a data point (or more), the Node takes the data, appends the time, the name of the node, and the IP address. The Node Pickles the data dictionary before it sends it down the network to the memory Node (Currently, one node is doing all of these functions). When the receiving Node gets the data, it unPickles it, appends a receive time (this seems like a good idea right now), and saves the data to disk.

Currently, multi-threading isn't working. I can't get any thread but the BMP180 thermal sensor to run correctly. A fair amount of troubleshooting went in to this before the holidays, and I'm going to have to pick this up again. I had it running initially, but I completely screwed up my object instantiation, so my objects (sensor threads) were crosstalking and polluting each other's "short term memories".

I need to develop a graceful check for the logging Node. Right now, if the Node starts up and attempts to send data to an incorrect IP, the system suffers a full-stop error. Eventually, I'd like the Node to have a way of automagically looking at the local network and finding the local memory node. Failing that, I would like the Node to save sensor data locally, until a memory node is identified. There's also the possibility of always saving data locally, and sending reports (when possible) to a main memory Node.

I'm working on using GitHub. I'm very new at it, so there's going to be some starts and stops. I've got the basics down, when I consult a cheat sheet... I'll work on that. And code commenting. My coding is a mess.

Discussions