Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

CR1000 APRS/CWOP


cellectronic Mar 2, 2020 01:00 PM

Hi folks ,

I am interested in posting CR1000 data via APRS and CWOP. 

Currently the CR1000 is posting data directly to Weatherunderground. 

Can somebody shed some light on the code which will enable the CR1000 to post this data ? Thanks for any support.  


GaryTRoberts Mar 5, 2020 04:39 PM

I have a subroutine that I use to post data to the CWOP network. See https://aprs.fi/weather/a/AG1T-20. I use the following code to do so:

 

'Subroutines
Sub SUB_Send_APRS_Data()
  Dim sequence_number
  Dim temp_number
  Dim temp_string As String
  Dim cwop_message As String * 300
  Dim cwop_socket As Long

  IPRoute ("sixth.aprs.net", 1, 1)  

  cwop_socket = TCPOpen("sixth.aprs.net", 14580, 200)
  If(cwop_socket > 100) Then
    SerialOut(cwop_socket, "", "# aprsc 2.1.4-g408ed49" & CHR(10) & CHR(13), 1, 200)
    SerialOut(cwop_socket, "user AG1T-20 pass 1111 vers CRBasicCWOPAPRS " & _PROGRAM_VERSION & CHR(10) & CHR(13), "# logresp AG1T verified, server CWOP-1" & CHR(10) & CHR(13), 1, 200)
    temp_number = wind_direction
    Sprintf(temp_string, "%03.0f", temp_number)
    'Send standard weather information
    cwop_message = "AG1T-20>APRS,TCPIP*:!4141.14N/11150.00W_" & temp_string
    temp_number = TEN_MINUTE.wind_speed_mph_average(1, 1)
    Sprintf(temp_string, "%03.0f", temp_number)
    cwop_message = cwop_message & "/" & temp_string 
    temp_number = TEN_MINUTE.wind_speed_mph_Max(1, 1)
    Sprintf(temp_string, "%03.0f", temp_number)
    cwop_message = cwop_message & "g" & temp_string
    cwop_message = cwop_message & "t" & FormatLong ( air_temperature, "%03u" ) 
    cwop_message = cwop_message & "r" & FormatLong ( (rain_fall_last_hour * 100), "%03u" ) 
    cwop_message = cwop_message & "p" & FormatLong ( (rain_fall_last_24_hours * 100), "%03u" ) 
    cwop_message = cwop_message & "P" & FormatLong ( (rain_fall_since_midnight * 100), "%03u" )
    cwop_message = cwop_message & "L" & FormatLong ( slrw, "%03u" )
    cwop_message = cwop_message & "h" & FormatLong ( relative_humidity, "%02u" )
    temp_number = barometric_pressure(3)
    temp_number = (temp_number * 10)
    Sprintf(temp_string, "%05.0f", temp_number)
    cwop_message = cwop_message & "b" & temp_string
    cwop_message = cwop_message & "xCSIL" & _PROGRAM_VERSION 'WinAPRS with "CSI L"ogger designation
    cwop_message = cwop_message & CHR(13)
    cwop_message = cwop_message & CHR(10)
    SerialOut(cwop_socket, cwop_message, "", 1, 0)
    'send telemetry data
    If(sequence_number <> 999) Then
      sequence_number += 1
    Else
      sequence_number = 1
    EndIf
    cwop_message = "AG1T-20>APRS,TCPIP*:T#" & FormatLong(sequence_number, "%03u") & "," & FormatLong(battery_voltage(1) * 10, "%03u")
    cwop_message = cwop_message & "," & FormatLong(battery_voltage(2) * 10, "%03u") & "," & FormatLong(battery_voltage(3) * 10, "%03u")
    cwop_message = cwop_message & "," & FormatLong(battery_voltage(4) * 10, "%03u") & ",000,000" & ",01100000"
    cwop_message = cwop_message & CHR(13)
    cwop_message = cwop_message & CHR(10)
    SerialOut(cwop_socket, cwop_message, "", 1, 0)
    
    'send telemetry parameter names only once a day
    'make sure there are only 9 characters (including spaces) in the callsign/station id field or else we get APRS errors
    If (IfTime (0, 720, Min)) Then
      cwop_message = "AG1T-20>APRS,TCPIP*::AG1T-20  :PARM.Battery,Bat1,Bat2,Bat3,Bat4,Bat5"
      cwop_message = cwop_message & CHR(13)
      cwop_message = cwop_message & CHR(10)
      SerialOut(cwop_socket, cwop_message, "", 1, 0)
      cwop_message = "AG1T-20>APRS,TCPIP*::AG1T-20  :UNIT.volt,volt,volt,volt,volt,on,on,on,on,on,on,on,on"
      cwop_message = cwop_message & CHR(13)
      cwop_message = cwop_message & CHR(10)
      SerialOut(cwop_socket, cwop_message, "", 1, 0)
      cwop_message = "AG1T-20>APRS,TCPIP*::AG1T-20  :EQNS.0,.1,0,0,.1,0,0,.1,0,0,.1,0,0,0,0"
      cwop_message = cwop_message & CHR(13)
      cwop_message = cwop_message & CHR(10)
      SerialOut(cwop_socket, cwop_message, "", 1, 0)
    EndIf
    TCPClose(cwop_socket)
  EndIf
