Nov 172022
 

You can built your own weather station using Argent ADS-WS1 or any other devices that capable submiting to aprs-is or cwop network, but it was too expensive for me.
i began my research how to craft APRS WX packet using python and bash script on direwolf. that
was not easy for newbie amateur like me, LOL. Luckily i’ve found aprs-weather-submit created by KC1HBK.
it makes my research easier.

first of all, we need some hardwares Raspi Zero, BME280 sensorand some jumper wires.
Conect all wires from pi zero to bme280 using i2c pin. you can find pinout configuration here:

https://pinout.xyz

or type pinout in ssh shell

don’t forget to activate i2c pin, go ssh shell. issue command sudo raspi-config and go to interface options to activate i2c

Wiring:

  1. BME280 VIN pin connects to GPIO pin 1 (3.3V)
  2. BME280 GND pin connects to GPIO pin 6 (GND)
  3. BME280 SCL pin connects to GPIO pin 5 (SCL)
  4. BME280 SDA pin connects to GPIO pin 3 (SDA)

i’m using python and bme280 library from https://github.com/pimoroni/bme280-python
there’s some example script there, i silghtly modify the script to obtain bme280 values

building aprs-weather-submit.

git clone https://github.com/rhymeswithmogul/aprs-weather-submit.git

cd aprs-weather-submit

follow the instructions at build scripts section here:

https://github.com/rhymeswithmogul/aprs-weather-submit/blob/master/INSTALL.md

./autogen.sh ./configure [--disable-aprs-is] [--enable-debug] 
make 
sudo make install

when i first compiled, i got this error:

modify main.c

vi src/main.c

at line 588

i changed this line from:

(note at %lu)

fprintf(stderr, “Your comment was %lu characters long, but APRS allows %u characters. Your comment was truncated.\n”, strlen(optarg), MAX_COMMENT_LENGTH);

i changed it to %ul

than it compiled propperly.

here is my wx.sh script to generate wx format:

wx.sh

#!/bin/bash
STR=$(/home/pi/bme280_cjb_AA.py)

Temp=$(echo $STR | cut -f 1 -d" ")
Hum=$(echo $STR | cut -f 3 -d" ")
Bar=$(echo $STR | cut -f 2 -d" ")
Alt=$(echo $STR | cut -f 4 -d" ")
#aprs-weather-submit -k YD0BCX-13 -n -06.714692S -e 106.728514 -t $Temp -A $Alt -h $Hum -b $Bar -V 9
STR2=$(aprs-weather-submit -k YD0BCX-13 -n -6.198611 -e 106.87000E -T $Temp -h $Hum -b $Bar -M " WX on Pi Zero + BME280 + DW 1.7")

echo "${STR2:22}"
#echo "$Temp $Hum $Bar $Alt"

/home/pi/bme280_cjb_AA.py

chmod 755 bme280_cjb_AA.py

#!/usr/bin/env python
#Import modules for time and to access sensor
import time
from smbus import SMBus
from bme280 import BME280
#Initialise the BME280
bus = SMBus(1)
bme280 = BME280(i2c_dev=bus)
#Get data and discard to avoid garbage first reading
temperature = bme280.get_temperature()
pressure = bme280.get_pressure()
humidity = bme280.get_humidity()
altitude = bme280.get_altitude()
time.sleep(1)
#while True:
temperature = bme280.get_temperature()
pressure = bme280.get_pressure()
humidity = bme280.get_humidity()
altitude = bme280.get_altitude()
if ( temperature and pressure and humidity and altitude ):
print('{:05.2f} {:05.2f} {:05.2f}'.format(temperature, pressure, humidity), round(altitude),  end="")
time.sleep(1)

in wx.sh, there’s command part
echo “${STR2:22}”

this command will remove leading 22 characters(based on my lat long value)
in this case when i’m executing aprs-weather-submit -k YD0BCX-13 -n -6.198611 -e 106.87000E
the result will be:
YD0BCX-13>APRS,TCPIP:@200431z0611.92S/10652.20E_…/…t…aprs-weather-submit/1.6

we need to remove “YD0BCX-13>APRS,TCPIP:” part, that’s what “echo “${STR2:22}”” is for.

if it’s not removed direwolf will also submit those part and make it position beacon failed to aprs-is(YD0BCX-13>APRS,TCPIP*: submit 2 times)

direwolf configuration:

ADEVICE plughw:1,0
#ACHANNELS 1
#CHANNEL 0
MYCALL YOURCALLSIGN
MODEM 1200
IGSERVER rotate.aprs2.net
IGLOGIN YOURCALLSIGN passcode

CBEACON sendto=IG delay=1 every=05:00 infocmd="echo '>WX Station' $(date)"

