Self-hosted Development

This example shows how to set up and use simple and inexpensive computer hardware (Android and Raspberry Pi) for monitoring temperature.

For Android < 5.x GNUroot worked well, but not as well since (for pascal). A new program (UserLAnd)  showed up June 2018 which might help.

RPi Zero Wireless Temperature Sensing Development Kit
Hopefully available soon from friends (in Lawrence, Kansas, USA) who help on the phone...
- Raspberry Pi Zero Wireless and case
- Micro SD card with console Debian (see next paragraph)
- Micro USB power supply
- DLP-TEMP-G 3-Channel Temperature Acquisition Board
- Micro USB powered hub
- USB keyboard
- USB mouse
- Micro HDMI to regular HDMI cable (HDMI display extra)

Instructions for minimal console Debian on RPi Zero Wireless
- Get NOOBS LITE here (just 32 MB) and use PC to install on SD card (at least 2 GB) per this
- Set up Zero hardware (similar to this, but a little different as need USB hub and several micro to standard cables). Note that wireless keyboards and mice will work later, but for NOOBS you need the wired variety!
- When boots up, login to WiFi then select Raspbian Lite (just 1272 MB) to install on the SD card.  Select language and keyboard. When reboot the user is pi and the password is raspberry.
- sudo apt-get update
- sudo apt-get upgrade -y
- sudo reboot
- sudo dpkg-reconfigure tzdata
- sudo raspi-config (can configure auto log in)
- sudo halt (to shut down before power off)

Parts for an embedded temperature sensing kit
- Raspberry Pi Zero Wireless and case
- Micro SD card
- Micro USB power supply
- DLP-TEMP-G and cable to micro USB


Android - Check out C4Droid on the play store, uses tcc (if don't install anything else)

RPi - sudo apt-get install tcc (then use nano)


Android - Use the cloud?

RPi - to be added here ASAP


New wiki page for Android and RPi

To install Free Pascal 2.6.4 on the RPi:
- sudo apt-get install fpc

To use Free Pascal (some options are listed here)
1) ppcarm (see first two examples here)
2) fpc
3) fp (starts text mode IDE)

Notes on using the Free Pascal Text Mode IDE:
- Alt-F calls up the file menu
- How enable mouse?

Here is unfinished code for software that sends emails (and texts) with the temperature (and power status) every 3 hours.
- The arm code has the latest dlptempg.pas so be sure to update the older x86_64 code from that.
- This code will hopefully be uploaded later to this page and this page.  Your comments and feedback are appreciated very much!
- The CtrlTerm.pas code included is a version that provides configuration with command line parameters.

Configuration notes for the above code:
- In a terminal in the folder, compile 2 programs:
- Clean dcu folder:
- The file (in bin) must be edited for your email, and the file must only terminate each line with LF (not CR/LF) or you'll get this error: 43: Syntax error: end of file unexpected (expecting "then")

To test:
- cd bin
  sudo ./dlptempg - so creates message.txt file (first temp reading is wrong). After file is created do Ctrl-C - to stop dlptempg
- Check that
    sh 0 subject message.txt (sends text)
    sh 1 subject message.txt (sends email)
  both run OK
- Return to home folder
- sudo nano .bashrc (then add this at the end of the file: )
if [ $(tty) == /dev/tty1 ]; then
  cd /home/pi/yourfolder/bin/
  sudo ./dlptempg
  cd ..
  cd ..
- Should now work to auto login and auto start the program. Can press "s" key at any time to send both text and email (to test). Ctrl-C still works to stop the program.

Other ideas: use bluetooth to change settings, watchdog, do same for the BeagleBone, monitor sump pump operation...

Use bluetooth (from phone) to reboot the Zero. Copied instructions from here (most by Douglas6 - Thanks!).

- Start by adding the Serial Port Profile. Edit this file:
$ sudo nano /etc/systemd/system/dbus-org.bluez.service
- Add a ' -C' compatibility flag at the end off the ExecStart= line, and add a new line to add the SP profile. The two lines should look like this:
ExecStart=/usr/lib/bluetooth/bluetoothd -C
ExecStartPost=/usr/bin/sdptool add SP
- Save the file and do this in a terminal:
$ bluetoothctl
[bluetooth]# discoverable on
[bluetooth]# quit
- Create a new file with sudo
$ sudo nano /etc/systemd/system/rfcomm.service
- enter the following:
Description=RFCOMM service
ExecStart=/usr/bin/rfcomm watch hci0 1 getty rfcomm0 115200 vt100 -a pi
- Save the file, then enable that to start at boot time by doing this in a terminal:
$ sudo systemctl enable rfcomm
- Reboot by doing this in a terminal:
$ sudo reboot
Pair and Connect on phone (using BlueTerm on Android). then do the above command.

For power detection (first pass showing Micro Center prices), run the RPiZw (and your WiFi router) on a battery backup system (~40 US dollars). Purchase a 5V switching power supply (QVS ARUSB-2.5A is ~11 US dollars) to plug into raw power, a 1.5K ohm 1/4 watt resistor, and a Micro-USB extension cable (QVS CC2217-03MF is ~9 US dollars) to cut in half then install the jack onto the DLP-TEMP-G sensor 2 input (along with the 1.5K resistor between Data and Ground so is a pulldown that matches the DLP-TEMP-G onboard pullup resistor).  Change the dlptempg.pas code for the voltage 5 places from 0.5 to 3.75 (should use a constant).  Run the dlptempg program (without the raw power applied) and verify that the voltage displayed every ten seconds is about 2.5V.  Plug in the raw power and it should change to 5.0V.  The dlptempg program is intended to ignore short power interruptions.

Other things to check out:

New! 1) Ultibo is getting closer!

2) - Using Forth

3) APDE (Android Processing Development Environment - Java). In Sept. 2017 (on Android 7.1.1) Load Sketch | Examples | Sensors | Accelerometer works very nice!  See Getting Started. Features Overview.

Return to home page.

Please share your ideas, comments and suggestions. Thanks!