EndSub '//End SubSendCWOPData

 

You will need to use an amateur radio callsign and password or CWOP assigned station in the program code. This code is running on a CR6, but should be portable to a CR1000.  The logger will also need to have a PPP modem connection, NL115, NL116, NL200, NL201, or NL240 with a connection to the internet to be able to do this.


cellectronic Mar 5, 2020 07:34 PM

Hi Gary, many thanks for the info. I will be connecting the logger via an NL115 to the internet , hopefully I will get chance to look into this over the weekend.  Will keep you informed.  Best regards, Steve (G7NSJ).


cellectronic Mar 10, 2020 10:32 AM

Hi Gary, I have now had chance to look at this and have picked my way through the code.

one issue I have is the program will not compile because Line 8 of your subroutine "

 IPRoute ("sixth.aprs.net", 1, 1)"
I get an error which states "two many parameters"
If I remove the 1, it will then compile , Can you suggest a fix for this or does the
,1 need to be there ?
Thanks for any help.
Steve .

GaryTRoberts Mar 10, 2020 03:11 PM

It should work if you are running the latest version of the operating system in your datalogger. The option isn't needed, but it helps to force the route.


GaryTRoberts Mar 10, 2020 03:15 PM

Here is a link to the instruction details in the CR1000X (HELP). The CR1000 should be similar if running 32.04.


cellectronic Apr 9, 2020 06:18 PM

Hi Gary

I am still attempting to debug the program and wondered if you would be so kind as to have a quick look at it to see where I am going wrong, I have added a few public variables to eliminate some errors which were cropping up. I have the latest firmware in the logger and the code compiles ok but nothing uploading to CWOP,Here is the code and thanks for any help.

************************************************************************************

'TEST TO GO IN LOGGER
'CR1000
'Created by Short Cut (4.0)

'Declare Variables and Units
Public BattV
Public PTemp_C
Public BP_mbar
Public WS_mph
Public WindDir
Public Rain_mm
Public AirTC
Public RH
Public NR_Wm2
Public _PROGRAM_VERSION
Public rain_fall_last_hour
Public rain_fall_last_24_hours
Public rain_fall_since_midnight
Public slrw
Public battery_voltage

Units BattV=Volts
Units PTemp_C=Deg C
Units BP_mbar=mbar
Units WS_mph=miles/hour
Units WindDir=degrees
Units Rain_mm=inch
Units AirTC=Deg C
Units RH=%
Units NR_Wm2=W/meter^2

'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,60,Min,10)
Average(1,BattV,FP2,False)
Average(1,PTemp_C,FP2,False)
Average(1,BP_mbar,IEEE4,False)
Average(1,WS_mph,FP2,False)
Sample(1,WindDir,FP2)
Totalize(1,Rain_mm,FP2,False)
Average(1,AirTC,FP2,False)
Sample(1,RH,FP2)
Average(1,NR_Wm2,FP2,False)
EndTable

DataTable(Table2,True,-1)
DataInterval(0,1440,Min,10)
Minimum(1,BattV,FP2,False,False)
EndTable

DataTable(TEN_MINUTE,True,-1)
DataInterval(0,10,Min,10)
Average(1,WS_mph,FP2,False)
EndTable

