User Tools

Site Tools


member-projects:m0jqq_-_bpq_for_beginners

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
member-projects:m0jqq_-_bpq_for_beginners [2024/02/17 09:29] – [BPQ for Beginners] m0jqqmember-projects:m0jqq_-_bpq_for_beginners [2024/12/15 12:44] (current) – [Monitoring a Remote Battery Voltage] section added m0jqq
Line 11: Line 11:
 ==== Things to check... ==== ==== Things to check... ====
   - What s the relationship between NODESINTERVAL within the port config and SIMPLE in the config header?   - What s the relationship between NODESINTERVAL within the port config and SIMPLE in the config header?
-  - +  - Found a new command to temporarily stop ports (needs SYSOP access) <STOPPORT n> & <STARTPORT n> 
 +  - Writeup Node Help: Create a NodeHelp.txt file in /opt/oarc/bpq. This can contain anything you like. The command <help> from node level will present the contents of this file to the user. 
 +  - Mine is
  
 +<code>
 +****************************
 +*         Ask Tom!         *
 +* Always the best route :) *
 +****************************
 +</code>
 ==== Configuring your node for mail ==== ==== Configuring your node for mail ====
  
Line 401: Line 409:
  
  
 +
 +
 +==== Monitoring a Remote Battery Voltage ====
 +
 +GB7AAAX is powered via solar panels and we found there was a need to monitor the battery voltage.
 +
 +I've elected to use the an ADC on an Arduino board to read the voltage from a divider circuit in order to reduce the input to no greater than 5 volts. The Arduino is  powered and communicates via USB to the RPi.
 +
 +=== Arduino Nano ===
 +
 +== Wiring ==
 +
 +{{:member-projects:voltage_monitor_wiring.png?400|}}
 +
 +== Arduino code ==
 +
 +<code>
 +//To measure up to 15V dc
 +
 +#define inputPin A0
 +// mvpc is a measurement of actual millivolsts per count (5v ref/1064)
 +const float mvpc = 4.55;
 +//counts are the ouput of the adc
 +float counts = 0;
 +float mv = 0;
 +float multi = 3;
 +//multi depends on voltage divider setup (3 x 5k in series)
 +float output = 0;
 +
 +void setup() {
 +  // put your setup code here, to run once:
 +Serial.begin (115200);
 +}
 +
 +void loop() {
 +  // put your main code here, to run repeatedly:
 +counts = analogRead (inputPin);
 +mv = counts * mvpc;
 +output = (mv * multi) / 1000;
 +Serial.println("GB7AAX Solar Battery = " + String(output)+" Volts");
 +
 +delay (5000);
 +}
 +
 +</code>
 +
 +== Create python3 script – battMonitor.py==
 +Depending on RPI OS version, you may need to install Python and/or Python libraries
 +
 +<code>
 +cd ~/
 +nano battMonitor.py
 +#!/usr/bin python3
 +import serial
 +import time
 +sdata = serial.Serial('/dev/ttyUSB0', 115200, timeout=1.0)
 +time.sleep(2)
 +sdata.reset_input_buffer()
 +print("Arduino Connected")
 +try:
 +        while True:
 +                time.sleep(0.01)
 +                if sdata.in_waiting >0:
 +                        file = open("/opt/oarc/bpq/beacon" ,"w")
 +                        battState = sdata.readline().decode('utf-8').rstrip()
 +                        file.write(f"{battState}"+"\n")
 +                        file.close()
 +                        print (battState)
 +except KeyboardInterrupt:
 +        print("Serial Comms Closed")
 +        sdata.close()
 +        file.close()
 +
 +</code>
 +Make it executable <code> chmod +x battMonitor.py </code>
 +
 +== Create bash startup script – getBattMonitor.sh ==
 +<code>
 +nano getBattMonitor.sh
 +
 +#!/bin/bash
 +sudo python3 /home/robin/battMonitor.py
 +sleep 1
 +</code>
 +
 +Make it executable <code> chmod +x getBattMonitor.sh </code>
 +
 + == Create beacon file ==
 +
 +<code> sudo touch /opt/oarc/bpq/beacon && sudo chown linbpq:linbpq /opt/oarc/bpq/beacon</code> 
 +
 +Now is the time to test your work. Connect a variable power supply set to less tha 5 volts to the batt+ and Gnd connections of your Arduino and measure the voltage between GND & A0 It should be about one third of your variable power supply voltage.
 +Start the script with <code> ~/getBattMonitor.sh </code> After a few seconds you should see something like the following...
 +
 +
 +
 +
 +a <code> get /opt/oarc/bpq/beacon </code> from a second terminal should match and follow the output at 5 second intervals
  
  
  
member-projects/m0jqq_-_bpq_for_beginners.1708162168.txt.gz · Last modified: 2024/02/17 09:29 by m0jqq