Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

20 May, 2017

GY-MCU90614-BCC Serial IR Non-contact Module: Python code

It seems that this variant of the module, with serial interface, is not that popular or at least I could not find code that I can easily port to Raspberry Pi. One can find a Windows program that prints the values from the serial port but that is all.
Anyway, I found description of the protocol on several pages, and it looked doable. Later, I found an Arduino example code, which could have helped, but...  I start programming before I had the module, which explains the reason why I first convert the characters to hex and then decode... This way is easier to debug it... So, here is the Python code (at the end of the post) that tests the checksum, decodes and prints the values to the standard output. (by the way, I still do not know how to get negative values for the temperature...)

Example output:
$ ./IRserial.py
TO: 21.36   TA: 24.04
TO: 21.36   TA: 24.04
TO: 21.36   TA: 24.04
TO: 21.57   TA: 24.04
TO: 21.57   TA: 24.04
TO: 21.57   TA: 24.04
TO: 21.57   TA: 24.08
TO: 21.57   TA: 24.08
TO: 21.57   TA: 24.08

04 February, 2017

BroadLink SP3 SPcc Contros Mini WiFi Smart Home Socket

Ok, this guy has enough reviews and videos on the Net and pretty much all of them are positive.
And these are my few lines of wisdom on the subject.


Pros:
  • Good build quality, size, look, and feel.
  • Relatively easy to configure and upgrade the firmware with the Android app.
  • Two-way communication - you get the current state of the switch even after manual toggle.
  • Fast to connect to WiFi and with good range.
  • The Android app is good enough and has CloudBackup/Sync, so one can easily clone the setup on multiple devices.
Cons:
  • Lack of official support for desktop platforms, more importantly - Linux.
    I have found an alternative solution to this, read more below
  • The device will be alive as long as BroadLink's servers run as every proprietary protocol. 

28 October, 2013

Home automation: second round

Some time ago I briefly mentioned here the main concepts behind the project. Nothing has changed dramatically, except that I realized that my SMSgate solution was outdated. The phone battery was seriously deteriorated and I also realized that it is not that easy to just replace the phone anymore.

Well, I had an old Android phone (HTC Wildfire) that was essentially lying unused for quite some time. There is not so much that one can do with this old phone... but it turned out it works just perfectly to send and receive SMS and much more.

If you are in the "business" of home automation and you have Android device, Tasker is a MUST HAVE! To send and receive SMS messages I use SMS Gateway (I could not find an easy way to send SMS from external device via Tasker).


Briefly: I have changed the original python code to send SMS via SMS Gateway via HTTP GET request from RPi and then I have slightly modified the example, so I can control stuff by SMS. It is very clean and simple solution.

Now, since I have web server on which I get the notifications from the SMS Gateway I can simply use the same code to handle events from Tasker! This is how I get notifications on call - piece of cake. I have added, at the end of the post, an example how to switch on/off device 2 via tdtool.

24 June, 2013

Home automation: Raspberry Pi + Tellstick Duo ++

There are many sites that has this project in many flavors... I will just add mine.

Brief summary: Tellstick Duo is connected to Rasberry Pi (running Raspbian).  I have SE K700i GSM phone connected to RPi as well. The main features are:
  • control several radio controlled switches (Anslut)
  • monitor temperature and humidity from my wireless weather station
  • monitor for "door open event" (NEXA LMST-606)
  • monitor for commands send by SMS (gammu) Update: replaced by Android SMS Gateway. Read more...
  • report on selected events by sending SMS to predefined phone number (gammu)
  • simple web interface to control some of the features (apache + php)
  • events are logged locally in to a file and to a remote server (own twitter like)
To install telldus-core follow this guide. One can compile the GUI for RPi or use it on another computer to set the codes. I wanted to be able to repeat the original codes from the remote controls. Advanced users can use code from the examples to "learn" the codes.

Essentially, I am running a monitoring program written in python (took one of the provided examples and changed it severely). It catches signals from the remote controls and could trigger an action. In other words, I can use the remote controls to send signals to RPi. The same program monitors the GSM. It could trigger an action upon CALL or SMS. The signal from the door is logged by default but could also send an SMS - poor man's home security alarm.

I particularly like the CALL feature since you do not need to answer the call, so no cost attached. The downside is that there is only one action hooked to this event. SMS is easier but will cost you (or not - depends on the plan you have). When SMS is received from another phone (not mine) the SMS is logged and forwarded to my phone.