'Main Program
BeginProg
'Main Scan
Scan(5,Sec,1,0)
'Default CR1000 Datalogger Battery Voltage measurement 'BattV'
Battery(BattV)
'Default CR1000 Datalogger Wiring Panel Temperature measurement 'PTemp_C'
PanelTemp(PTemp_C,_50Hz)
'CS100 Barometric Pressure Sensor measurement 'BP_mbar'
PortSet(1,1)
VoltSE(BP_mbar,1,mV2500,1,1,0,_50Hz,0.2,600)
BP_mbar=BP_mbar*1
'A100R Wind Speed Sensor (CSL) measurement 'WS_mph'
PulseCount(WS_mph,1,1,2,1,0.7768,0)
If WS_mph<0.01 Then WS_mph=0
'W200P Wind Direction Sensor (CSL) measurement 'WindDir'
BrHalf(WindDir,1,mV2500,2,1,1,2500,False,20000,_50Hz,357,0)
'Generic Tipping Bucket Rain Gauge measurement 'Rain_mm'
PulseCount(Rain_mm,1,2,2,0,0.007874,0)
'HMP45C (panel switched power) Temperature & Relative Humidity Sensor (CSL) measurements 'AirTC' and 'RH'
PortSet(9,1)
Delay(0,150,mSec)
VoltSE(AirTC,1,mV2500,3,0,0,_50Hz,0.1,-40)
VoltSE(RH,1,mV2500,4,0,0,_50Hz,0.1,0)
PortSet(9,0)
If (RH>100) And (RH<108) Then RH=100
'NR-LITE Net Radiometer (no wind speed correction) measurement 'NR_Wm2'
VoltDiff(NR_Wm2,1,mv25,3,True,0,_50Hz,100,0)
'Call Data Tables and Store Data
CallTable Table1
CallTable Table2
CallTable TEN_MINUTE
NextScan

'*******************************************
'************************************************************
'************************************************************
'Subroutines

Sub SUB_Send_APRS_Data()
Dim sequence_number
Dim temp_number
Dim temp_string As String
Dim cwop_message As String * 300
Dim cwop_socket As Long

IPRoute ("cwop.aprs.net", 1)

cwop_socket = TCPOpen("cwop.aprs.net", 14580, 200)
If(cwop_socket > 100) Then
SerialOut(cwop_socket, "", "# aprsc 2.1.4-g408ed49" & CHR(10) & CHR(13), 1, 200)
SerialOut(cwop_socket, "user FW6986 pass -1 vers CRBasicCWOPAPRS " & _PROGRAM_VERSION & CHR(10) & CHR(13), "# logresp FW6986 verified, server cwop.aprs.net" & CHR(10) & CHR(13), 1, 200)
temp_number = WindDir
Sprintf(temp_string, "%03.0f", temp_number)
'Send standard weather information
cwop_message = "FW6986>APRS,TCPIP*:z5232.51N/00301.80W_" & temp_string
' temp_number = TEN_MINUTE.wind_speed_mph_average(1, 1)
Sprintf(temp_string, "%03.0f", temp_number)
cwop_message = cwop_message & "/" & temp_string
' temp_number = TEN_MINUTE.wind_speed_mph_Max(1, 1)
Sprintf(temp_string, "%03.0f", temp_number)
cwop_message = cwop_message & "g" & temp_string
cwop_message = cwop_message & "t" & FormatLong ( AirTC, "%03u" )
cwop_message = cwop_message & "r" & FormatLong ( (rain_fall_last_hour * 100), "%03u" )
cwop_message = cwop_message & "p" & FormatLong ( (rain_fall_last_24_hours * 100), "%03u" )
cwop_message = cwop_message & "P" & FormatLong ( (rain_fall_since_midnight * 100), "%03u" )
cwop_message = cwop_message & "L" & FormatLong ( slrw, "%03u" )
cwop_message = cwop_message & "h" & FormatLong ( RH, "%02u" )
' temp_number = BP_mbar(3)
temp_number = (temp_number * 10)
Sprintf(temp_string, "%05.0f", temp_number)
cwop_message = cwop_message & "b" & temp_string
' cwop_message = cwop_message & "xCSIL" & 'WinAPRS with "CSI L"ogger designation
cwop_message = cwop_message & CHR(13)
cwop_message = cwop_message & CHR(10)
SerialOut(cwop_socket, cwop_message, "", 1, 0)
'send telemetry data
If(sequence_number <> 999) Then
sequence_number += 1
Else
sequence_number = 1
EndIf
' cwop_message = "FW6986>APRS,TCPIP*:T#" & FormatLong(sequence_number, "%03u") & "," & FormatLong(battery_voltage(1) * 10, "%03u")
' cwop_message = cwop_message & "," & FormatLong(battery_voltage(2) * 10, "%03u") & "," & FormatLong(battery_voltage(3) * 10, "%03u")
' cwop_message = cwop_message & "," & FormatLong(battery_voltage(4) * 10, "%03u") & ",000,000" & ",01100000"
cwop_message = cwop_message & CHR(13)
cwop_message = cwop_message & CHR(10)
SerialOut(cwop_socket, cwop_message, "", 1, 0)

