Datalogger Usage, Serial Commands - hydrogeologger/pyduino GitHub Wiki

NOTES

  1. Onboard humidity and temperature sensor, DHT22 is attached to analog 0 do not connect analog sensor to the port if onboard DHT22 is installed
  2. Vsense: used for detecting battery voltage for offgrid deployment, attached to analog 15 and power switch 9, do not use analog 15 or power 9 if vsense is implemented
    • Please make sure both vsense jumper/shunt are connected
  3. Software UART (NOT all systems), GPIO13-sRx, GPIO16-sTx on RPI are configured

Datalogger Serial Commands & Arguments

Serial Communication Check "handshake"

This is executed by running /home/pi/pyduino/serial_session.sh in bash as a normal user.

Test if serial communication is setup correctly

abc

you will see:

abc

returned from the interface, suggesting the communication between PI and Arduino is established correctly.

Debug:

  1. If there is no return from Arduino, it is very likely that other process is using the Arduino (e.g., background python scripts) ensure they are all killed so that Arduino is ready to be used by the serial_session.sh . the second option is to reset PI either from terminal, or press the reset button on the Arduino Board.
  2. If received part of the expected string, such as bc or c, just run the command for the second time to ensure receiving abc, this is probably because the leading string was lost from the previous attachment.

Analog Sensors

Command to obtain readings from analog sensors

analog,<analog pin>

Analog Ports: 0 - 15

  • 0: Do not use if onboard DHT22 is installed
  • 15: Used in conjunction with vsense, do not use if vsense is employed

Arguments:

  • power: Power switch number
  • points: Number of readings to be stored
  • dummies: Number of readings to be discarded prior to taking actual readings
  • interval_mm: Time in milliseconds between readings
  • debug: 1, show debug. 0, do not show debug info.

Example:

analog,1,power,22,points,5,dummies,3,interval_mm,10,debug,1

DHT22 Temperature and Humidity

dht22,<Data Pin>

Arguments:

  • power: Power switch number
  • points: Number of readings to be stored, default if omitted
  • dummies: Number of readings to be discarded prior to taking actual readings, default if omitted
  • interval_mm: Time in milliseconds between readings, default if omitted
  • debug: 1, show debug. 0 or omit, do not show debug info.

Example:

issuing the following command

dht22,54,power,2,points,5,dummies,3,interval_mm,200,debug,1

Returns:

dht22,54,power,2,points,5,dummies,3,interval_mm,200,24.50,68.32,

24.5 and 68.32 are respectively the temperature (Celsius) and humidity (percent) of the ambient environment measured by the onboard sensor.

I2C Sensors

Scan I2C Multiplexer List i2c devices installed via multiplexer

9548_search

if an i2c sensor is installed in channel 0, you expect to see:

9548_search,0,TCAScanner ready!
TCA Port #0
Found I2C 0x76
TCA Port #1
TCA Port #2
TCA Port #3
TCA Port #4
TCA Port #5
TCA Port #6
TCA Port #7
Done

Reset Multiplexer

Command to reset i2c multiplexer by turning it off for a set time

9548_reset,<off duration in milliseconds>

Usage:

>9548_reset
9548_reset,400
>9548_reset,2000
9548_reset,2000

Sensor Reading

9548,<i2c channel>,type,<i2c sensor type>

Acceptable Types:

  • 5803 # 5803 water pressure sensor with channel 0x76, orginal
  • 5803l # 5803 water pressure sensor with channel 0x77, note the last letter is l for lima
  • sht31: humidity,temp
  • si1145: uv

Arguments:

  • power: *Power switch number, -1 or omit if not switching
  • points: Number of readings to be stored, default if omitted
  • dummies: Number of readings to be discarded prior to taking actual readings, default if omitted
  • interval_mm: Time in milliseconds between readings, default if omitted
  • debug: 1, show debug. 0 or omit, do not show debug info.

Example1:

9548,0,type,sht31,power,-1,points,5,dummies,3,interval_mm,10,debug,1
9548,0,type,sht31,points,5,dummies,3,interval_mm,10,debug,1
9548,0,type,si1145,debug,1

