mix archive.install https://github.com/nerves-project/archives/raw/master/nerves_bootstrap.ez
mix nerves.new npp_weather_bot --module NPPWeatherBot
cd npp_weather_bot
export MIX_TARGET=rpi3
you'll need to do this every time you open a new shell
See the nerves_interim_wifi
module and
the hello_wifi
example project.
On ACU campus wifi you will need to use the "BasicACUwifi" network. Connecting to this network utilizes a captive portal which will require you to register your devices MAC address using your ACU credentials. The easiest way to do this is by:
- Get your raspberry pi’s MAC address
- Boot into Raspbian or some other flavor of Linux
- Open the terminal (if in the GUI)
- run
cat /sys/class/net/wlan0/address
- Go here (while behind the ACU firewall)
- Sign-in using ACU credentials
- Enter a Device Name; Device Type: Other; MAC Address:
If your weather station will be running on a different network be sure to change the config
setting for :ssid
, :key_mgmt
, and :psk
We are using the DS18B20 temperature sensor
There are two models that were purchased The longer sensors wires are: red - 3.3v, yellow - GND, and green - Data The shorter sensors wires are: red - 3.3v, black - GND, and yellow - Data
You need a 4.7K Ohm pull-up resistor between V+ and Data. Here’s a nice article explaining pull-up (and pull-down) resistors: link
We will need to enable the OneWire protocol by following the
Advanced Config instructions
to get a custom version for fwup.conf from the rpi3 system in deps\nerves\_system\_rpi3
This will in turn allow use of a custom config.txt where we can uncomment this line:
dtoverlay=w1-gpio-pullup,gpiopin=4
We are using the Twitter client library ExTwitter (docs)
The :consumer_key, :consumer_secret, :access_token, and :access_token_secret have been shared in the NPP Outline Document or you can email me for them directly. You can hard-code them in config.exs or preferably export them to your environment.
Feel free to play around with pattern matching in
pick_saying/1
and make your own sayings for your station. Also make sure you have your correct station number in config.exs
WeatherServer is a GenServer that simply calls into the Tweet module, but this allows us to supervise it in our main application so it can be restarted if it ever crashes.
We are using the job scheduler library Quantum (docs)
Each station will be given a schedule. Go to crontab.guru to better understand the cron schedule expressions.