Procedure to make changes to an installed driver

67 views
Skip to first unread message

Craig Young

unread,
Sep 19, 2023, 6:44:51 PM9/19/23
to weewx-user
I have installed and configured a new driver in my weewx installation, TWI.py.  But before I launch weewx I need to make a couple of changes to the driver.  What is the correct method for doing that?  Do I:
0: Stop weewx
1. Open driver (located in usr folder) with Thonny
2. Make the changes and save
3. Start weewx
or do I need to reconfigure it first?

Craig Young

unread,
Sep 19, 2023, 8:18:25 PM9/19/23
to weewx-user
Maybe I should try a new tact.  I have a datalogger which is outputting weather data every 15 seconds and is received on the Raspberry Pi through the USB0 serial port.  Using CuteCom here is a sample data record:

<"2023-09-20 12:11:30",13.65,24.91,737,0,0,0,0,1.5,167,1.96,18.1,1.52,101.15,0.745,21.3,0.8,-1.1,-14.1105,0.5613659,323.5677>␍␊
I have written the program on the datalogger to do this so I can change the data format if needed.

What I need to do now is import this into weewx.  I assume I need a driver (or extension?) to do this but that is where the problems begin.  This is not for the feint of heart.  I have written tons of software in other languages for other applications, but all on windows.  I have a Raspberry Pi now running and have written a small python program to use the Serial instruction to read the data stream and even post this after formatting to wunderground.  So I am not stupid, just a very long learning curve to do a simple thing.
I found the TWI.py driver and it looks simple enough to modify for this application, but given my inexperience with linux and weewx I see lots of problems ahead.

Is there someone on here who could spend a couple of hours or so on Discord or Skype to help me either modify TWI.py or write a new driver for weewx?

Craig

Craig Young

unread,
Sep 19, 2023, 9:14:54 PM9/19/23
to weewx-user
Maybe it would be better to use the driver: fileparse.py.

gjr80

unread,
Sep 20, 2023, 12:44:43 AM9/20/23
to weewx-user
If you have the ability to provide a delimited text file with your obs and timestamp then fileparse will certainly work for you and it will be a straightforward and quick setup. However, if you already have some code to read observations from your station/datalogger you pretty much have all you need for your own driver. In a nutshell, all a driver does is run an infinite loop obtaining data from the station, converting units as required, packaging the data in a python dictionary and passing the dictionary on to WeeWX. The fileparse driver is a good example of a basic driver, you could just remove the code that reads data from a fie and substitute your code or a call to a method that reads data from your station/datalogger. At the very least the data will need to be massaged into a python dictionary (ie a loop packet), but that is easy to do. There will be a few things to watch for, for example: handling units, dealing with missing data and making sure the driver does not block the main WeeWX loop (typically an issue when reading from high latency devices or via a network). You already have code running to read data from the datalogger/station and post to WU, you could potentially have WeeWX reading data direct from your datalogger/station and let WeeWX handle uploading to WU (and other services as well) - that way you are reading data from your datalogger/station once only.

Have a look at the Porting to new hardware section in the Customization Guide. It's quite a simple process and quite satisfying once complete.

Also, just post back here if have any questions.

Gary

Craig Young

unread,
Sep 20, 2023, 12:56:16 AM9/20/23
to weewx-user
Thanks Gary, that is an idea I have not thought about .. to take the fileparse driver and as you say, just drop my code into it.  I will look at this.

Craig
Reply all
Reply to author
Forward
0 new messages