CBEACON sendto=IG delay=01:10 every=10:00 infocmd="telem-parm.pl YD0BCX-13 Temperature Pressure Humidity Altitude"
CBEACON sendto=IG delay=01:11 every=10:00 infocmd="telem-unit.pl YD0BCX-13 deg.C hPa % masl"
CBEACON sendto=IG delay=01:11 every=10:00 infocmd="telem-eqns.pl YD0BCX-13 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0"
CBEACON sendto=IG delay=01:15 every=10:00 infocmd="telem-data.pl telem-seq.sh /home/pi/bme280_cjb_AA.py"

CBEACON sendto=IG delay=1 every=05:00 infocmd="/home/pi/wx.sh"

IBEACON sendto=IG delay=30 every=30 via=WIDE1-1

LOGDIR /var/log/direwolf
PTT GPIO 21

note on direwolf configuration, i also submiting telemetries data, you can ommit it if you want.
i think that’s it. i’m not good at talking or writing.

if there’s something to ask just drop me a message 😀

Jan 312011
 

Original Author: Simon J. Mudd
postfix-2.9-20110130-multiline-greeting.patch
[download#17]

diff -C1 -r postfix-2.9-20110130/src/smtpd/smtpd.c postfix-2.9-20110130.patched/src/smtpd/smtpd.c
*** postfix-2.9-20110130/src/smtpd/smtpd.c      Wed Jan 26 01:30:14 2011
--- postfix-2.9-20110130.patched/src/smtpd/smtpd.c      Mon Jan 31 13:35:51 2011
***************
*** 4529,4531 ****
            } else {
!               smtpd_chat_reply(state, "220 %s", var_smtpd_banner);
            }
--- 4529,4531 ----
            } else {
!               smtpd_chat_reply_multiline(state, 220, var_smtpd_banner);
            }
diff -C1 -r postfix-2.9-20110130/src/smtpd/smtpd_chat.c postfix-2.9-20110130.patched/src/smtpd/smtpd_chat.c
*** postfix-2.9-20110130/src/smtpd/smtpd_chat.c Tue Jan 25 21:53:32 2011
--- postfix-2.9-20110130.patched/src/smtpd/smtpd_chat.c Mon Jan 31 13:35:51 2011
***************
*** 64,65 ****
--- 64,66 ----
  #include <stdarg.h>
+ #include <ctype.h>

***************
*** 217,218 ****
--- 218,274 ----
        state->flags |= SMTPD_FLAG_HANGUP;
+ }
+
+ /* trim_line - remove trailing whitespace and return a pointer to the first */
+ /* non-space char in the string.  Based on TRIM() in ../util/dict.c         */
+ /* WARNING: this function is DESTRUCTIVE.                                   */
+
+ static char *trim_line( char *line ) {
+     char *p;
+
+     for (p=line + strlen(line); p > line && ISSPACE(p[-1]); p--);
+        *p = 0;
+
+     while ( ISSPACE(*line) )
+        ++line;
+
+     return ( line );
+ }
+
+ /* smtpd_chat_reply_multiline - convert multline string into seperate */
+ /* lines, sending each one to smtpd_chat_reply()                      */
+
+ #define LINE_SEPARATOR "\n"
+
+ void smtpd_chat_reply_multiline(SMTPD_STATE *state, int smtp_reply_code, char *format,...)
+ {
+     va_list ap;
+     char    *line, *line2;     /* one line (of the multiline) reply */
+     size_t   size;             /* size of a single line             */
+     static VSTRING *temp_line; /* SMTP reply before unescapeing     */
+     static VSTRING *multiline; /* SMTP reply after unescaping       */
+
+     /* First-time intialization. */
+     if (!temp_line)
+        temp_line = vstring_alloc(512);
+     if (!multiline)
+        multiline = vstring_alloc(512);
+
+     va_start(ap, format);
+     vstring_vsprintf(temp_line, format, ap);
+     va_end(ap);
+
+     /* unescape lines with "\\n", converting them to "\n" */
+     unescape( multiline, STR(temp_line) );
+
+     line = STR(multiline);
+     while ( (size = strcspn(line, LINE_SEPARATOR)) < strlen(line) ) {
+        *(line + size) = 0;
+
+        line2 = trim_line(line);
+        smtpd_chat_reply(state, "%03d-%s", smtp_reply_code, line2);
+
+        line += size + 1;
+     }
+     line2 = trim_line(line);
+     smtpd_chat_reply(state, "%03d %s", smtp_reply_code, line2);
  }
diff -C1 -r postfix-2.9-20110130/src/smtpd/smtpd_chat.h postfix-2.9-20110130.patched/src/smtpd/smtpd_chat.h
*** postfix-2.9-20110130/src/smtpd/smtpd_chat.h Tue Apr 25 01:48:28 2006
--- postfix-2.9-20110130.patched/src/smtpd/smtpd_chat.h Mon Jan 31 13:35:51 2011
***************
*** 17,18 ****
--- 17,19 ----
  extern void PRINTFLIKE(2, 3) smtpd_chat_reply(SMTPD_STATE *, const char *, ...);
+ extern void smtpd_chat_reply_multiline(SMTPD_STATE *, int, char *, ...);
  extern void smtpd_chat_notify(SMTPD_STATE *);