Page 1 of 1

New input mode for homebrew station?

Posted: Mon 07 Sep 2015 8:07 am
by LA1HSA
Hi all,

I've been a lurker here for some time and I've been using Cumuls MX on a Pi together with a Fine Offset station. Big success so far and I'm thankful for all the work steve put into this! It does the job without any major issues, although my Fine Offset is another matter.

I can't say that I've seen other threads about this, but I have tried to search for it. On my own wishlist, I'd love to have an input to Cumulux MX that supports basic clear text serial data, probably CSV or something that is easy to manage and send from a microcontroller. Why? As I'd love to modify my own homebrew station to be able to talk to Cumulus without having to implement the Davis protocol.

My own station is based on several MCUs (AVR) and will gather and display data on my own console, not too different from Weatherduino, but incorporates a lot of extra sensors for indoor climate control and future outside sensors. I can imagine that more people would be able to make their own station if they could export their data in a more common format, at least I do :)

So steve; I'm not sure how hard it would be to implement this? I don't think it would require too much effort compared to the Davis and Fine Offset protocols, as you wouldn't have to all the magic with the data coming in. You're the programmer here, so this is just my impression of how things are done.

I'm really sorry if this has been asked before, I just couldn't find anything about it. Anyway, thanks a lot for Cumulus MX :D

Re: New input mode for homebrew station?

Posted: Mon 07 Sep 2015 8:15 am
by steve
What other people have done quite successfully is to generate a file in easyweather.dat format. Cumulus repeatedly reads the last (or only) line in the file, watching for the timestamp changing, then uses the new data as input. This is described in the wiki - http://wiki.sandaysoft.com/a/EasyWeather_Format

Re: New input mode for homebrew station?

Posted: Mon 07 Sep 2015 9:17 am
by LA1HSA
Thank you steve, that is of course a way to do it. Have thought of using it, but it limits me to only use data that Fine Offset normally provides (no "extra sensors" in Cumulus).

I can use that approach until I manage to put out some Davis data so I can get soil temp, moisture etc.

Re: New input mode for homebrew station?

Posted: Mon 21 Sep 2015 8:35 am
by LA1HSA
So, I've been trying to fight the Davis protocol for some time now, but it seems I need to study it some more, not getting the proper results yet.

Meanwhile, I could try to use the Easyweather.dat approach so I at least get some data flowing. What I need to do to get that working, is saving serial input on the Pi to that file, but unfortunately I can't find any way of doing that unless I program it myself. I'm not into Python or any other way of programming on Linux (yet), so I wonder if anyone can give me a hint or help me out how I should approach this. I made an app for this on Windows (.NET) which works perfectly, but it would be hard getting that to run on Linux, especially when there's no running X-server on it.

What I need it to do:
A program running all the time (manually started), waiting for a string on /dev/ttyUSB0 and saves that string to Easyweather.dat, deleting/overwriting the old contents.

It should be simple, but I'm pretty clueless when it comes to Python.

Any help would be greatly appreciated :)

Re: New input mode for homebrew station?

Posted: Mon 21 Sep 2015 8:45 am
by steve
Won't your .NET app run under mono?

Re: New input mode for homebrew station?

Posted: Mon 21 Sep 2015 8:52 am
by LA1HSA
Unfortunately not, as it's a form and I have no way of displaying a form on a text-only console.

Re: New input mode for homebrew station?

Posted: Tue 22 Sep 2015 6:32 am
by LA1HSA
I had to tinker a bit with Python so this could be done. It was actually quite easy and it works just fine with Cumulus now. Examples and manuals I found on the net helped me a lot.

Posting the script here if anyone happens to be in the same situation as me:
Note: This may be awful code for anyone who knows Python, but this is my first attempt, so please don't hang me ;)

Code: Select all

import serial

con = False

port='/dev/ttyAMA0'

try:
    print "Connecting to ",port
    ser = serial.Serial(port, 19200)
except:
    print "Could not connect to ",port

## Waiting for connection
while not con:
    serin = ser.read()
    con = True

## Save incoming data to this file    
weatherdata = open("Easyweather.dat", 'w')

## Data is available and will be saved to file
## Note: For my purpose I will only have one single line of data in the file at all times
while 1:
    if ser.inWaiting():
        x=ser.readline()
        print(x) 
        text_file.seek(0)
        text_file.truncate()
        text_file.write(x)
        text_file.flush()

## Close file and serial port
weatherdata.close()
ser.close()