I’m in the midst of a project to stream video from an area of my property not covered by wifi, essentially just to keep an eye on the odd kangaroo etc. I’ve successfully got a pi camera running on a pi zero, with 4g/LTE provided by a Waveshare 7600-H 4G Hat (B). Relates to my other project which Trent & Tim were very helpful with here Guide by Tim; Set Up a Geophone with a Raspberry Pi and an ADC (ADS1115) - #5 by Kevin213725
I’m running RPi-Cam-web-interface as it seems to provide better latency than rtsp although RTSP also works. wiki page, install instructions
So far so good, the pi runs the web page and streams the video over wifi great. I’ve also had no issue getting the 4G modem going and running a speedtest and pulling 30mbit down and 10mbit up, more than enough to run a live 720p stream or similar.
The issue I am having is how to get the stream from the camera accessible to the ‘public internet’ once it is off wifi. There is no ability to get wifi where I want the camera set up and I also wouldn’t mind being able to deploy it in different spots, i’m powering it off a usb power bank or similar.
The internet service is provided by a Telstra sim - my limited web/networking knowledge will show here - my understanding is that every time this kit turns on it is going to get a new ip from the network, so hosting the web service on the device and having it accessible from the public internet is a challenge. I assume I need to push the stream or image to some external hosting service or similar and have the feed stored there - which I could then access from any device that has internet access. I have some experience with python/flask but not so much with the hosting/networking side and would appreciate a pointer in the right direction.
One thought was - every time the pi turns on it runs a script that grabs the new external ip and sends that as an sms to my phone, for my use case this would be fine but i am not even sure how to reliably get an ip address, for some reason i am only getting an ipv6 address and i suspect this is not the best technical path anyway.
My immediate thought is to use DuckDNS to get yourself a free domain (something like camera123@duckdns.org). Once you have that you then hit the machine via dns and not IP. So long as your ISP doesnt use IP v6 or CGNAT, it will work just fine. I have recentkly just been through a similar process for a different application but my property is connected to the web via starlink and it uses CGNAT so I had to abandon the idea!
Im not a wizard by any means on IP v6 but I know it doesnt need to use DNS. Have Telstra started only issing IP v6 addresses on their mobile connections?
LoraWAN is no good because of the large volumes of data.
Thanks Jon. It does seem to have been issued an IPv6 address unfortunately.
I am going to look at LoraWAN to just send an image when there is movement perhaps.
My other thought is - the connection is more than capable of uploading the stream from looking at the speed test - it seems there should be some way to upload an image to an ftp or web server or similar that i host elsewhere that just refreshes every now and then and have that address stored on the pi. It gives me a chance to dig in to some web stuff which is a bit of a weak point of mine. Perhaps AWS, it just feels like there should be a solution as it has internet access.
If you have web access at the remote site you could ftp the file to another pi / machine onsite that has a IP v4 address and have that machine running a web server that pulls the content from the ftp folder and then hit that remotely (via DuckDNS (and https via Lets Encrypt if you want to do is securely)).
Of, if you are thinking permenant infrastructure, your other option could be to invest in some long range radio comms that you can push wifi over via local APs - sounds complicated but it really isnt. Thats what Ive done at my small farm, its great for wifi calling when anywhere on the property. Ive embraced the Ubiquiti Unifi products - fantastic for the money. Going down this route would probably mean at least an AP-M, SolarPoint switch, 100W solar panel, a 24V battery plus something like 2 x NanoBeam’s (one at the remote end and one at the LAN end).
This generally isn’t a bad thing when you’re serving if you have control over the router and firewall (you can route domains/subdomains straight to the host in theory, I’m not a networking god though so I never got it working), though if you are on a mobile connection, you probably don’t have the control you need to make this work.
As Jon suggested, sending data back to a machine you have more control over is a great idea. As is using a long-range microwave link (if you have line-of-sight) such as those from unifi:
All the best with your project, let us know if you need any more help!
-James
This is sort of what I’m looking at now, and I have a new issue! I have the telstra sim in the waveshare modem connecting to a WAN and it is being given an IP, which I can ping but cannot go any further, i.e I can’t access the pi at all. If I shutdown the pi but keep the waveshare modem connected and powered I can also still ping it which suggests there is some port forwarding or routing that needs to be done.
I’ve spent most of this morning digging through the waveshare/Simcom documentation without much success. I can use AT commands to set the APN and credentials, and can also access the internet via the pi when using the none-WAN profiles with AT+CGDCONT. Do i need some ‘router’ software on the pi as the waveshare is just a modem?
The Waveshare RNDIS dialup RNDIS Dial-Up - Waveshare Wiki page seems to just be for a standard internet connection with the sim, but I need to get it going with the WAN.
Thanks for your assistance @James@Jon13024 . Jon the AP infrastructure is on my todo list as well for a similar idea as is getting a more thorough understanding of the networking side
edit: thinking further, the pi is looking at the modem as in internet connection but really it is a WAN/LAN, is there something with bridging it to a lan interface?
The networking side of things is the easiest bit for me, especially with the Ubiquiti gear - reach out if you need any assistance with that.
As for the Pi and the Waveshare hat, once connected to the internet via the SIM, from a terminal can you ping by name or only IP address? Apologies if ive started too basic here, but can you ping 8.8.8.8 (google) and get a response? If so, can you then ping google.com and get a valid response?
If you can ping the 8.8.8.8 and not google.com then its a DNS issue. If Telstra are allocating you an IP v6 address they may not be allocating a DNS server address (through their DHCP server), in which case, google how to add a static IP address to your Pi (from memory it involves editing /etc/dhcpcd.conf and editing the relevent network interface… One of the configurable items is a DNS server, you can put 8.8.8.8 and 8.8.4.4 as your primary and secondary DNS servers. After a reboot you should then be able to ping an external address by name.
I should have been clearer sorry, the issue is inbound traffic to the modem - from my laptop on WAN i can ping the modem, but can’t reach the pi or a web server or RTSP running on it. I don’t actually need it connecting to the internet now as i’ll be accessing it from the WAN.
Nothing is too basic for me with networking stuff I find!
We probably need to clear up your definition of ‘WAN’.
As I understand it the Pi Zero is connected to the Waveshare hat, which gets a 4g signal from Telstra - Thats essentially the internet and would be considered a WAN conneciton.
If your laptop is connecting via its wifi to the Pi Zero via the Pi’s Wifi, thats a LAN connection.
Do you have a Pi Zero or Zero W?
Perhaps a drawing of how you are wanting / actually connecting may be helpful.
Hopefully caught before you jump at getting any parts.
While the range of LoRa/LoRaWAN are very appealing they lack the bandwidth to send photos, especially LoRaWAN (to stay compliant you have to respect rate limits and the data allocation is very small compared to a 4G connection).
Like other trail cam setups is it possible to save the video to a mp4 or another format and leverage a cloud storage service? (Google Drive, One Drive etc) to get it up and running ASAP?
There are some good instructions out there on how to successfully use rsync with onedrive from the Pi. Unless things have changed recently, Google is way to hard to sync with. I did the rsync and onedrive thing for a year and a bit a few years ago - it worked great.
I do agree with Liam though, LoraWan is not designed for these volumes of data.
Good idea re the diagram as I am not describing it correctly upon review.
So:
With wifi enabled on the pi zero (i.e sitting in the house next to me) I can ssh, run an rtsp stream, etc.
I want to be able to position this more or less anywhere without wifi connectivity and use the 4g network to access a wan (telstra.corp) - to that end I have a sim that connects to a WAN in the waveshare hat. I used minicom and the waveshare docs and have got the APN credentials working without issue, and in minicom when I run AT+CGPADDR (via the pi) the modem is giving the 10.0.10.50 address, so I know the modem is connecting to the WAN.
from the PC - I can ping 10.0.10.50 and get a response, but cannot ssh or access a web server or rtsp stream hosted on the pi. The WAN is setup to allocate that ip address to the APN credentials and it works fine in a different modem (teltonika)
I’ve used these two methods with the same result more or less
Hence my thinking that the issue lies between the pi and the modem.
Running ifconfig on the pi it pulls a 169.254.xxx.xx type address, rather than the one it should get from the modem. in minicom if i run at+cgauth, at+cgdcont i get the expected values.
Update - I have resolved the issue, and have probably been leading you all down the garden path by misunderstanding my own problem so apologies for any wasted effort from you helpful lot - I think there is possibly a bit of undocumented behaviour going on with the waveshare kit also.
I decided to just do a clean install on the pi and get my head around what was going on. After following the instructions here Raspberry Pi networked via NDIS - Waveshare Wiki I think the issue was that I was using the incorrect dialup method (RNDIS), and now using NDIS and ensuring the simcom wwan0 driver was used I am now able to SSH in. The AT command for this, AT$QCRMCALL doesn’t seem to be correctly indicated in the docs as it is critical for getting the modem to talk to the pi.
The simcom driver also seems to disappear on reboot so I need to do up a script to get that humming. It is still a mystery to me why I was able to ping the modem as the dialup command affects the modem itself and not the pi. Reading the simcom and waveshare manuals is not particularly illuminating either. Thanks for your assistance, I guess the lesson is as always to keep persisting and not throw the whole lot of kit in the creek. I will keep updating the thread with my developments in case there is any interest.
Glad you got it sortred. I hsve absolutely no phone signal here on the farm so I’ll likely not be using the waveshare hat, but regardless, Im sure this thread will be of use to others down the track.
Simple question - writing a little python script that works as an SMS interface, when it receives a certain string it will text back for e.g temp, uptime, a shutdown command to be run before power off etc. Really trying to make it foolproof for a non-technical user to query the device
I see two options:
A Cron job that runs the script sms.py every minute, checks modem if messages have been received in which case do xyz and the script terminates
sms.py runs constantly and checks for new SMS then does time.sleep(60), like it’s own little service
Both work but what is best practice considering battery life/reliability? having to wait up to 60s for the sms isn’t really an issue.
If you are keen on stretching your battery out as long as possible a microcontroller would be best to handle this type of task.
With a Pi running the overhead OS - a python script won’t make too much of a difference.
Thanks Liam - I have to run it on a pi zero at least as it’s running an RSTP stream at the same time - I suppose the answer is it doesn’t matter much then if the script is running as a cron job or as a systemd style process since the raspbian OS is running a heap of other processes in the background anyway and it’s just one more on the pile.