#help-with-radio

1 messages · Page 4 of 1

untold needle
#

Error message with that code @granite spear @half plover

granite spear
#

I'm not familiar enough with numpy to know exactly what's going on, but it looks like you're reading the data in from a text file, but never actually converting it to a complex number. It's still a string?

untold needle
#

f = np.array([complex(x) for x in f])

#

just now

#

this shrinks the error down @half plover @granite spear to just:

Traceback (most recent call last):
  File "C:\Users\aryan\PycharmProjects\Fast Fourier Transform\main.py", line 21, in <module>
    f = np.array([complex(x) for x in f])
  File "C:\Users\aryan\PycharmProjects\Fast Fourier Transform\main.py", line 21, in <listcomp>
    f = np.array([complex(x) for x in f])
ValueError: complex() arg is a malformed string

half plover
#

complex() I believe requires two inputs, first the real part, then the imaginary

untold needle
#

I see

half plover
#

So

a=1.03
b=0.8
c=complex(a,b)
#

As an example

untold needle
remote pond
untold needle
half plover
#

try print(numpy.real(num))

primal warren
#

Seems fine here ```

complex('-0.0117647058823529-0.019607843137254943j')
(-0.0117647058823529-0.019607843137254943j)

untold needle
#

then why is it giving me errors

#

wait

#

its because its not in string form originally

#

but it is

#

surely

primal warren
#

It looks like you're making arrays of strings, then handing them to complex() two at a time?

untold needle
#

how so

#

import pyfftw
import multiprocessing
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams['figure.figsize'] = [30, 21]

plt.rcParams.update({'font.size' : 10})

#Create a signal with two/multiple frequencies and some noise

dt = 4.16666667e-7 #Time div


with open('time.txt', 'r') as a:
    t = [line.strip() for line in a]

with open('voltages.txt', 'r') as a:
    f = [line.strip() for line in a]

f = np.array([complex(x) for x in f])

#FFT computation

n = len(t)
print('works')
fhat = pyfftw.interfaces.numpy_fft.fft(f, n)
print('works')
PSD = fhat * np.conj(fhat) / n
print('works')
freq = (1/(dt*n)) * np.arange(n)
print('works')
L = np.arange(1, np.floor(n/2), dtype = 'int')

indices = PSD > 40
PSDclean = PSD * indices
fhat = indices * fhat
ffilt = pyfftw.interfaces.numpy_fft.ifft(fhat) #Filtered signal

#Plot

fig, axs = plt.subplots(3, 1)


plt.sca(axs[0])
plt.plot(freq[L], PSD[L], color = 'c', linewidth = 2, label = 'Noisy')
plt.plot(freq[L], PSDclean[L], color = 'k', linewidth = 1.5, label = 'Filtered')
plt.xlim(freq[L[0]], freq[L[-1]])
plt.xlabel('Frequency(Hz)', fontsize=12)
plt.ylabel('Power(PSD)', fontsize=12)
plt.legend()

plt.show()








#

if you look at the complex line

#

f = np.array([complex(x) for x in f])

#

@primal warren it is just converting them to complex numbers

half plover
#

So it can’t be a string I’m finding

untold needle
#

im getting the string malformed error though

young cove
#

pyrtlsdr output .npy files natively, which you can read back in as complex arrays, so can you avoid the conversion to text?

untold needle
#

but I would like to fix this error

half plover
remote pond
primal warren
#

Probably there's something in your file that's throwing it. Either print each value before converting it, or catch the exception and print the resulting string to see which one it gags on (I'm guessing a blank line)

half plover
#

If I have quotes around the number it returns the whole string

untold needle
#

its a txt file

#

here it is

#

if you look at my code, I unpack it earlier line by line

young cove
#

you could use numpy.loadtxt() to read it directly, setting dtype=complex,

#

instead of reading it line by line

untold needle
#

hmm

young cove
#

works perfectly for me:

>>> import numpy as np
>>> a = np.loadtxt("Downloads/message.txt", dtype=complex)
#

the values print match perfectly

untold needle
#

well erm

#

@young cove that was beautiful

young cove
#
array([-0.02745098-0.01176471j,  0.00392157+0.01176471j,
        0.00392157-0.03529412j, -0.01176471+0.00392157j,
        0.01176471+0.00392157j, -0.00392157-0.01960784j,
       -0.00392157+0.01960784j,  0.00392157-0.01960784j,
#

...

untold needle
#

it worked perfectly

young cove
#

numpy has all kinds of tools for data I/O, we should use them

untold needle
#

yeah no that definitely works

#

@young cove thanks a lot

#

numpy is actually great

young cove
#

numpy is fantastic, and is designed to be easy to use

primal warren
#

I remember the bad old days when building numpy would take a couple of days, but these days I just install it with pip and life is good.

remote pond
# untold needle

you have two blank lines at the end of your file, and complex() doesn't like empty strings as input

young cove
#

is pyfftw a separate package? There are FFT's in scipy (which builds on numpy)

untold needle
#

the syntax is just pyfftw.interfaces.(numpy or scipy)

young cove
#

got it

untold needle
#

this is weird though @young cove its running fine and all, I think I've calibrated the axis wrong

#

a 1MHz signal on a 92.2MHz received frequency?

#

Must be some dodgy axis calibration

young cove
#

the fft is going to make some assumptions about the center frequency, doest it have that as an optional arg?

untold needle
#

I will have a look

untold needle
#

maybe fftshift()

young cove
untold needle
#

not sure thoug

young cove
#

do you need the speed of pyfftw right now? You could use the standard numpy/scipy routines, and have more examples avaialble. Later you can optimize with a faster FFT

young cove
#

i would say stick with the integrated toolset for now

untold needle
#

ok

young cove
#

an FFT itself is kinda unitless

untold needle
#

Its about axis calibration though

young cove
#

the signal the pyrtlsdr records is downcoverted to a baseband. The data has no knowledge it was at 92-94MHz (or whatever the bandwidth you are using is). So the result is going to be 0-2MHz, etc. You can just add an offset.

#

if I understand correclty

untold needle
#

Do I just add an offset of the centered frequency, so 92.2e6?

young cove
#

chatgpt didn't say that; some smart person wrote something that chatgpt paraphrased. it's better to dfind that smart person

#

is it center or left edge?

untold needle
#

Center

#

Center is 92.2 in pyrtlsdr

#

In the pi

young cove
#

and you gave that center to gqrx?

untold needle
#

Well yes

#

I gave it the parameters we discussed yesterday

young cove
#

So you want to make an adjustment so that it looks the same in your numpy code as it does in the gqrx plot

untold needle
#

Yes

young cove
#

and does the graph make sense, based on the signal the rtl-sdr was recording?

untold needle
#

Which graph?

#

The fft?

young cove
#

the gqrx graph and your fft output graph

untold needle
#

The gqrx one does

#

I haven't matched gqrx vs fft actually but looking at local radio stations, fft does seem right

young cove
#

they both have a known peak somewhere, yeah, so you can just say, ok that's the offset I need

#

center or left, whichever works

#

and your signal was from a beacon at a known frequency, so that's the test

untold needle
#

Oh so just brute force it fine

#

Yeah I see

#

Just Try different offsets

#

That seems perfectly reasonable

#

Thanks.

#

Thanks for fixing the complex error too btw

young cove
#

yeah, it's not really brute force, it's just that the system is at a frequency, but the signal is shifted when received, and then you offset it it back up so it matches the scanned frequency band

untold needle
#

You have really helped with everything in the last few days

untold needle
#

I will try tomorrow, as I have class I should probably sleep considering that it is 23:20

#

Thanks a lot for your assistance.

young cove
#

i am not an expert by any means, but I use SDR's for recreation. Also I helped a group shift from Matlab to numpy a few jobs ago.

untold needle
#

Oh fine, so you are an expert

#

🤣🤣🤣

young cove
#

you're doing great, you have to apply the rather theoretical stuff you learned in class to this practical problem. (I am glad you folks didn't build a receiver from scratch)

#

but I have never actually used FFT for my own devious calculation purposes

untold needle
#

Unless we decide to return the components

young cove
#

what happened to the competition deadline?

untold needle
#

Hardware submission by 12th March

#

Including raspberry pi and code.

young cove
#

got it

untold needle
# young cove got it

The building receiver from scratch is like a side hobby now just for fun, won't contribute towards competition although we might talk about our pains and struggles during the end presentation

#

We will likely mention adafruit/external assistance

young cove
#

is this all theoretical or is it going to fly?

untold needle
#

It's going in a balloon

#

30km into thr atmosphere

young cove
#

well, looking forward to hearing about

#

it

untold needle
# young cove it

Definitely, I'll make an announcement about it in this channel here at least

young cove
#

good night and good luck!

untold needle
#

Thats why I also need to automate the pi to run the code when it boots up automatically

untold needle
untold needle
#

@primal warren Do you have some arduino code for the AD9850 function generator, we are getting dodgy results with our code and oscilliscope.

#

we have a module

#

we are getting a flat line

#

rather than a sine wave

#

it is extremely dogy

primal warren
untold needle
#

It was done on a breadboard

weak niche
#

we rewired it twice i think

primal warren
#

I used a breadboard too, worked fine (however this was an AD9833, I'm unsure what an AD9850 is)

untold needle
#

we need to hookup the yagi to the function generator

primal warren
#

So, what do you mean by "extremely dodgy"? That seems different from "we are getting a flat line". Did you connect the FSYNC wire?

#

When you say "we are getting a flat line", what is your oscilloscope deflection factor? The signal from these boards isn't a high voltage one. I get about 600mV peak to peak from mine.

#

If you're on something like 5 volts per division, it would look like a flat line.

untold needle
#

You could try with @tropic fractal who is part of my team but he's not particularly active

#

ill check it out though

tropic fractal
# untold needle You could try with <@709420251653210246> who is part of my team but he's not par...

This was the code we were using today, it's just example code provided on the GitHub page for the library we're using (https://github.com/F4GOJ/AD9850):


const int W_CLK_PIN = 13;
const int FQ_UD_PIN = 8;
const int DATA_PIN = 10;
const int RESET_PIN = 9;

double freq = 1500000;
double trimFreq = 124999500;

int phase = 0;

void setup(){
  DDS.begin(W_CLK_PIN, FQ_UD_PIN, DATA_PIN, RESET_PIN);
  DDS.calibrate(trimFreq);
  DDS.setfreq(freq, phase);
}

void loop(){
  
}```

