robwlakes / Weather-Station-OS-Sensors

Weather Sensors, Tx & Rx for Arduino plus 433MHz
14 stars 4 forks source link

V21Final serial monitor check #1

Open deennoo opened 9 years ago

deennoo commented 9 years ago

Hi Rob ! v16_next step give me good result on serial monitor

Did version_v21final have to give result on the serial monitor ?

robwlakes commented 9 years ago

Now, the last one (DebugVersion_21_Final) uses the extra on-board sensors etc. You will have to comment out code that refers to them. Around 15 lines of code. (I am guessing here) Start at the top and then remove what gives errors. Their final values will be returned as zeroes. Once you have it working you can then cut/build it how you want. Sounds like you are on your way. Let me know how go. Cheers Rob

deennoo commented 9 years ago

Rob i remove all DHT and BMP line, does on line 536 i have to keep 7?

Once again, if i run serial monitor, does I have a chance to see something written ? (for the moment when i run serial monitor, nothing is shown, and i think your skecth stop (led on pin 13 stop blinking).

I'm sure i need a python script to recieve the data and write the csv file, maybe you can share yours, or something similar, just for me to have a chance to check if my correction (simplification) are good.

robwlakes commented 9 years ago

Hi Deennoo, I have been able to check the code for "DebugVersion_21_Final.ino" I would suggest commenting out these lines 84,85,166,294,295,296 and 552-561. This should remove any functional reliance on the extra sensors and allow the code to run.

If you also comment out 536 and 561 then it will stop the program insisting on all sensors having reported in before sending out a csv line of characters. It will send out a line of csv every minute. Any sensors that have not yet been read, will simply return a zero until a valid reading updates the variable. It will retain that value until a valid reading of the sensor is eventually made.

I am away from my main computer at the moment and won't be able to organise some Python code for you just yet. However I was wondering if you would like to save the csv data to an SD card connected on the Arduino, this way no Python would be needed to store the CSV data. However to process to graphs etc Python is very handy. I could help you get an SD card attached if you are interested in doing that?

Cheers, Rob

deennoo commented 9 years ago

when i'll be sure that i can run your skecth without internal sensor, i'll plug your arduino reciever module to my raspberry, try to made a script to get data on csv,

With this data i'll update my weatherunderground PWS and my homeautomation software (raspberry app call Domoticz http://www.domoticz.com/).

deennoo commented 9 years ago

ok I try, you tips and looks to works : Led blinking, but still nothing on serial monitor.

Is this normal ?

robwlakes commented 9 years ago

Hi Deennoo, Just check your baud rate first. But I think you will have that sorted Have definitely been able to receive Wind,Temperature and Rainfall?? On the simpler debug programs? Cheers, Rob

deennoo commented 9 years ago

Dear Rob,

i finaly got some value (i don't eat this lunch but i got the value !

show like this :

0,0,7,4.7,62.1,8.00

where i guess : 0 is byte 0 0 is byte 1 7 is quadrant 4.7 is gust wind 62.1 is rain total 8.00 is temperature

is there a way to get external humidity ? and channel ?

i got 2 thgr800 sensor, 1 on ch1 and 1 on ch2 (ch2 is a fake on to get my swimming pool temp, sketch use is good because my wmr86 recieve the fake sensor and read it).

robwlakes commented 9 years ago

Congratulations Deennoo... Yes that is correct, the byte0 and byte1 are my experimental values I was sending from a sensor set up I had designed myself. You can either get rid of them or reuse them yourself your own way. Plus you can now add in your own choices of values, for example I don't use 'rain rate' or 'average wind speed' but you might like to print those out. I also use the digital humidity sensor on the board rather than the one from the Oregon Temp/Hum sensor. Now that you have got this far many things will have opened for you.

I only have one Temp/Humidity sensor so I don't decode the switch inside it to be able distinguish it from a second sensor. However I have tested the switch on mine and I know how to determine one THGR800 from another. Have a look at lines 486-505. nybble5 contains the value of the sensor's switch.

So the code could be something like this: Declare:

double temperature1 = 0;
int humidity1 = 0;
double temperature2 = 0;
int humidity2 = 0;

Then around the lines 495-505 make some changes like this

void thermom(){
  temperature = (double)((nyb(11)*100)+(nyb(10)*10)+nyb(9))/10; //accuracy to 0.01 degree seems unlikely
  if(nyb(12)==1){//  Trigger a negative temperature
    temperature = -1.0*temperature;
  }
  humidity = (nyb(14)*10)+nyb(13);
if (nyb(5)==1){
       temperature1=temperature;
       humidity1 = humidity;
     }
if (nyb(5)==2){
       temperature2=temperature;
       humidity2 = humidity;
     }
}

etc Probably not the most elegant solution, but should work. You will also have to get any new values printed out into the CSV line as well to check if it is working. Have a look around lines 551 and after that for output commands.

I hope this is all helping.

Cheers, Rob

robwlakes commented 9 years ago

Hi Deennoo, How's progress going? Have you begun your python scripts? Cheers Rob

deennoo commented 9 years ago

Just working on the channel. on debugversion_16_nextstep

more easy to introduce :

line : 49 : int channel = 0; line 374 : channel = (nyb(5)); line 383 : Serial.print(" Channel "); Serial.println(channel);

next step ? add this to version 21final

robwlakes commented 9 years ago

Hi Deennoo, OK fair enough too. As that could cope with any number of channels. Mind you the rolling codes allow many of the same sensors to be recognised as different. But annoyingly the rolling code system is a real nuisance to rely on though, as it resets every time the batteries are changed and there would be a 1 in 256 chance it could be identical to another sensor and therefore totally indestuingishable. A severe limitation with multiple ws or sensor setups. The Arduino can help out and could be programmed to recognise each new rolling code. Ie lock onto it. But would require a good bit of extra code to utilise it. If anyone near me buys a similar system I will have to work that c++ code out and add it in. That is, make sure my Arduino is only listening to my sensors with their rollings codes registered. Unfortunately nothing can stop another anemometer for example from randomly starting up exactly on the same values as my anemometer. Just a 255/256 chance it won't happen. Sorry I am probably off topic for your needs but it is an OS design limitation my software does not really address. Cheers Rob

deennoo commented 9 years ago

ok Done !!

only channel 1 is shown and i have add humidity on your csv ready to export.

i make a froke and submit a new version

robwlakes commented 9 years ago

Hi Deennoo, You can change the switch I think to then check if the software detects it. I will look forward to seeing your version. I am back on my main computer Saturday night. So will be able to do Git-hub much easier than on my phone. Cheers, Rob

deennoo commented 9 years ago

Switch already change, channel détection ok

robwlakes commented 9 years ago

Ahh back at home, no more viewing on a Phone!!

deennoo commented 9 years ago

Cool !

My python script is OK i record arduino serial output to a .csv file.

Juste tome stamp is missing, if you got an idéal how to add it on arduino sketch i'm happy

robwlakes commented 9 years ago

Here is my Python script that I have been experimenting with. It dumps to a couple of .json format files but also includes a time stamp. Imports....

import time  #I think this is the main one...
import calendar
from time import strftime, gmtime, localtime

And the code:

            #dump time,pressure,temperature, wind speed, wind direction to App format for Nick
            #In a file named 'weather.json'
            #{"temperature":25,"pressure":1000,"wind_speed":8,"wind_direction":W}
            app = open("//var/www/LTB/ramdrive/weather.json","w")
            app.write("{\"time_EPOCH\":"+str(time.time())+",\"temperature\":"+str(mytemperature[719])+",\"pressure\":"+str(mypressure[719])+",\"wind_speed\":"+str(mywindspeed[719])+",\"wind_direction\":"+str(mywinddirection[719])+",\"humidity\":"+str(myhumidity[719])+"}\n")
            app.close()
            app = open("//var/www/LTB/ramdrive/experimental.json","w")
            app.write("{\"time_EPOCH\":"+str(time.time())+",\"Byte0\":"+str(wlist[0])+",\"Byte1\":"+str(wlist[1])+"}\n")
            app.write("{\"time_EPOCH\":"+str(time.time())+",\"TempSamp\":"+str(float((int(wlist[0])*256)+int(wlist[1]))/16)+"}\n")
            app.close()

You can probably format that to however you want knowing the versatility of Python. I hope that helps, let me know.... Cheers, Rob

deennoo commented 9 years ago

ok thank you

very complicated for my who is a python newbie... i have to learn how to import your code on my python script who is like this :

!/usr/bin/python

get lines of text from serial port, save them to a file

from future import print_function import serial, io

addr = '/dev/ttyUSB23' # serial port to read data from baud = 115200 # baud rate for serial port fname = 'osvlog.csv' # log file to save data in fmode = 'a' # log file mode = append

with serial.Serial(addr,115200) as pt, open(fname,fmode) as outf: spb = io.TextIOWrapper(io.BufferedRWPair(pt,pt,1), encoding='ascii', errors='ignore', newline='\r',line_buffering=True) spb.readline() # throw away first line; likely to start mid-sentence (incomplete) while (1): x = spb.readline() # read one line of text from serial port print (x,end='') # echo line of text on-screen outf.write(x) # write line of text to file outf.flush() # make sure it actually gets written out

robwlakes commented 9 years ago

That seems to be similar to the I the way I did it Deennoo

import socket
import os
........
#Now swapping to the serial input
ser = serial.Serial('/dev/ttyACM0', 115200)  #sets up Python Serial but also restarts Arduino
print "Attached Serial Port @ ttyACM0, 115200 baud"
....
while True:
    #new version using the serial port
    ser.flushInput() #for a nice clean start
    # ii, pp, Quad, Speed, Rain, ExTemp, InTemp, Press,Humi  @115200
    print ("Awaiting data.....")
    dataRaw = ser.readline()
    #example data  Cycles -1.0 = 3,2,14,5.1,3504,7.00,12.00,1017.80,60.00(nl)(re)
    data = dataRaw.strip(' \t\n\r')   #remove /n and /r off the end of the incoming serial string
    wlist = logspliter.split(data)  #Split by comma into a list, wdict[]
    print(wlist)

So I would guess you are on the right track. This is my .csv code I run as well...

            writer = open("//var/www/LTB/ramdrive/dump.csv","w")
            writer.write("H:M,Pressure,Temperature,Wind Speed,Wind Direction,Rainfall,Humidity\n")
            h=0
            m=1
            for i in range(719,0,-1):#how to count backwards
                writer.write(str(h)+":"+str(m)+","+str(mypressure[i])+","+str(mytemperature[i])+","+str(mywindspeed[i])+","+str(mywinddirection[i])+","+str(myrain[i])+","+str(myhumidity[i])+"\n")
                m=m+1
                if m==60:  #increment hours every 60 minutes 
                    h=h+1
                    m=0
            writer.close()

I use it to debug reading etc with a spreadsheet. Otherwise it writes it but I do not use it. I keep 720 1 minute readings in the computer to graph at any one time, this just dumps them out.

http://www.laketyersbeach.net.au/ramdrive/dump.csv

robwlakes commented 9 years ago

How's it going Deennoo??

Rob Ward Lake Tyers Beach, 3909 Lake Tyers Beach Website http://www.laketyersbeach.net.au XP to XUbuntu - The journey, join me! http://www.laketyersbeach.net.au/XP2XU.html

On 17/01/15 19:44, deennoo wrote:

ok thank you

very complicated for my who is a python newbie... i have to learn how to import your code on my python script who is like this :

!/usr/bin/python

get lines of text from serial port, save them to a file

from future import print_function import serial, io

addr = '/dev/ttyUSB23' # serial port to read data from baud = 115200 # baud rate for serial port fname = 'osvlog.csv' # log file to save data in fmode = 'a' # log file mode = append

with serial.Serial(addr,115200) as pt, open(fname,fmode) as outf: spb = io.TextIOWrapper(io.BufferedRWPair(pt,pt,1), encoding='ascii', errors='ignore', newline='\r',line_buffering=True) spb.readline() # throw away first line; likely to start mid-sentence (incomplete) while (1): x = spb.readline() # read one line of text from serial port print (x,end='') # echo line of text on-screen outf.write(x) # write line of text to file outf.flush() # make sure it actually gets written out

— Reply to this email directly or view it on GitHub https://github.com/robwlakes/Weather-Station-OS-Sensors/issues/1#issuecomment-70359610.

deennoo commented 9 years ago

I don't manage to get succès with python And weather underground update.Some project are more easyer for me...Envoyé depuis mon mobile Huawei-------- Message original --------Objet : Re: [Weather-Station-OS-Sensors] V21Final serial monitor check (#1)De : Rob Ward À : robwlakes/Weather-Station-OS-Sensors Cc : deennoo How's it going Deennoo??

Rob Ward Lake Tyers Beach, 3909 Lake Tyers Beach Website http://www.laketyersbeach.net.au XP to XUbuntu - The journey, join me! http://www.laketyersbeach.net.au/XP2XU.html

On 17/01/15 19:44, deennoo wrote:

ok thank you

very complicated for my who is a python newbie... i have to learn how to import your code on my python script who is like this :

!/usr/bin/python

get lines of text from serial port, save them to a file

from future import print_function import serial, io

addr = '/dev/ttyUSB23' # serial port to read data from baud = 115200 # baud rate for serial port fname = 'osvlog.csv' # log file to save data in fmode = 'a' # log file mode = append

with serial.Serial(addr,115200) as pt, open(fname,fmode) as outf: spb = io.TextIOWrapper(io.BufferedRWPair(pt,pt,1), encoding='ascii', errors='ignore', newline='\r',line_buffering=True) spb.readline() # throw away first line; likely to start mid-sentence (incomplete) while (1): x = spb.readline() # read one line of text from serial port print (x,end='') # echo line of text on-screen outf.write(x) # write line of text to file outf.flush() # make sure it actually gets written out

— Reply to this email directly or view it on GitHub https://github.com/robwlakes/Weather-Station-OS-Sensors/issues/1#issuecomment-70359610.

—Reply to this email directly or view it on GitHub.

robwlakes commented 9 years ago

No Problems, best wishes with your new projects ;-)

Rob Ward

On 02/02/15 22:51, deennoo wrote:

I don't manage to get succès with python And weather underground update.Some project are more easyer for me...Envoyé depuis mon mobile Huawei-------- Message original --------Objet : Re: [Weather-Station-OS-Sensors] V21Final serial monitor check (#1)De : Rob Ward À : robwlakes/Weather-Station-OS-Sensors Cc : deennoo How's it going Deennoo??