'send telemetry parameter names only once a day
'make sure there are only 9 characters (including spaces) in the callsign/station id field or else we get APRS errors
If (IfTime (0, 720, Min)) Then
cwop_message = "FW6986>APRS,TCPIP*::FW6986 :PARM.Battery,Bat1,Bat2,Bat3,Bat4,Bat5"
cwop_message = cwop_message & CHR(13)
cwop_message = cwop_message & CHR(10)
SerialOut(cwop_socket, cwop_message, "", 1, 0)
cwop_message = "FW6986>APRS,TCPIP*::FW6986 :UNIT.volt,volt,volt,volt,volt,on,on,on,on,on,on,on,on"
cwop_message = cwop_message & CHR(13)
cwop_message = cwop_message & CHR(10)
SerialOut(cwop_socket, cwop_message, "", 1, 0)
cwop_message = "FW6986>APRS,TCPIP*::FW6986 :EQNS.0,.1,0,0,.1,0,0,.1,0,0,.1,0,0,0,0"
cwop_message = cwop_message & CHR(13)
cwop_message = cwop_message & CHR(10)
SerialOut(cwop_socket, cwop_message, "", 1, 0)
EndIf
TCPClose(cwop_socket)
EndIf
EndSub '//End SubSendCWOPData

***********************************************************************************************************************


DaveMattey Apr 11, 2020 12:31 PM

Hi  Steve - I wonder if you can help me... I am repurposing a CR1000 formerly used for stand-alone monitoring to running a weather station with CO2 analysis - data collection is running fine but I too want to post data to a local server and WU.  I have no experience in CR1000 serial comms though!  I am looking at getting a NL121 but suspect this may entail an expensive upgrade cycle (currently running PC400 v1.5).  I am curious how you are running yours, which versions of  software and firmware, and whether you can share some code that connects to WU?  Hugely appreciated.

best wishes  Dave


cellectronic Apr 11, 2020 02:46 PM

Hi Dave,

Thanks for the info, TBH I am not a programming guy but I am plodding away at it ,with some results.

I have found the time is not being sent in the packet , as below from the raw data ...

2020-04-11 15:34:54 BST: FW6986>APRS,TCPXX*,qAX,CWOP-1:@5232.51N/00301.88W_221/221g221t023r000p000P000L000h56b02218

The info on how the packet should look is on the CWOP website.


cellectronic Apr 11, 2020 10:35 PM

Hi Dave, I should be able to help you out with some code that I use for WU , will dig it out tomorrow.  Also there is a newer way to post to WU than my method , but we can chat about that tomorrow too, maybe via pm.

Best regards. 


GaryTRoberts Apr 11, 2020 10:56 PM

It looks like your are missing a call to the subroutine SUB_SEND_APRS_DATA in your main scan.  Add this after your Call Tables in the mail scan:

If (IfTime(0, 10, Min)) Then
Call SUB_Send_APRS_Data
EndIf

That will call the subroutine SUB_Send_SPARS_Data ever 10 minutes.

In order to send data to the system, you are also going to need a password. A -1 won't let you send data to the server. -1 access just allows you read only access to the CWOP server.

As you run and test this, watching in the data logger's terminal is always a good idea. In the terminal type W then 13 and press N (for no) to watch the interaction between the CWOP server and your datalogger.


DaveMattey Apr 12, 2020 10:19 AM

