Page 1 of 1

Home automation

Posted: Thu Apr 09, 2015 4:17 pm
by fendell
Hello,
Started a project of building some kind of home automation, the part I’m starting with is to control my pellets burner with the pyboard.
The pyboard will take care of the burning process and keeping the burner running with new pellets. Then I want to send all the values
to my Raspberry pi over serial that will send to my phone using socket and on the phone i will have kiwi for managing the set values and
the actual values for the burner.

How would you send many different values over serial? (Just curious for suggestions)
My first thought is combining all values in a string with a separator char to tell what values to go into the right variable.

Here is my repo with what i got so far:
https://github.com/Fendell/homeAutomation

Any suggestions or critique on my coding is appreciated

Best Regards Lars Fendell

Re: Home automation

Posted: Thu Apr 16, 2015 4:52 am
by mikewop
Hi fendell,

The answer to your question probably is "it depends" :).
There are many different serial protocols already defined that all serve specific purposes, and of course you can always create your own.
If you only ever want to communicate between pyBoard and RPi, you could use just any string format

If you want something more generic or extensible that scales to multiple sensors and/or actuators take a look here:
http://openmicros.org/index.php/article ... -reference

Then there is also firmata from the Arduino-world, someone seems to have started porting this to micropython:
https://github.com/Neon22/micropython-firmata



Hope that helps,
Mike

Re: Home automation

Posted: Thu Apr 16, 2015 4:45 pm
by pythoncoder
Re sending values over a serial link one way is as follows. Put the various values into a Python object of your choosing, say a list or a dictionary or an instance of a class of your own design. You can then use the Python repr() function to convert the object instance to a string. This can be sent over a serial link. When it's received you re-create the original object using eval(the_string). e.g.

Code: Select all

>>> a = 23.2
>>> b = -17.5
>>> c = "hello"
>>> d = {1:a, 2:b, 3:c}
>>> s = repr(d)
>>> s
"{1: 23.2, 2: -17.5, 3: 'hello'}"
>>> g = eval(s) # At the receiver
>>> g
{1: 23.2, 2: -17.5, 3: 'hello'}
>>> g[2]
-17.5
>>> 
This assumes that your transmission link is reliable. If there is a chance that data might be corrupted in transmission, or if the receiver might be switched on in mid message, you start to enter the world of communication protocols. A big topic.

Re: Home automation

Posted: Sat Apr 18, 2015 2:00 pm
by fendell
pythoncoder wrote:Re sending values over a serial link one way is as follows. Put the various values into a Python object of your choosing, say a list or a dictionary or an instance of a class of your own design. You can then use the Python repr() function to convert the object instance to a string. This can be sent over a serial link. When it's received you re-create the original object using eval(the_string). e.g.

Code: Select all

>>> a = 23.2
>>> b = -17.5
>>> c = "hello"
>>> d = {1:a, 2:b, 3:c}
>>> s = repr(d)
>>> s
"{1: 23.2, 2: -17.5, 3: 'hello'}"
>>> g = eval(s) # At the receiver
>>> g
{1: 23.2, 2: -17.5, 3: 'hello'}
>>> g[2]
-17.5
>>> 
This assumes that your transmission link is reliable. If there is a chance that data might be corrupted in transmission, or if the receiver might be switched on in mid message, you start to enter the world of communication protocols. A big topic.

yes this was in the way i was thinking, I’ll try this out. Thanks

Re: Home automation

Posted: Tue Jul 09, 2019 8:59 am
by Jessiryan
Hey the Github link you have provided is not valid. Could you please verify the link again please?

Re: Home automation

Posted: Wed Jul 10, 2019 11:20 am
by pythoncoder
The github reference from @mikewop works fine here, but the openmicros.org domain is a 404.