You will need to edit the lib_location on common.py in the /usr/local/lib/python2.7/dist-packages/snap7/ directoryAdd a line in the __init__ part of the Snap7Library class:lib_location='/usr/local/lib/libsnap7.so' example below:

Tuesday, August 26, 2014

As part of a future project I may be working on(details coming soon). I wanted to get some logging done with some temperature sensors to the online cloud database called Parse.com
If you want your data stored on the cloud to be able to access anywhere this is what you will need to do:

With much trial and error I was able to get a simple serial communication with it through a ttl usb cable. I then wanted to control the I/O remotely. This device can be polled for status and controlled through tcp messages from your Android/iOS device and Raspberry Pi

Whenever these inputs are pressed it will toggle the relays locally. The pushbuttons would be connected to the right side of the Wifi Module. Giving you remote and local control of your device without having to put an Arduino or Raspberry Pi in that enclosure.
For me I like knowing instantly whether my light is on while looking at it remotely. The PlugPoller python script is polling statuses every tenth of a second. The MCU and the module talk at 115k baud so you can get your results pretty quickly.

Since that looked pretty ugly (prototype), i'm currently working with the LPC811 which has more I/O. 14 configurable pins, 2 of which I will use for UART communication (12 for I/O pins) which will let you sense more inputs and turn on more outputs. These chips can have some of these pins configured for i2c and spi that can connect you to 100s of sensors that you can have through wifi.

Please Comment if you wish to see this as a kit you could buyOr if you have questions

Monday, July 7, 2014

Since finding a cheap alternative to PLC whilst using an industrial protocol is a popular idea the Raspberry Pi has caught many eyes on doing this. I posted once on reading a temperature sensor and serving it up on the Pi using ModbusTCP. This time I expound on it and show you how to control something. In this case it will be a PC 12v fan.

Monday, February 24, 2014

Dallas has a couple 1-Wire I/O chips out there. I decided to test the one that seemed practical to replace a light switch or plug. The DS2413 was almost perfect. It has 2 I/O, gets power from the data line, and Adafruit made it easy for me to test by making the breakout board.

With these I created a demo to see the read and write speeds through the 1-wire data line.
Source code for benchmark:

As you can see the performance dropped more than half every time I pressed the button. Not bad if all I care about is whether the light turns on right when I press the button, and it would.
I then ran the loop to see how fast it would go at turning on and off the relay and saw an average of 20.833 requests per second. (Don't worry, the relay wasn't able to click on and off that fast)

Adding a DS18B20 Temperature sensor and requesting it every second I found that when the temperature was requested the requests per second dropped down to 1.950 requests per second and then jumped back up to the 42.27 range until the next second came along.

Requesting the temperature every loop cycle was unworkable. I had to hold my finger on the button far longer than desired to get the relay to turn on. I tuned it up by requesting the lesser accurate temperature value "fasttemp". I also requested it less often (every other second).

t=ow.Sensor('/28.B0A534050000')t.useCache(False)print t.fasttemp

The DS2413 datasheet mentions the ability for Overdrive (~10x the communication speed) but I was unsuccessful on getting it to work. The communication would seize when I tried enabling it on the bus.

Conclusion:
Controlling your lights with the DS2413 is possible, but you are limited on the quantity of chips on the same bus line. If you are able to get the chip's Overdrive feature working then I would suggest getting the 8-port i2c to 1-wire add-on board if you have plans for your whole house.

I'm going to test the DS2408 (8 port 1-Wire I/O chip) soon and am a little more hopeful since you can control multiple rooms and/or lights with one chip.