Hi Steve  - thanks very much

My email (if the forum allows this)  is dave.mattey@gmail.com - look forward to hearing from you

dave 


cellectronic Apr 17, 2020 09:32 AM

So, here we are , Back again !

I could do with a little assistance regarding the below code regarding uploading data to CWOP from the CR1000 logger.

A couple if points I dont understand , Which are the CHR(10) and CHR(13) , what are those for and also the "%03u" ?

The problem I am having is the decimal point for the barometric pressure is being displayed in the wrong place  ie 99.7 instead of 997.0 mbar.

Programming is definately not my strong poing (so far) and the code was extracted from an example which was posted earlier, and a few days of head scratching got me to the code below,  Thanks for any help.

'Subroutines
  SlowSequence
  Scan(5, Min, 3, 0)
 
 ' Sub SUB_Send_APRS_Data()
  Dim sequence_number
  Dim temp_number
  Dim temp_string As String
  Dim cwop_message As String * 300
  Dim cwop_socket As Long

  IPRoute ("cwop.aprs.net", 1)  

  cwop_socket = TCPOpen("cwop.aprs.net", 14580, 200)
  If(cwop_socket > 100) Then
    SerialOut(cwop_socket, "", "# aprsc 2.1.4-g408ed49" & CHR(10) & CHR(13), 1, 200)
    SerialOut(cwop_socket, "user FW7209 pass -1 vers CRBasicCWOPAPRS " & _PROGRAM_VERSION & CHR(10) & CHR(13), "# logresp FW7209 verified, server cwop.aprs.net" & CHR(10) & CHR(13), 1, 200)
 
    'Send standard weather information
    cwop_message = "FW7209>APRS,TCPIP*:!5234.67N/00235.15W_" & temp_string
    Sprintf(temp_string, "%03.0f", temp_number)
    cwop_message = cwop_message & "_" & FormatLong ( WindDir,"%03u" )
    cwop_message = cwop_message & "/" & FormatLong ( WS_mph,"%03u" )
    cwop_message = cwop_message & "g" & FormatLong ( WS_mph,"%03u" )
    cwop_message = cwop_message & "t" & FormatLong ( AirTC, "%03u" )
    cwop_message = cwop_message & "r" & FormatLong ( (rain_fall_last_hour * 100), "%03u" )
    cwop_message = cwop_message & "p" & FormatLong ( (rain_fall_last_24_hours * 100), "%03u" )
    cwop_message = cwop_message & "P" & FormatLong ( (rain_fall_since_midnight * 100), "%03u" )
    cwop_message = cwop_message & "L" & FormatLong ( slrw, "%03u" )
    cwop_message = cwop_message & "h" & FormatLong ( RH, "%02u" )
    cwop_message = cwop_message & "b" & FormatLong ( BP_mbar, "%05u" )

    temp_number = (temp_number * 10)
    Sprintf(temp_string, "%05.0f", temp_number)
   
    SerialOut(cwop_socket, cwop_message, "", 1, 0)
   
    EndIf
    TCPClose(cwop_socket)
    Nextscan
    EndProg


GaryTRoberts Apr 17, 2020 04:00 PM

The CHR(10) and CHR(13) are Carriage Return and a Line Feed characters. The equilivent of hitting the Enter key on your Windows keyboard.  The %03u tells FormatLong that it should pad the variable with at least three zeros. ie. if the value is 1 it will be formatted as 001. The APRS protocol requires that all data be sent as whole numbers and that those numbers take up so many spaces or bytes (three in most cases).

The APRS protocol can be found HERE. The section concerning weather packets can be found in Chapter 12 on page 62 of the document.


Makada Apr 17, 2020 04:09 PM

I use Python to upload weatherdata to WU, WOW and Windguru.


cellectronic Apr 17, 2020 06:08 PM

Hi Makada,

Can I ask what you are running Python on , is it a Raspberry Pi ?

Thanks.


Makada Apr 17, 2020 07:10 PM

Hi,

Windows 10 pro.


Haidar Mar 19, 2023 06:30 PM

How to access cr1000 datalogger through Arduino mega or any microcontroller??

And How I can give password to the datalogger so that it identify and accept it and begins communication to fetch the mateorological data from Campbell scientific cr1000??

Log in or register to post/reply in the forum.