Example 2:

with the setup as above, where a 9548 sensor is hooked up at the port 0, inserting:

9548,0,type,5803,power,22,points,3,dummies,3,debug,1,interval_mm,1000,

returns:

9548,0,power,22,points,3,dummies,3,interval_mm,1000,type,5803,1000.80,1001.00,1000.70,24.51,1000.8,

SDI-12 Sensors

SDI-12,<sdi12 data pin>

Data Pins: 50, 51, 52, 53

Alternate Ports: Analog A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69)

  • 15: Used in conjunction with vsense, do not use if vsense is employed

Arguments:

  • power: Power switch number, -1 or omit if not switching
  • power_off: 1, Default turns off power switch when done, 0, leave switch on when done
  • default_cmd: "change", "read"
    • read: Obtain sensor reading
    • change: Change sensor address
  • custom_cmd: Non-Standard SDI-12 commands
  • debug: 1, show debug. 0 or omit, do not show debug info.

Example:

Take reading, no power switch used
SDI-12,50,default_cmd,read,debug,1
SDI-12,50,power,-1,default_cmd,read,debug,1

Take reading, do not power off
SDI-12,50,power,22,power_off,0,default_cmd,read,debug,1

Change address, power off when done
SDI-12,50,power,22,default_cmd,change,7,debug,1

Power Switches (Manual Operation)

Used to manually toggle power switches

power_switch,<power switch pin>

Switches:

  • 3 - 5: Digital/PWM only ports
  • 8, 9: 12 volt capable switches, pwm compatible
    • 9: Used in conjunction with vsense, do not use if vsense employed
  • 10 - 13: Reverse logic switches, default state is on. pwm compatible
  • 22 - 49: Standard 5 volt switches

Arguments:

  • power_switch_status: 0 - off. 1 - On
  • pwm_status: 0 - 255, (0 [0% Duty) and 255 [100% duty) will be equivalent to power_switch_status = 0 and = 1 respectively)

Example:

Turn on switch 22
power_switch,22,power_switch_status,1

Reverse logic switches
Turn off switch 10
power_switch,10,power_switch_status,1

Switch 8 with 50% duty cycle
power_switch,8,pwm_status,127

NOTE Current bug exists for switches 8 to 13 incorrectly operating as PWM switches if using "power_switch" command

Suction Sensor

Search For Sensor Address

Find address of suction sensor on data pin

ds18b20_search,<data pin>

Arguments:

  • power: Power switch number

Returns: Rom = <64-bit ROM Code>

Example:

> ds18b20_search,5,power,49
ds18b20_search,5,0ROM = 28 5A 40 A1 A 0 0 5A,  Temperature = 85.00 Celsius, 185.00 Fahrenheit
8-bit family 48-bit serial 8-bit CRC
28 5A 40 A1 A 0 0 5A

Read Sensor

Command to obtain suction sensor readings, readings is performed in following group/case. <1x baseline><[otno]x heated><[otno]x unheated>. There for for otno=5, will return (5 * 2) + 1 = 11 values.

fred,<address> or fred9,<address>

Address: Address is to be sent comprises of (zero-padded) 16 characters consisting of the above 64-bit ROM code, see above.

Address of Device to Send

8-bit family 48-bit serial 8-bit CRC
28 5A 40 A1 0A 00 00 5A

Addr = 285A40A10A00005A

Arguments:

  • dgin (Digital Port Number): 3 - 5, 50 - 53
    • Alternate Ports (Analog A0-15): 54 - 69
    • A15 (69): Used in conjunction with vsense, do not use if vsense is employed
  • snpw: Power switch number
  • htpw: Heater power port number
  • itv: Time in milliseconds between readings
  • otno: Number of readings when heater is on and off, i.e otno=2, 4 readings total

Example:

fred,285A40A10A00005A,dgin,5,snpw,49,htpw,48,itv,1000,otno,5,debug,0
fred9,285A40A10A00005A,dgin,5,snpw,49,htpw,48,itv,1000,otno,5,debug,0
⚠️ **GitHub.com Fallback** ⚠️