Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notes on setting up #1

Open
bndxn opened this issue Mar 11, 2023 · 11 comments
Open

Notes on setting up #1

bndxn opened this issue Mar 11, 2023 · 11 comments

Comments

@bndxn
Copy link
Owner

bndxn commented Mar 11, 2023

Turned on and set up LAMP server following these steps!

General goal is an interactive site that forecasts weather using different ML models.

To do:

  • Expose to external network
  • Find API to populate database with data, e.g. weather data
  • Write repo to query database and develop temp forecast

Also useful: configuring SSH to the pi (docs).

@bndxn
Copy link
Owner Author

bndxn commented Mar 11, 2023

MariaDB password just e

@bndxn
Copy link
Owner Author

bndxn commented Mar 11, 2023

Couldn't log in to WP from another computer, mentioned here, but unsure whether that's important

@bndxn
Copy link
Owner Author

bndxn commented Mar 16, 2023

Tips from Stan and Alistair - could use ngrok to set up forwarding from google domain to the pi (docs here). An example of using ngrok (but not a positive one).

From ngrok docs, my emphasis

Let's assume you've registered a domain name like example.com with a domain name registrar and you want to use it with ngrok. First you'll need to decide exactly which DNS name you want to use. Because we assign each of your custom domains a randomly-generated name under our domain to use as a CNAME record value, we usually recommend you choose a subdomain of your primary domain rather than the primary domain itself. So let's say you're going to set up foo.example.com.

To get foo.example.com working with an ngrok tunnel you'll need to perform one step within your ngrok account dashboard and one step with the DNS host for your domain name. In many cases your DNS records are hosted by your domain name registrar, but not always.

Definitions

  • DNS name: Domain Name System - the database mapping internet domain names to IP addresses. Presumably the name is the domain name side of the mapping.
  • DNS host: possibly the service that provides the domain name?
  • CNAME record value: Canonical Name (according to the primary source), a type of DNS record that maps an alias name to a true or canonical domain name.
  • Subdomain: an additional prefix on a domain name, e.g. store.example.com and mail.example.com, often used for testing different versions of a site.

Installing ngrok on the Pi (guide).

@bndxn
Copy link
Owner Author

bndxn commented Mar 16, 2023

Got the website served online, access on a different device, successfully at something like https://etc1-etc-etc.ngrok.io! Got a warning on browser, prompting to upgrade to premium. Also other pages than the homepage didn't work, they pointed back to localhost/new-page rather than updating to the https://etc1-etc-etc.ngrok.io/new-page domain. Not sure how to resolve that.

Some info about RasPi and ngrok here, including running ngrok as a daemon (a background process). Upgrading to ~$10/month would also let me reserve CNAME and remove the warnings on loading.

@bndxn
Copy link
Owner Author

bndxn commented Mar 16, 2023

Bought a temperature and humidity sensor (link) from the pi hut, some useful comments in the review from other people on getting it set up.

@bndxn
Copy link
Owner Author

bndxn commented Mar 16, 2023

PiHut links to modmypi/temper, which is probably the best to use, forked from urwen/temper.

An older Discussion on temper-python also mentions the urwen/temper repo.

@bndxn
Copy link
Owner Author

bndxn commented Mar 17, 2023

Found this guide on setting up a weather station, mentioned using adafruit for logging

@bndxn
Copy link
Owner Author

bndxn commented Mar 19, 2023

Finally fond a repo that will return the temp values: https://utcc.utoronto.ca/~cks/space/blog/linux/USBTemper2SensorToPrometheus: and doing sudo python3 temper.py --json now returns temperature readings! Probably will need to sort out the sudo but great success!

@bndxn
Copy link
Owner Author

bndxn commented Mar 25, 2023

On the logging of data, it works with sudo but I get an error

ben@raspberrypi:~/Repos/temper $ python3 temper.py --json
Traceback (most recent call last):
  File "/home/ben/Repos/temper/temper.py", line 463, in <module>
    main()
  File "/home/ben/Repos/temper/temper.py", line 460, in main
    sys.exit(temper.main())
  File "/home/ben/Repos/temper/temper.py", line 453, in main
    results = self.read(args.verbose)
  File "/home/ben/Repos/temper/temper.py", line 370, in read
    results.append({ **info, **usbread.read() })
  File "/home/ben/Repos/temper/temper.py", line 295, in read
    return self._read_hidraw(self.device)
  File "/home/ben/Repos/temper/temper.py", line 179, in _read_hidraw
    fd = os.open(path, os.O_RDWR)
PermissionError: [Errno 13] Permission denied: '/dev/hidraw1'

Then if I look at the permissions for that file,

ben@raspberrypi:/dev $ ls -l /dev/hidraw1
crw------- 1 root root 241, 1 Mar 19 22:17 /dev/hidraw1

After a bit of reading around, reset these permissions using ben@raspberrypi:/dev $ sudo chmod 777 /dev/hidraw1.

@bndxn
Copy link
Owner Author

bndxn commented Apr 23, 2023

Notes on using crontab here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant