# Wiki source code of Nightscout on Linux

Last modified by Richard Johnson on 2022/08/30 16:31
Export
Office Formats
Export as PDF
Other Formats

Select the pages to export:

select all/ none

Legend:
  Created Page
  Modified Extension Page
  Clean Extension Page

Export as HTML

Show last authors

author | version | line-number | content
--- | --- | --- | ---
|  | 1 | 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:
|  | 2 |
|  | 3 | [[https:~~/~~/github.com/schmitzn/howto-nightscout-linux>>url:https://github.com/schmitzn/howto-nightscout-linux]]
|  | 4 |
|  | 5 | 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.
|  | 6 |
|  | 7 |
|  | 8 | Now, on to trying to install my own MongoDB on a Raspberry Pi Zero W...
|  | 9 |
|  | 10 | * 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>>https://pimylifeup.com/ubuntu-server-raspberry-pi/]], onto your Raspberry Pi and then you can follow the instructions above.
|  | 11 | ** 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.
|  | 12 | *** Probably the smallest choice would be Raspberry Pi Model 3 A+.
|  | 13 |
|  | 14 | When installing "nodejs", make sure you're using a more recent version such as 16.x.x. Run "node -v" to verify your node version. If you're running an older version of Linux, you may have to manually override the installed version in order to get the version you need; currently nodejs 14, 12, or 10. I ran this command to setup apt-get to install version 14:
|  | 15 |
|  | 16 | (% class="box" %)
|  | 17 | (((
|  | 18 | curl -sL https:~/~/deb.nodesource.com/setup_14.x -o nodesource_setup.sh
|  | 19 | )))
|  | 20 |
|  | 21 | You also need to make sure you have Mongo version 3.x or later. You can setup the apt-get install for version 4.x here:
|  | 22 |
|  | 23 | [[https:~~/~~/www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/>>https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/]]
|  | 24 |
|  | 25 | (If you end up with the wrong version, use "dpkg -l" to see the package name. There were probably other packages also installed at the same time, so remove all all "mongo" pages using "apt-get remove", then check "dpkg -l" to see if any are in the "rc" state. If so, purge them with "dpkg ~-~-purge". Finally, you can reinstall the correct version again.)
|  | 26 |
|  | 27 | 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>>https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-18-04/]]. I installed Ubuntu 19 from here:
|  | 28 |
|  | 29 | [[https:~~/~~/ubuntu.com/download/raspberry-pi>>https://ubuntu.com/download/raspberry-pi]]
|  | 30 |
|  | 31 |
|  | 32 | You'll want to configure the Wifi using "netplan" (/etc/netplan directory):
|  | 33 |
|  | 34 | (% class="box" %)
|  | 35 | (((
|  | 36 | network:
|  | 37 | ethernets:
|  | 38 | eth0:
|  | 39 | dhcp4: true
|  | 40 | optional: true
|  | 41 | version: 2
|  | 42 | wifis:
|  | 43 | wlan0:
|  | 44 | dhcp4: true
|  | 45 | access-points:
|  | 46 | "My Network Name":
|  | 47 | password: "My Network Password"
|  | 48 | )))
|  | 49 |
|  | 50 | Then install the packages mentioned on the above web page as root, but install the "Nightscout" installation ("npm install") as a non-root user.
|  | 51 |
|  | 52 | Finally, here's a sample "start.sh" file:
|  | 53 |
|  | 54 |
|  | 55 | (% class="box" %)
|  | 56 | (((
|  | 57 | #!/usr/bin/bash
|  | 58 |
|  | 59 | export SSL_KEY=MyCertKeyFile.key
|  | 60 | export SSL_CERT=MyCertFullchainFile.cer
|  | 61 | export SSL_CA=MyCertFullchainFile.cer
|  | 62 |
|  | 63 | # environment variables
|  | 64 | export DISPLAY_UNITS="mg/dl"
|  | 65 | #export MONGO_CONNECTION="mongodb:~/~/MyNightscoutUsername:MyNightscoutPassword@localhost:27017/Nightscout"
|  | 66 | export MONGO_CONNECTION="mongodb:~/~/localhost:27017/Nightscout"
|  | 67 | export BASE_URL="https:~/~/nightscout.example.com"
|  | 68 | export PORT=443
|  | 69 | export API_SECRET="My Nightscout Secret"
|  | 70 |
|  | 71 | export PUMP_FIELDS="reservoir battery status"
|  | 72 | export DEVICESTATUS_ADVANCED=true
|  | 73 | export ENABLE="careportal iob cob openaps pump bwg rawbg basal bridge"
|  | 74 | export BRIDGE_PASSWORD="My Dexcom Share password"
|  | 75 | export BRIDGE_USER_NAME="My Dexcom Share Username"
|  | 76 |
|  | 77 | export TIME_FORMAT=24
|  | 78 |
|  | 79 | # start server
|  | 80 | node ~-~-no-deprecation server.js
|  | 81 |
|  | 82 | )))
|  | 83 |
|  | 84 | Note: The idea is that this can be used as a temporary Nightscout site, if we have no access to Internet. Once we have access again, the MongoDB data stored on this temp. site can be pulled and uploaded to the main MongoDB Nightscount online. (This merging can be done at any time, since it's just copying DB records over. No big deal.)

# Applications

# Tips

Did you know that you can improve XWiki? Take 5 minutes to fill this survey and help this open source project!

# Need help?

If you need help with XWiki you can contact:

- Community Support
- Professional Support

XWiki Debian 13.10.2