Home automation

Showroom for MicroPython related hardware projects.
Target audience: Users wanting to show off their project!
Post Reply
fendell
Posts: 2
Joined: Sun Apr 05, 2015 6:55 pm

Home automation

Post by fendell » Thu Apr 09, 2015 4:17 pm

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

mikewop
Posts: 3
Joined: Mon Feb 02, 2015 2:21 am

Re: Home automation

Post by mikewop » Thu Apr 16, 2015 4:52 am

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

Online
User avatar
pythoncoder
Posts: 3613
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Home automation

Post by pythoncoder » Thu Apr 16, 2015 4:45 pm

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.
Peter Hinch

fendell
Posts: 2
Joined: Sun Apr 05, 2015 6:55 pm

Re: Home automation

Post by fendell » Sat Apr 18, 2015 2:00 pm

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

Jessiryan
Posts: 1
Joined: Tue Jul 09, 2019 8:50 am
Location: Sterling
Contact:

Re: Home automation

Post by Jessiryan » Tue Jul 09, 2019 8:59 am

Hey the Github link you have provided is not valid. Could you please verify the link again please?

Online
User avatar
pythoncoder
Posts: 3613
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Home automation

Post by pythoncoder » Wed Jul 10, 2019 11:20 am

The github reference from @mikewop works fine here, but the openmicros.org domain is a 404.
Peter Hinch

Post Reply