We made sure to connect the Arduino's pins as described on the library's page and other tutorials, and the connection to the arduino seems to be working. As for the "dodgy" results, the sine wave output was a constant voltage, usually around 30mV, though this could change after restarting the program without any obvious explanation (it tended to vary between 20 and 40mV, so nothing like the 600mV peak to peak that you've been getting @primal warren ). Our oscilloscope has been known to act up, so it could just been an issue with that. Thanks for any help 🙂
untold needle
#

@young cove @granite spear Sorry to bother you guys once again, it appears that my fourier is returning bogus results, here is the code:


import pyfftw
import multiprocessing
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams['figure.figsize'] = [30, 21]

plt.rcParams.update({'font.size' : 10})

#Create a signal with two/multiple frequencies and some noise

dt = 4.16666667e-7 #Time div
center_freq = 92.2e6
n_samples = 24000

with open('time.txt', 'w') as f:
    for i in range(n_samples):
        f.write(f'{dt:.20f}\n')
        dt += 0.000000416666667


with open('time.txt', 'r') as a:
    t = [line.strip() for line in a]

''''with open('voltages.txt', 'r') as a:
    f = [line.strip() for line in a]'''

f = np.loadtxt('voltages.txt', dtype="complex")

#FFT computation

n = len(t)
fhat = pyfftw.interfaces.numpy_fft.fft(f, n)
PSD = fhat * np.conj(fhat) / n
freq = (1/(dt*n)) * np.arange(n)
freq = freq + center_freq
L = np.arange(1, np.floor(n/2), dtype = 'int')

indices = PSD > 40
PSDclean = PSD * indices
fhat = indices * fhat

#Plot

plt.plot(freq[L], PSD[L], color = 'c', linewidth = 2, label = 'Noisy')
plt.plot(freq[L], PSDclean[L], color = 'k', linewidth = 1.5, label = 'Filtered')
plt.xlim(freq[L[0]], freq[L[-1]])
plt.xlabel('Frequency(Hz)', fontsize=12)
plt.ylabel('Power(PSD)', fontsize=12)
plt.legend()

plt.show()







#

Now I will show you my graph vs GQRX graph for the same values

#

GQRX graph

#

my graph, it is clear in gqrx there is no spike at 92.2MHz and it appears that my fourier is only scanning a bad of 100Hz?!?!?! which is really weird

#

thanks guys @young cove @granite spear

young cove
#

why n = len(t) ? Is n number of samples? In that case why not len(f)?

untold needle
#

Unfortunately that isnt the error

young cove
#

are they the same?

untold needle
#

yes

#

they are both 24000

young cove
#

so, in the sample data, are you expecting a spike at 92.2MHz? I don't know what generated the sample data/

untold needle
#

I am not expecting a spike ther

young cove
#

ok, so it's not sample reception data

untold needle
#

I want my fourier to show the same data as gqrx but mine is dodgy

untold needle
#

its something with the fourier or something

young cove
#

how did you calculate dt? I'm surprised it's a numerical constant. I thought you could calculate it

untold needle
#

its just 1/sample rate

#

surely

young cove
#

I think you could print out the freq values, etc. as you compute them to see if they look reasonable

young cove
#

if it's just 1/sample_rate, then do that calculation in the code, then you are assured it is not off by a decimal place, or one too many zeros, etc.

untold needle
#

ok sure

young cove
#

I'm not saying it's wrong, but the fewer mysterious constants there are, the better

untold needle
#

hmmmmmmmm

#

its different to gqrx but I think it is still right

#

@young cove this seems promising but still different to gqrx

#

import numpy as np
import scipy.fft
from scipy.fft import fft
import matplotlib.pyplot as plt

dt = 0.000000416666667
n_samples = 24000

with open('time.txt', 'w') as f:
    for i in range(n_samples):
        f.write(f'{dt:.20f}\n')
        dt += 0.000000416666667

# Load the voltages and times from file
voltages = np.loadtxt('voltages.txt', dtype=np.complex128)
times = np.loadtxt('time.txt')

# Define the sampling rate and center frequency
sampling_rate = 1 / (times[1] - times[0])
center_freq = 92.2e6
bandwidth = 2e6

# Define the frequency range to compute the FFT over
freqs = np.linspace(center_freq - bandwidth / 2, center_freq + bandwidth / 2, len(voltages))

# Compute the FFT of the voltages
fft_voltages = scipy.fft.fft(voltages)

# Save the results to a file
with open('fft_results.txt', 'w') as f:
    for i in range(len(freqs)):
        f.write('{} {}\n'.format(freqs[i], abs(fft_voltages[i])))

# Plot the results
plt.plot(freqs, abs(fft_voltages))
plt.xlabel('Frequency (Hz)')
plt.ylabel('Magnitude')
plt.show()
young cove
#

why write time.txt and then read it back in? Why not just use a linspace to generate times?

#

times isn't even used except you compute the sampling rate from the first two values

#

but the sampling rate is a given (what was it, 2 MHz? I forget)

untold needle
#

I mean thats just triviality, good practice I guess

#

@young cove I do believe this fourier is completely correct, I honestly dont understand why GQRX thinks I am wrong

#

maybe my fourier/gqrx fourier picked up on something that the other didnt?

young cove
#

you could bd supplying data to gqrx in some wrong way

untold needle
untold needle
young cove
#

I think you should start with some sample data that has known stuff in it

untold needle
#

of like 92MHz

#

using 2pi*Omega

#

I see

#

thats a good shout

young cove
#

yes, or real data that you get from gqrx by connecting it to the rtl-sdr, with known carriers. e.g. ok in this 2MHz part of the FM band, I can hear these stations, so I'd expect to see these carriers in gqrx (spread over the modulation width). Then save that data from gqrx and put it through your FFT

#

or sample the AM broadcast band. There you'll have fix carriers with sidebands, maybe easier to spot

untold needle
#

how do you save data from gqrx as a file?

young cove
#

i don't know, maybe not possible, but maybe not necessary. You can see those stations in real-time on gqrx. Then you record with pyrtlsdr the same band, and expect to see similar data ("there's Radio 4, there's ...", etc.)

young cove
#

the point is just to get some data that you know what it should look like, and then you can vet the processing steps. Or use a signal generator to generate a single carrier in some band, record it with pyrtlsdr (if it's just nearby, it will certainly pick it up), and look for a spike at that freq. Or generate artificial data, as you suggested

untold needle
#

yes good ideas

untold needle
#

As you predicted @young cove I took a live reading with the rtl sdr dongle and got 91MHz strong signal, 91.3MHz strong signal and 90.8MHz some signal whereas the GQRX when I imported a file, was completely messed up

young cove
#

ok, so our import attempts are no good, have you run the data through your fft programs yet ?

#

i thought the gqrx display looked kinda junky

untold needle
#

It correctly identifies a spike at 90.3MHz but misses the spikes at 91Mhz and 91.3MHz

young cove
#

so maybe your starting frequency is wrong? Like, is it center frequency or lowest frequency? Maybe the spike is from some other place in the FM band

untold needle
young cove
#

that is 90.3 is not really the signal at 90.3

untold needle
#

The spikes are clearly at 90.3, 91 and 91.3MHz

untold needle
young cove
#

on the live gqrx?

untold needle
#

yes

#

right now

#

on the live gqrx

#

maybe it needs more samples?

young cove
#

ok, so when you record the same band with pyrtlsdr, are you saying that you only see one carrier? YOu should record for several seconds

untold needle
#

right now I am doing millisecond

#

several milliseconds

young cove
#

but since it's FM, you should see _something" all the time, the carrier is always there, but it's modulated and moves around

#

well how about 0.5 seconds

untold needle
#

that is 1.2 million samples

#

that is a large text file indeed

half plover
#

For reference, spec analyzer of FM frequencies around me

untold needle
#

and my fourier

#

but gqrx and fourier dont match

young cove
#

don't use the text file. save the binary data with .save(), an then read it in with .load(), instead of .loadtxt()

#

it will be a lot smaller

#

no reason to use text

untold needle
#

correctly identifies this FM signal

#

my fourier

#

well I have to get the data over from pi ---> laptop

#

so even using .raw files is large

#

I'll go up by 1 order of magnitude

young cove
#

can't you do an scp or something?

untold needle
young cove
#

no, scp network copy program

untold needle
#

no idea

young cove
#

how are you copying it over now?

#

is the Pi on wifi now?

untold needle
#

copying text file into discord

#

then copying discord to notepad

#

then notepad to pycharm

#

very pedantic

#

extremely

young cove
#

you can just upload the binary data file to google drive or something

untold needle
#

in theory yes

young cove
#

scp mylocalfile.npy username@remotehost:somename.npy

#

what is the desktop computer you are using?

#

is it windows or Linux?

untold needle
#

windows

young cove
#

scp requires ssh server to be enabled on the receiving side

#

are you running a desktop on the Pi or just command line?

untold needle
#

discord method is superior

#

14MB

#

oh my

young cove
#

so use Google drive or similar instead, then you'll have an archive of all this, no?

#

instead of random discord files

#

and you can upload binary files, they will be much smaller

#

and faster to upload and download

#

one sample is 16 bytes in binary and about 55 bytes in ascii

untold needle
#

mhmm

young cove
#

i mean, you can do what you want, I'm just saying how I would do it.

untold needle
#

yeah I'll try that

young cove
#

the peak in the FFT plot above is centered on 9.025 MHz, not 90.3 MHz ??

untold needle
#

this is true

#

but it spreads over

#

to 90.2 and 90.3

#

is it an issue

young cove
#

yeah but off by a factor of 10 in frequency also

#

not sure you are recording the same thing

#

the x axis label seems wrong

untold needle
#

factor of 10

#

no the x axis label is right

#

910^7 = 90(10^6) = 90MHz

young cove
#

ah ok

#

is the 90.3MHz station much stronger than the others?

untold needle
# young cove ah ok

just plotted the data with 240000 samples rather than 24000 so one order of magnitude higher

#

it produced the same results

#

it likes the 90.25MHz

#

this is very annoying

#

@young cove I have no idea what the error could be

#

as my program is insisting on the 90.25MHz

young cove
#

maybe try other band slices to see if you see other FM stations at expected places. I'm still a bit suspicious. Or, expand the y asxi scale so you can see lower peaks more easily. madbodger suggested log scale

young cove
#

or just let the 90.3 go off scale and widen 0-100

untold needle
#

how do I use a log scale

young cove
#

i dunno, it's in matplotlib for sure

untold needle
#

ok

#

got it

young cove
#

your spectrume analyzer photo clearly shows one station as much stronger

untold needle
#

yes it does

#

ill plot a log scale

#

woah woah woah

#

@young cove the log scale did something devious to it

young cove
#

the x axis is different, how come?

untold needle
#

still the same

#

89.5MHz to 92.5Mhz

#

3MHz bandwith

young cove
#

is there a station at 89.x?

untold needle
#

let me ask GQRX

#

@young cove the plot looks very messy now though

young cove
#

lots of high variable noise

#

reduce the scale maybe

untold needle
#

my plot shows 89.8x

#

very wrong

#

I am not sure why

#

it is so wrong

#

maybe the offset is wrong @young cove ?

young cove
#

I don't know, you could recheck your code.

untold needle
#

I dont think anything is wrong though

young cove
#

does the spectrum analyzer show 90.3 smack dab on 90.3? My impression is that the reported frequencies might be rounded?

#

in the US, the frequencies are correct, but you might have different spacings. (like the AM band is 9 kHz in UK, and 10 kHZ in the US)

#

don't know about the FM band

untold needle
young cove
#

... but gqrx shows it smack dab on 90.3, right?

untold needle
#

well now its gone

#

the radio station must have stopped broadcasting

#

at the time ye

#

yes

young cove
#

i would say check and simplify your code

untold needle
#

now the 2 main stations broadcasting are 89.6Mhz and 91MHz

young cove
#

you could generate an artificial signal as we discussed. Generate a 90 MHz sinewave or something, or even square wave

#

if you generate a 1MHz square wave, you can check the harmonics

untold needle
#

I've tried it many times

young cove
#

try AM band, carriers don't move

untold needle
remote pond
#

yeah broadcast FM if you're sampling for only a few milliseconds, you're probably picking up the instantaneous audio-frequency deviation of the carrier, not the carrier itself

untold needle
#

Ill try this AM band

#

101-103Mhz band

young cove
#

i mean MW, 500-1600 kHz. AM in MHz is something else, like aircraft, not likely to hear much

untold needle
#

oh like very low

#

ok

young cove
#

i have to stop for the evening soon

untold needle
#

ok same here

young cove
#

check that gqrx can hear stuff there

untold needle
#

sure

#

just doing that now

#

@young cove 24MHz lowest limit

remote pond
#

there might be a WWV signal at 25MHz? haven't checked recently

untold needle
#

just seems like a bunch of noise to be honest

remote pond
#

100MHz is still broadcast FM in the US

young cove
#

tyr without log

#

also TV stations, but don't know where they are in UK

remote pond
#

oh, they're in the UK? hm, there might be a Finnish time service broadcast at 25MHz too

untold needle
#

This fourier is so mind boggling

#

@primal warren @granite spear do you guys have any examples of code to plot the PSD of a file or wave as mine is just not working.

grizzled vapor
#

I do have some jank fft code if that helps. It's for an EEG plotter thing

#

I'll send it later

#

Maybe you can play the data back slower as audio and feed it into an fft you know works correctly

#

Then you just need to multiply each frequency by the reciprocal of the slowing down factor I think

#

And you would have audible verification of the things the fft shows

grizzled vapor
untold needle
#

I'll try it though

untold needle
#

oh my god

#

@young cove it worked

#

After 5 hours of trying with the same file and changing the code, I get 2 noticeable peaks at 91 and 91.3MHz which is what I recorded with the gqrx live data

young cove
# untold needle <@329766224093249548> it worked

Great! … I am wondering if there is a Nyquist issue here as well. For a bandwidth b, Nyquist says you need to sample at at least 2b to recover the signal and avoid aliasing. But I think you said you were sampling 2 MHz (and wider) at 2.4 MHz Should be at least 4 MHz sampling frequency for 2 MHz bandwidth.

grizzled vapor
#

You don't need phase value. So you don't need complex numbers

#

You can just use rfft

untold needle
glass jungle
#

seems like you have a lot more experience with this than me

I want to use my keyboard to type messages as a kind of point to messenger. is this possible or am i just stuck with using the buttons to send pre-baked messages?

primal warren
#

Yeah, that should be fairly straightforward.

sage spire
half plover
#

Direct line of site though

sage spire
#

oh ok thanks!

normal drift
#

The range is highly dependent on the antenna and environment. Trees, hills, buildings, windows have a huge impact. If you need more than 1km you may have to pay attention to these things.

sage spire
#

Thanks!

frozen monolith
glass jungle
#

i imagine writing the interpreter that will break up a message into 256 character chunks if it goes over the limit wouldn't be too hard would it?

noble thorn
#

I have an ESP32-S3 running CircPy 8.x and I want to connect to wifi on boot.py but then use HttpServer in code.py. Is this possible? HttpServer docs show connecting to wifi in code.py and during soft reloads my ESP32 has to reconnect to wifi all over again.

#

Right now I connect to wifi on boot, the little TFT screen on the ESP32 confirms it connected.
Then my code.py runs and the top of the TFT says "No IP" and wifi.radio.ipv4_address == None

normal drift
noble thorn
#

Thank you @normal drift

sage spire
granite spear
sage spire
#

perfect, thanks!

untold needle
#

@granite spear @primal warren So the project is somewhat functional but we have one problem. They won't allow us to put rechargeable lithium ion batteries on thr balloon so is there anyway to power the pi without a UPS hat like for example using some lithium energizer batteries and stripping a micro USB or even some AA batteries. Many Thanks.

granite spear
#

Yep, that's totally possible. You'll probably need some sort of voltage regulator to produce a stable 5V. We used the Energizer lithiums on balloons before, as they're reasonably tolerant of low temperatures.

#

Do you know how much current the whole system draws? That will set the specs of your needed regulator and battery pack.

grizzled vapor
#

are you allowed to use a power bank?

#

that is the easiest solution

#

but also low temps

#

could do some stuff to it

#

EdKeyes's advice is good

untold needle
#

1.8A is the standard lipo battery hat for the pi 3b

#

but then again we cant have rechargeable batteres

granite spear
#

The AA ultimate lithiums are rated to 2.5A continuous current, so that should work fairly well. A 4-pack of those would get you around 6V which you could regulate down to 5. That would last probably a few hours depending on what the peak versus average current of the Pi is.

untold needle
#

but wait

#

@granite spear could we strip the ends off and shove it into a microusb that has also been stripped?

granite spear
#

I'm not familiar with the Pi pinout off the top of my head... Does it have an unregulated voltage input or only takes USB?

untold needle
#

though without regulation that is very risky

granite spear
#

So you'd likely want a regulator like the one linked above. And then you could wire it either directly or through a USB connector.

untold needle
#

but how do you wire it through a USB connector is my questin

#

question

#

just strip the wires

granite spear
#

Yeah, the easiest thing would be to just cut a USB cable apart. Typically the power and ground will be red and black wires inside it.

untold needle
#

and then just solder together

#

im guessing

granite spear
#

Yup.

untold needle
#

so just connect red and red and then black and black Im guessing

#

and how do we know which one is ground in this thing and supply

granite spear
#

Yes, that should be correct. Not 100% guaranteed since the colors inside a cable are not actually standardized, but pretty common. Black should be ground.

untold needle
#

do you hookup likes together

#

like ground --> ground and supply --> supply

granite spear
#

Yes, that's correct.

untold needle
#

yep

#

then the last step is just to get it to run the python script on bootup

granite spear
#

(And a good general rule. It's pretty rare to have to connect power directly to ground.)

untold needle
#

and there are tutorials for that

untold needle
#

ok that problem is fixed now

#

@granite spear @primal warren @young cove Sorry to bother you guys, for some reason, I am trying to run the python script on startup but it simply isnt working. I have tried using both crontab and rc.local but neither of them appear to work at the moment.

#

I am trying systemd right now

untold needle
#

ok I see the error it is throwing

#

Traceback (most recent call last):
File 'home/pi/Radio.py', line 13 in <module>
np.save('samples.npy', samples, allow_picle = True, fix_imports = True)
File '<_array_function__internals>', line 5, in save
File '/usr/lib/python3/dist-packages/numpy/lib/npyio.py', line 524, in save
file_ctx = open(file, 'wb')
PermissionError : [Errno 13] Permission denied: 'samples.npy'

#

Mar 14 12:41:49 raspberrypi python3[1339]: Found Rafael Micro R820T tuner
Mar 14 12:41:50 raspberrypi python3[1339]: [R82XX] PLL not locked!
Mar 14 12:41:50 raspberrypi python3[1339]: Traceback (most recent call last):
Mar 14 12:41:50 raspberrypi python3[1339]: File "/home/pi/Radio.py", line 13, in <module>
Mar 14 12:41:50 raspberrypi python3[1339]: np.save('samples.npy', samples, allow_pickle = True, fix_imports = True)
Mar 14 12:41:50 raspberrypi python3[1339]: File "<array_function internals>", line 5, in save
Mar 14 12:41:50 raspberrypi python3[1339]: File "/usr/lib/python3/dist-packages/numpy/lib/npyio.py", line 524, in save
Mar 14 12:41:50 raspberrypi python3[1339]: file_ctx = open(file, "wb")
Mar 14 12:41:50 raspberrypi python3[1339]: PermissionError: [Errno 13] Permission denied: 'samples.npy'
Mar 14 12:41:50 raspberrypi python3[1339]: Reattached kernel driver
Mar 14 12:41:51 raspberrypi systemd[1]: Radio.service: Main process exited, code=exited, status=1/FAILURE
Mar 14 12:41:51 raspberrypi systemd[1]: Radio.service: Failed with result 'exit-code'.
Mar 14 12:41:51 raspberrypi systemd[1]: Radio.service: Consumed 3.449s CPU time.
Mar 14 12:41:51 raspberrypi systemd[1]: Radio.service: Scheduled restart job, restart counter is at 7.
Mar 14 12:41:51 raspberrypi systemd[1]: Stopped Radio Service.
Mar 14 12:41:51 raspberrypi systemd[1]: Radio.service: Consumed 3.449s CPU time.
Mar 14 12:41:51 raspberrypi systemd[1]: Started Radio Service.

young cove
#

rc.local or systemd run as root. You can run as the the pi user instead. (Though as root it should just run.)

young cove
untold needle
#

I'm getting the above error though

#

Its something to do with it not being able to access the samples.npy file

young cove
untold needle
#

@young cove it should be working and the above error message shows that it was trying to work but its something to do with the samples.npy file needing access or something

young cove
#

the home directory for root is not /home/pi

#

so it may be looking in the wrong place

untold needle
#

it was /home/aryan

young cove
#

could you upload the script, using the + sign?

untold needle
#

aryan is the name of the account

#

with root access

young cove
#

you can run as a user other than root. See section 4.2.4.3 in the guide

untold needle
#

@young cove well the issue is with saving it to the file

#

the program is running

#

but it cant save to samples.npy file

young cove
#

in rc.local or whatever put in sudo -u aryan -i name/of/the/script. I think you want to & it or it will hold up the boot process.

untold needle
#

some permissions error or something

young cove
#

then it will run as aryan and you don't have to worry about what happens when it runs as root. If you run it too early perhaps the filesystem hasn't been mounted r/w yet

untold needle
young cove
untold needle
#

@young cove Thats what I will add now

#

oh wait

young cove
#

reference it with a full path: /home/aryan/Radio.py

untold needle
#

I made the rc.local file executable

#

ok

#

I made it executable though

#

sudo chmod +x /etc/rc.local

#

so I cant write to it now

#

@young cove what should I do in systemd

#

to stop the samples.npy issue

young cove
#

better: sudo -u aryan -i python3 Radio.py

#

why did you make it executable?

untold needle
#

I would rather do it in systemd as crontab and rc.local failed

young cove
#

if you arent using /etc/rc.local remote it

untold needle
#

what should I do in systemd then

young cove
#

I would say don't use systemd -- use plain crontab instead. Remove what you added to systemd. See the guide above, section 4.3: Using cron

untold needle
#

ok fine

#

but crontab is failing for me

#

it isnt working

young cove
#
crontab -e
# add this line when editing crontab
@reboot sudo -u aryan -i python3 Radio.py &
#

not sure if the & is needed here or not. I'll try to find out

untold needle
#

oh ok fine

young cove
#

oh wait, that's not necessary, holdon , don't do anything yet

untold needle
#

thing is @young cove I cant see the errors crontab is throwing but with systemd I know what is going wrong(in this instance it cant save to the samples.npy file) but in crontab I dont know what is going wron

untold needle
#

do you want to know what I currently have in my crontab file @young cove

young cove
#

remove what is in your crontab file, remove /etc/rc.local

#

undo what you did with systemd. Get it back to nothing

#

I haven't done this in about 20 years, gotta study it a bit

untold needle
#

ok

untold needle
#

I used this guy

#

for crontab

young cove
#

ok, don't remove it. I can't watch videos for this. I read.

untold needle
#

I ran my file in the terminal and it worked perfectly

young cove
#

don't trust the videos

untold needle
young cove
#

takes too long to watch a video

untold needle
#

Thats true

young cove
#

what is in rc.local now?

untold needle
#

dont know as its executable now

#

but when I execute the /etc/rc.local file it works

young cove
#

sudo cat /etc/rc.local

untold needle
#

but it doesnt work on bootup

young cove
#

sudo chmod -x /etc/rc.local will undo the executable

#

wow there is a lot of bad advcie out there

#

do this:

untold needle
#

yes there is so much bad advice everywhere

young cove
#

sudo cat /etc/rc.local what does it say?

untold needle
#

it says exactly what I added into the file

#

its the standard file

#

but then before the exit0 line

young cove
#

was it empty before or did it not exist?

#

please just show me what's in the file

untold needle
#

no it always existed

#

ok sure

young cove
#

I don't have an RPi to boot up right now

untold needle
#

discord loading on rpi

#

#!/bin/sh -e

rc.local

This script is executed at the end of each multiuser runlevel.

Make sure that the script will "exit 0" on success or any other

value on error.

In order to enable or disable this script just change the execution

bits.

By default this script does nothing.

Print the IP address

_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi

python3 /home/aryan/Radio.py &
exit 0

#

@tight sail

#

@young cove

young cove
#

change that to sudo -u aryan -i python3 /home/aryan/Radio.py &

#

that will run Radio.py as you instead of as root

untold needle
#

ok

young cove
#

did you add the "My IP address" stuff, or was it in there?

untold needle
#

already in there

#

@young cove ok I did that

young cove
#

ok, reboot

untold needle
#

alright

#

ok I did a sudo reboot

#

now waiting

young cove
#

what is your deadline on this? >March 12 now

untold needle
#

so until monday I guess

#

we had to fill in a waiver for an extension

#

it was very annoying

#

but we are still tight on time

young cove
#

can you get another team member who is a sysadmin type person?

untold needle
#

I will be in belgium by next tuesday

untold needle
young cove
#

in the whole university?

untold needle
#

@young cove ok so I just checked the last time the samples.npy file was written to and it says 12:04 and currently it is 13:25 for me

#

this means that it didnt work

young cove
#

does it print "My IP address is ..." to the syslog?

untold needle
#

how do I check the syslog

young cove
#

look in /var/log/syslog

untold needle
#

ok

young cove
#

i have to get set up here to try this myself. I'll be back in a bit

untold needle
#

should I disable the systemd program

young cove
#

don't disable all of systemd. Just disable what you added.

untold needle
#

Ill try rebooting again

#

I also removed the stuff I added to crontab

#

ok Ill try again

untold needle
#

@young cove ok nothing in syslog

#

not even IP address

#

earlier systemd was showing something

#

but now i disabled my systemd service

#

nothing is happening

young cove
#

i am trying a simple test, will be a few more minutes

untold needle
young cove
#

not yet, but I'm getting closer

#

the problem is getting the output monitored

#

still working, i'll be back

untold needle
#

running an arbitrary program on pi startup?

young cove
#

rc.local, it's working, the issue is making sure it keeps running

untold needle
#

the closest I have gotten is with systemd

young cove
#

halfway

untold needle
#

use an ampersand(&)

#

at the end of the line

young cove
#

of course, that's not the issue right now

#

just give me more time

untold needle
#

oh ok sure

#

@young cove my systemd was working but the issue was that it didnt have permission or something to save to the samples.npy file

young cove
#

systemd is large and confusing and a mess

untold needle
#

my rc.local and crontab have shown nothing in the syslog either though

#

and have no evidence of working

young cove
#

right, that's what I'm trying to fix. using shell redirection into a file properly. It's partly working, but there's no output in the file, as if the script has stopped running. debugging that

untold needle
#

ok

untold needle
#

@young cove maybe add an echo to see if its working or not

young cove
#

ok, problem was that python was buffering the output, so it appeared there wasn't any. Here's what I think will work for you in rc.local:

sudo -u aryan -i /bin/bash -c 'python3 -u Radio.py >run.log 2>&1 &'
#

I'm using /bin/bash so I can redirect the output. The -u causes python3 not to buffer the output, so you can see it line by line in run.log. You can change the name of run.log, of course.

#

this is tested on an RPi

untold needle
#

ok sure

#

@young cove have a look at this forum too

#

it says rc.local is deprecated

young cove
#

i don't care if it's deprecated, it works

untold needle
#

alright Ill try it

#

I also dont care as long as it works

young cove
#

you can try it with systemd later, but if you get this working, you know you have something that works

#

in the long run, yes, you should use something else, but you have a short time here

untold needle
#

yep

#

I agree

young cove
#

get it working, and then comment it out with # (so you can put it back), and try similar from systemd. But you have to work out how to run as aryan from systemd as well. crontab might be better to run as yourself.

untold needle
young cove
#

systemd is "after my time", I haven't had to use it for anything

brave willow
untold needle
young cove
#

rc.local does not need to be executable

untold needle
#

ok I'm rebooting now

young cove
untold needle
#

Mar 14 12:41:49 raspberrypi python3[1339]: Found Rafael Micro R820T tuner
Mar 14 12:41:50 raspberrypi python3[1339]: [R82XX] PLL not locked!
Mar 14 12:41:50 raspberrypi python3[1339]: Traceback (most recent call last):
Mar 14 12:41:50 raspberrypi python3[1339]: File "/home/aryan/Radio.py", line 13, in <module>
Mar 14 12:41:50 raspberrypi python3[1339]: np.save('samples.npy', samples, allow_pickle = True, fix_imports = True)
Mar 14 12:41:50 raspberrypi python3[1339]: File "<array_function internals>", line 5, in save
Mar 14 12:41:50 raspberrypi python3[1339]: File "/usr/lib/python3/dist-packages/numpy/lib/npyio.py", line 524, in save
Mar 14 12:41:50 raspberrypi python3[1339]: file_ctx = open(file, "wb")
Mar 14 12:41:50 raspberrypi python3[1339]: PermissionError: [Errno 13] Permission denied: 'samples.npy'
Mar 14 12:41:50 raspberrypi python3[1339]: Reattached kernel driver
Mar 14 12:41:51 raspberrypi systemd[1]: Radio.service: Main process exited, code=exited, status=1/FAILURE
Mar 14 12:41:51 raspberrypi systemd[1]: Radio.service: Failed with result 'exit-code'.
Mar 14 12:41:51 raspberrypi systemd[1]: Radio.service: Consumed 3.449s CPU time.
Mar 14 12:41:51 raspberrypi systemd[1]: Radio.service: Scheduled restart job, restart counter is at 7.
Mar 14 12:41:51 raspberrypi systemd[1]: Stopped Radio Service.
Mar 14 12:41:51 raspberrypi systemd[1]: Radio.service: Consumed 3.449s CPU time.
Mar 14 12:41:51 raspberrypi systemd[1]: Started Radio Service.

young cove
#

i have been using unix for 45 years, things change, and I don't have the same needs at the moment

untold needle
#

this was my systemd error

untold needle
#

lets see the last time the file was written to

#

@young cove nope

#

failed again

young cove
#

there should be a log in run.log

untold needle
#

last time samples.npy was written to was 13:43 and it is 14:31 for me

untold needle
young cove
#

no, I gave you a command to put the output from Radio.py into run.log

untold needle
#

yes

#

how do I check run.log

young cove
#

is there a run.log?

#

just more it

untold needle
#

more?

young cove
#

or less it or cat it

#

it's just a text file

untold needle
#

oh fine

#

ok

#

i did sudo cat run.log

#

@young cove cat: run.log: No such file or directory

young cove
#

show me the line you added to /etc/rc.local

untold needle
#

ok

young cove
#

cat /etc/rc.local

untold needle
#

yep

young cove
#

@brave willow if you are available to continue, I have to do other things

untold needle
#

sudo -u aryan -i /bin/bash -c 'python3 -u Radio.py >run.log 2>&1 &'

young cove
#

that looks ok

brave willow
#

That's going to try to write run.log in whatever directory you might be in when that script starts

young cove
#

right, but -i -u should get it into aryayn's homedir

brave willow
#

-i is an interactive shell, is it not?

young cove
#

it forces running .bash_profile, etc. that's what I want here, so the $PATH will be right

brave willow
#

Might be worth just putting an absolute path for the run.log to see if that works. I'm not sure you want an interactive shell from rc.local

young cove
#

we could also do sudo -D

#

it worked in a local test for me

#

here is how I am testing:
in /etc/rc.local:

sudo -u pi -i /bin/bash -c 'python3 -u test.py >test.output 2>&1 &'

test.py is:

import time

while True:
    print(time.time())
    time.sleep(5)
#

I reboot, and ps shows python3 running, and I see output in /home/pi/test.output

#

@untold needle you could try a simple test.py like the above instead of Radio.py for now

untold needle
#

ok

untold needle
#

I feel like with systemd I was very close

#

it was just some sort of permissions error

young cove
#

>test.output is writing the outputfile.

untold needle
#

This startup pgoram is confusing me so much

#

program

young cove
#

@brave willow if you can suggest how to do this with systemd, that woudl be great

brave willow
#

@untold needle post your .service file, and double-check the output path for the output file

young cove
#

must run as aryan, in aryan's homedir, and be spawned, because it runs forever

#

thank you

young cove
#

@untold needle so comment it out in /etc/rc.local before you reboot

untold needle
#

[Unit]

Description=Radio Service
After=multi-user.target

[Service]

Type=idle
User=aryan
ExecStart=/usr/bin/python3 /home/aryan/Radio.py
Restart=always

[Install]
WantedBy=multi-user.target

#

@brave willow

#

do you want the log/error message as well

brave willow
#

Should user be aryan instead?

#

I think you need to specify WorkingDirectory= and put your home dir in there as well

untold needle
#

my bad

brave willow
#

You can use WorkingDirectory=~to make it auto go to your home dir

untold needle
#

@brave willow ok just edited that

#

where do you add the WorkingDirectory part?

brave willow
#

In the [Service] section

untold needle
#

ok

untold needle
#

so /home/aryan

brave willow
#

So if you are using User=aryan, putting WorkingDirectory=~ will make it run out of aryan's home directory automatically

untold needle
brave willow
#

Oh, it's a tilde, on US/ANSI keyboards it's next to the 1 key

untold needle
#

my keyboard doesnt have it

#

should I just specify the homedir

brave willow
#

That should work for testing

untold needle
#

testing?

untold needle
brave willow
#

Oh, I meant you could go back and change it to ~ later 🙂

untold needle
#

oh ok

untold needle
#

as I think that is the problem potentially

brave willow
#

You can run it as root if you want

untold needle
#

how do I do that?

brave willow
#

I can't remember if you use User=root or not- might have to google on that one

#

Or if omitting it makes it run as root automatically

untold needle
#

I think omitting makes it run as root automatically

brave willow
#

So then you would need WorkingDirectory=/home/aryan instead of the ~ in that case

untold needle
#

yep

untold needle
#

wait a second

#

@brave willow I think it might have worked

#

it says the last time samples.npy was written to was 14:58 which is the time right now for me

#

It might have actually worked

#

this is a shocking revelation

brave willow
#

Woohoo!

untold needle
#

@brave willow I am 80% sure it is working now

#

but radio.service isnt stopping running

#

it is writing to samples.npy literally every minute

#

the last time samples.npy was written to literally just now

#

It is writing to it every 10-20 seconds @brave willow thats weird

brave willow
#

I think someone mentioned the writes are being buffered?

untold needle
#

its spam writing to it

#

this perhaps proves that systemd is superior to crontab and everything else

#

oh it works

#

@brave willow it works perfectly

#

it actually writes to the file

#

but it writes to it like every 5-10 seconds

#

which probably isnt ideal

#

is there anyway to add a delay @brave willow

#

probably

brave willow
#

Maybe, I'm not sure where that buffering is happening

#

Usually it defaults to that so you don't murder your I/O

untold needle
#

aha there is

#

@brave willow RestartSec=3600

#

you add this line

#

in seconds

#

so if I make that 60

#

it writes every 60 seconds

#

you add that under service I think

brave willow
#

Oh, you want the script itself to get auto-restarted every 60 seconds

#

?

young cove
#

may be easier to make Radio.py be an infinite loop and put in a time.sleep() rather than restart it

untold needle
brave willow
#

Sorry, I assumed that was the case already

untold needle
#

nope

brave willow
#

Yeah I'd do that for sure

untold needle
#

I dont know what happened actually

#

it just randomly started working

#

thats really weird

#

maybe it was the working directory thing

#

this definitely confirms systemd supremacy

brave willow
#

It's a beast but is generally pretty good at what it does

untold needle
#

I'm not so familiar with sysadmin and command line tools

#

plus I've been ill for the last few days including today so I've missed some class and doing work with a raging headache isnt particularly easy

young cove
#

ty @brave willow I was much more fmailiar with sysv init

brave willow
young cove
#

yes, it got out of hand. Not sure systemd was the best solution, amazing about the tension it created

young cove
#

people declared they would never use systemd. They started new distributions rather than using it (devuan, etc.)

untold needle
#

I was getting very stressed about it, I knew I was close with systemd to be fair, I was only missing one line it seems

untold needle
brave willow
#

systemd is pretty heavy-handed but I feel like it's in a good place now with what it provides- all the auto restart and logging features are really nice

untold needle
#

logging features are very good

young cove
#

it is very non-unix-y, which bothered people

untold needle
#

systemd>crontab>rc.local

#

in my opinion

#

from what I have tried

#

crontab and rc.local just flat out failed for me

brave willow
#

I mean, each has its use- crontab is good for periodic jobs for sure. I've used rc.local even fairly recently, but having to reboot every time to test changes is a real drag. Plus yeah, it is being deprecated, though I imagine it'll continue to work for the foreseeable future

spiral canyon
granite spear
untold needle
#

hopefully thats enough for pi+dongle

#

it should be

#

we need to add a heat sink though

granite spear
untold needle
#

Its not that short

#

It's like 3 hours

spiral canyon
#

Not sure how high you're going, but I felt inspired to make this.

grizzled vapor
#

You almost definitely want a buck converter

untold needle
grizzled vapor
#

Dissipation in watts is calculated by (voltage drop across regulator*amps drawn from reg)

untold needle
#

P=IV

#

however

#

"

#

@grizzled vapor with some calculations I thinks its likely to be more like 800mA-1A so like 3.2-4W which is still a lot

#

I'm sure we have heat sinks that can account for that much at least

#

pretty high; 30km upwards

grizzled vapor
#

You would need a beefy heatsink to keep that from overheating

#

At that point it may more of become a slug of metal with enough thermal capacity to prevent overheating during the flight

#

There are cheap buck converter modules on amazon

primal warren
#

Or reliable ones from Pololu

untold needle
grizzled vapor
#

Also it's cold up at 30km

untold needle
#

How beefy a heat sink are we talking @grizzled vapor

untold needle
grizzled vapor
#

Maybe

#

A lot of components are rated for -40 to 125 degrees Celsius

#

But vreg will still get really hot

#

Maybe you can stick an old laptop cooler on it

#

But that's overkill when you could just use a buck

untold needle
#

also if we get a buck it has to arrive literally in 2 days

grizzled vapor
#

You might be able to parallel linear regulators

#

Then each one gets less hot

untold needle
# grizzled vapor You might be able to parallel linear regulators
#

This?

#

we can feed it 6V@2A or 1.5A using 4 lithium energizers in a battery pack

grizzled vapor
#

That will work

untold needle
# grizzled vapor That will work

I think me or my friend will probably buy it ourselves to save time rather than emailing the professor/teacher to buy it for us, plus he doesnt like it for some reason

primal warren
#

Buck regulators can interfere with radio receivers, which may be why your professor wants to avoid them. However, a little separation, copper tape shielding, and ferrites can keep the interference from your receiver

untold needle
primal warren
#

You'd have to deal with the heat dissipation and reduced battery life with a linear regulator like that, as people have explained

untold needle
granite spear
#

Heh heh, maybe you'll pick up the buck frequency in your FFT, so you know that part works. 😉

grizzled vapor
#

Ferrite beads should go in between the buck and the Pi on the power line. Maybe add some decoupling caps after ferrites for more filtering

#

For copper tape/aluminum foil, just connect it to ground and wrap it around the buck

#

I think that's right

untold needle
#

thanks, @primal warren can you explain how to connect the ferrite beads and if I should add the tape to the converter or the outside of the dongle

wary arrow
#

What is gain of a receiver antenna?

untold needle
untold needle
wary arrow
granite spear
# wary arrow I mean in general, just trying to understand

It's usually a measurement of how much better or worse it is than a simple dipole receiver. An antenna with high gain would generally be directional, like a dish, so the gain tells you how much more power you can get when you point it correctly towards the source.

wary arrow
#

I wish old school Radio Shack stores were still around

granite spear
#

I actually saw one recently. Not very big, but it did still exist and have a small section of random components, too. 😁

grizzled vapor
#

Aluminum foil shielding won't hurt. I think it should just be wrapped around the buck to reduce radiated interference

#

And grounded

untold needle
#

I mean receiver is 27.5MHz with a 1MH, bandwidth

grizzled vapor
#

Well

untold needle
#

How do you ground foil

grizzled vapor
#

That's a lot of difference

#

Shouldn't be much

#

Interference

#

Actually rtlsdr won't even pick up 1mhz

untold needle
#

Yeah I didnt think so either

grizzled vapor
#

Testing is the best way

untold needle
untold needle
grizzled vapor
untold needle
#

Of the buck?

grizzled vapor
#

Kind of a tinfoil hat for your components lolol

untold needle
#

Hmm

#

Hopefully it doesn't need anything

grizzled vapor
untold needle
#

27MHz is pretty rare

untold needle
#

By the way @primal warren @young cove @granite spear we are launching it tomorrow, the only problem would potentially be if the transmitter would reach the ionosphere or not and then reflect, so range is the only issue. All the testing is done and we've given the pi in to be integrated into the balloon. Just wanted to update you guys.

granite spear
#

Good luck! 🤞

untold needle
#

to reach the ionosphere and back

#

we dont know the gain

#

its a yagi antenna though

#

homemade with some long booms

primal warren
#

Since you're not pushing information over the link, I suspect you can use averaging and filtering techniques to improve your link budget.

untold needle
remote pond
untold needle
#

@tropic fractal came up with that idea

granite spear
#

I'd ordinarily expect "watts" rather than milliwatts for that kind of distance at the least, though. Like ham radio sorts of gear.

grizzled vapor
#

Although things like WSPR beacons only have miliwatts of transmit power, but the signal can be picked up relatively far away if the ionosphere is good

#

Also because it uses FSK and a very low bitrate

young cove
#

i use WSPR with 1W and get heard 8000km away with a non-fancy antenna, and that is with ionosphere skip. Since this is line of sight, at least to begin with, it may work out

primal warren
wary arrow
#

I read somewhere that the ideal antenna length is 1/4th the wavelength. If I wanted to have a really tiny antenna (like a pinhead) for a 450MHz signal, would I need a lot of power to make it transmit?

granite spear
#

Like, the wire trace to connect to the pinhead becomes a better antenna than the pinhead itself.

wary arrow
wary arrow
#

Maybe I want a spiral antenna

primal warren
untold needle
#

Ok we launched today

#

From Belgium we are recovering the balloon from somewhere in the Netherlands or Germany

#

It's all intact

#

Anyways I will give you guys results after we analyse

#

I may have forgotten to let the antenna dangle loose, it might be taped to the side, I may have forgotten before launch. @granite spear @primal warren @young cove what will this do to it

primal warren
#

It will tend to reduce the gain and distort the pattern, depending on the shape it's in and what it's near

untold needle
primal warren
#

Standard engineering answer: it depends.

untold needle
primal warren
#

Coiled how tightly? What radius? What spacing between turns? Flat coil or conical? Is it near anything? Is that anything conductive? Is that anything radio circuitry?

untold needle
#

It's coiled like just normally

#

It's a flat coil

#

Not very big radius

primal warren
#

I'm going to guess a 24-31dB loss

untold needle
primal warren
#

Yes. Yes I am.

untold needle
#

That's good

#

Actually how bad it is

primal warren
#

I simply don't know enough about the situation to make even an educated guess, other than "it will tend to reduce the gain"

untold needle
#

My team is furious with me

untold needle
#

It's a flat coil, 1.75m of wire, 7cm radius but together at the centre, its a flat coil and taped at the centre

#

@primal warren @granite spear please help

#

My team will kill me

#

Tightly coiled

primal warren
#

I'm not sure how we can help at this point. As Julius Caesar put it "Alea iacta est." It will be what it will be. Collect the data and hope for the best.

untold needle
#

Is it very bad

#

Or medium bad

#

Or minor issue

primal warren
#

There are a few possible viewpoints here, and they're all guesswork. One is that you're already flying a bunch of untried technology, and it may have been marginal to start with. If so, it's still going to be marginal, so in that depressing scenario, it isn't much worse. The other is the "more signal, better results" mindset, and in this case, you're going to miss out on "more signal", so any results you do get will tend to be impacted.

untold needle
#

But my team don't think if it like that

#

They essentially think it's all my fault now

#

Unless we get data

granite spear
#

If there's an easy way to boost the transmit power, that might be something to consider.

young cove
#

did you test the transmitter and receiver on the ground at all?

untold needle
#

Yep

primal warren
#

Unfortunately, that's true, and it's a long-standing problem. Like the person who misses one basket gets blamed for losing the whole game.

untold needle
#

Payload been recovered

untold needle
#

And it all worked obviously

#

But transmitting in the same room ≠ doing a skip off the ionosphere

#

Even my professor is angry

#

RIP

granite spear
#

That's good! The first time I tried getting sky-brightness photos from a balloon, it landed in a swamp. Recovery isn't easy sometimes, heh heh.

young cove
#

i think it's a bit crazy you only get one chance at a launch. If this were other than a student project there would be tons of testing, and multiple runs.

#

so did the recovery get the balloon too?

granite spear
#

The balloon probably just popped.

untold needle
#

No everything was recovered

young cove
#

so was the tape still on the balloon

untold needle
#

The people who launch it have been doing it for years, they are very advanced

untold needle
young cove
#

i wouldn't take this as a personal failure, it is a system failure; the launch procedure needs a checklist and cross-checks

untold needle
#

Recovery went well, from Belgium it went to the Netherlands/Germany and they recovered it.

#

But now our results.m...

untold needle
#

How bad is the damage though

young cove
#

you just have to wait and see the data.

#

no chance to try it again?

granite spear
young cove
#

when commercial pilots prepare for a flight, they have checklists. It's not just seat of the pants

untold needle
untold needle
untold needle
young cove
#

this is a learning experience. my impression is that you did about 80% of the work. There was a lot of success: the transmitter was built, the receiver was built, the software was developed.

untold needle
#

And the thing is, it's more than likely the transmitter didn't work but we will never know because of my mistake

young cove
#

and you still don't know about the data, don't beat yourself up.

#

I thought you said you tested it in the same room?

untold needle
untold needle
#

Just 2 pieces of wire can transmit short range

#

We never tested a skip off the ionosphere

young cove
#

so there's a missing thing, which is that you should have done a rrange check outside across a considerable distance. so whose fault is that.

untold needle
#

Probably mine as a sort of team leader

#

That's so poor from me

young cove
#

how do you know it skips? it could be line of sight. I'm confused why you thought it had to be ionosphere bounce

#

The essence of learning is making mistakes.

untold needle
untold needle
#

I left as I have something to do back in the UK

young cove
#

i think you need to expect more from your team as well. Part of this learning experience is about the management structures and team cooperation that make for success

untold needle
#

So I won't be there for data collection

#

I gave them all the code though

#

Literally all they have to do is give my code a directory from the pi and it will create the graphs for them and display them one by one

#

If we don't get data I'm going to be blamed, if we get some data but its bad then I'm going to be blamed. If we get good data then everything is all right

young cove
#

there are many things that can go wrong here. For the professor to blame you alone is short-sighted. The professor should not expect success. The professor should also be guiding you toward success. It sounds like the professor does not necessarily have as much systems engineering experience as needed.

young cove
wary arrow
#

“Sink or swim” is not a good way to teach, except in special situations

grizzled vapor
#

@untold needle What organization is the high altitude balloon project for?

untold needle
#

@young cove @granite spear @primal warren only a few of the files have data, but a lot of them are showing concurrent data at 27.1-27.15MHz but its extremely strong. We must have caught a radio station for sure as it looks like it has proper shape and everything.

young cove
#

that frequency band is part of "CB radio", which is used extensively in many countries

#

so you could easily have been picking up CB'ers

untold needle
#

look at that

#

its unreal strength

young cove
#

some CB'ers use illegal amounts of power

#

what freq was your transmitter using?

untold needle
#

its like -70dB, so strong

untold needle
#

I dont think we got much from our transmitter

untold needle
granite spear