Nightscout on Linux
First, this doesn't work easily on a Raspberry Pi, which runs their own version of Linux. (I'll be playing with that next. The problem is you need MongoDB version 2.6 or later, and the Raspberry Pi version of Linux installs version 2.4. Thus, you need to compile your own MongoDB version from source. Fortunately, source is available, since it's open-source, but compiling your own usually involves also including/compiling/downloading a bunch of libraries, etc., so it can get involved.) This is under Ubuntu Linux and I was running version 20.x. Basically, you just follow the instructions here:
https://github.com/schmitzn/howto-nightscout-linux
except that where it mentions port 80, you must use port 443 ("https" means SSL encryption, so port 443). You should be using Python3. You will also probably need to install "npm" in addition to the packages he mentions. You must use https to connect, which means you need a certificate. Everything else seems pretty straight-forward and I have verified that it works, pulling numbers from Dexcom share, if you configure BRIDGE_USER_NAME, BRIDGE_PASSWORD, and "bridge" under the Enable options. Everywhere pages mention changing the "Config Vars", this maps directly to the environment variables in the "start.sh" file.
Now, on to trying to install my own MongoDB on a Raspberry Pi Zero W...
- The reason MongoDB 2.4 is installed under Raspian, seems to be because later versions of MongoDB are 64 bit and Raspian is 32 bit. You would need to install a 64 bit version of Linux, such as Ubuntu, onto your Raspberry Pi and then you can follow the instructions above.
- You can't install a 64 bit Ubuntu onto a Raspberry PI Zero or Zero W, because it requires ARMv7 processor and the Zero series is based on ARMv6.
- Probably the smallest choice would be Raspberry Pi Model 3 A+.
- You can't install a 64 bit Ubuntu onto a Raspberry PI Zero or Zero W, because it requires ARMv7 processor and the Zero series is based on ARMv6.
I finally ended up using a Raspberry Pi model 3 A+. This is an ARMv7 processor, so it can do 64 bit Linux, it has built-in Wifi, and it's still small and cheap. The system doesn't have a lot of memory, so I purchased a 32Gb micro-SD card and created a 16Gb swapfile. I installed Ubuntu 19 from here:
You'll want to configure the Wifi using "netplan" (/etc/netplan directory):
network:
ethernets:
eth0:
dhcp4: true
optional: true
version: 2
wifis:
wlan0:
dhcp4: true
access-points:
"My Network Name":
password: "My Network Password"
Then install the packages mentioned on the above web page as root, but install the "Nightscout" installation ("npm install") as a non-root user.
Finally, here's a sample "start.sh" file:
#!/usr/bin/bash
export SSL_KEY=MyCertKeyFile.key
export SSL_CERT=MyCertFullchainFile.cer
export SSL_CA=MyCertFullchainFile.cer
# environment variables
export DISPLAY_UNITS="mg/dl"
#export MONGO_CONNECTION="mongodb://MyNightscoutUsername:MyNightscoutPassword@localhost:27017/Nightscout"
export MONGO_CONNECTION="mongodb://localhost:27017/Nightscout"
export BASE_URL="https://nightscout.example.com"
export PORT=443
export API_SECRET="My Nightscout Secret"
export PUMP_FIELDS="reservoir battery status"
export DEVICESTATUS_ADVANCED=true
export ENABLE="careportal iob cob openaps pump bwg rawbg basal bridge"
export BRIDGE_PASSWORD="My Dexcom Share password"
export BRIDGE_USER_NAME="My Dexcom Share Username"
export TIME_FORMAT=24
# start server
node --no-deprecation server.js