camalie networks Wireless Monitoring and Control

 

 

Camalie Networks System 3 (CS3)- Open Source

Disclaimer -- Use this code at your own risk! There are no guarantees of fitness for any use. This code may unknowingly infringe other companies' patents. It may have bugs. It is intended to show what is actually required to build a practical, high value Wireless Sensor Network for Agriculture

Why OPEN SOURCE? -- The value of such a system is not in the code. Its in the data it produces and the decisions it supports. Such a system also provides value in the form of labor saved and human errors avoided. The code is only a small fraction of what is required to achieve this value. Hardware, Installation, Training, Field Maintenance and Relationship with the Grower are all required for such a system to be successful. Putting the code in open source makes such a system more maintainable and gives users a degree of independence from a single provider. Camalie Networks is a small company with a small support area and no plans to grow but, would like to see its technology used more widely. Most of the code is modifications of other folks' open source code. Think of this as a contribution back to the open source community and growers for the greater good.

CS3 Gateway:

cs3gatewayBuildScript_v2 This Script explains how to build a CS3 gateway. The platform of choice for this is a pcDuino V1 but, other ubuntu Linux platforms should work as well. The pcDuino which is ARM based with 1 GB of RAM and 4GB of flash for code storage sells for $59.00.

snetbase .pl

This program, snetbase.pl, (sensor-network-base station) receives data from XBee remote nodes and pushes it to cloud server(s). It also receives commands from cloud servers such as actuation, configuration and query commands and passes them on to XBee nodes. It provides a gateway between an XBee 900HP Digimesh network and the internet. This code is compatible with a CS3 shareware cloud server and can be run on the same linux platform as the server to form a stand alone offline monitoring/control system. Perhaps useful for maximum security applications. Runs well on a pCDuino from LinkSprite or any Ubuntu Linux platform. This code sets up the CS3 network to wake for 3 seconds every 2 minutes but can be easily changed.

snetbase This is a shell script to put into /etc/init.d which is used to start snetbase.pl when the CS3 gateway boots.

snetbaseWatch This is a shell script which is put in /etc/cron.hourly which runs every hour to check that snetbase.pl is still running, as evidenced by it touching file /home/ubuntu/cs3code/pushed within the last 20 minutes. This is an ugly hack to keep the code running. It seems to be less needed with the newer revisions of snetbase.

pcDpush .pl

pcDpush.pl is a PERL program that runs on a pcDuino-Nano to push data from the pcDuino-Nano or attached arduino shields to a Camalie Networks open data web server. HTTP protocol is used to push the data which is then stored on the server in an RRDTools database. An open source program, drraw.cgi, running on the server can then be used to access graphical
trend charts of the data and/or csv files with the data which can be imported into a spread sheet. Open Data can be seen by other users but, cannot be deleted by them.

pcDpush Shell script to start up pcDpush.pl on boot. Put this file into /etc/init.d and make it executable.

pcDpushWatch This is a shell script that when put in /etc/cron.hourly will run hourly and restart pcDpush if it has hung.

pcDpush_BuildScript This script describes how to install pcDpush.pl and associated files.

cpu_id This is a small executable which extracts the CPUid from a pcDuino3-Nano. It is called by pcDpush.pl. It should be copied to /home/ubuntu/cs3code. More information about it and how to build it can be found on the LinkSprite site here.

cpu_id.c Source code for the file above.

ttyS1init.cpp ttyS1init executable This code initializes the ttyS1serial port on a CS3 gateway pcDuino for communication with a connected XBee base radio.

XBeeReset.cpp XBeeReset executable This code resets the XBee base radio in a CS3 gateway which sometimes hangs.

CS3 Web Server:

cs3ServerBuildScript8c This file describes how to build a CS3 web server on a computer running Ubuntu Linux. Most of the software to be installed is open source shareware packages that come with Ubuntu including rrdtools, drraw, sqlite and PERL modules which enable communication with rrdtools and sqlite. There are a small number of CS3 web pages which provide the CS3 Alerts and Map. For best end user speed experience and to handle many users connected at the same time it is best if this server software runs on a high performance machine with plenty of memory. As of January 2016 this is something like a Gateway or Lenovo Desktop with intel i7 6700 processor, 6-12 GB of RAM and 1-2TB of disk space. These machines are selling for $600 at Fry's these days.

snetServe3 .cgi

This is the CS3 webservice which interacts with remote networks to receive data and send actuation commands. It responds to http (port 80) requests from snetbase.pl running on a CS3 gateway. It stores data and metadata in an sqliteDB which it uses to communicate with a web app with a U.I. for control. This code runs well on any PC running Ubuntu 10.04 or later with Apache2, RRDTools and sqlite installed.

cs3Control .cgi

This .cgi code file displays a list of nodes currently sending data to the CS3 server and provides a simple command form which can be used to send commands to nodes in the list. Commands are queued in an sqlite table until the specified node sends a request for command at which point snetServe3 searches the table for any commands for that node and if found replies with that command from the sqlite table.

To be posted when more stable: CS3Alerts.cgi, CS3Namer.cgi, CS3Map.cgi

CS3 Field Stations:

cs3StkAsense15f.ino Arduino code file that will run on an arduino stalker from SeeedStudio and send data through a CS3 network to the web. This code Drives digital pins and samples analog inputs once per network sleep cycle. Suitable for resistive sensors like Watermark and thermistors as well as voltage outputing sensors like pressure sensors and Maxbotix ultrasonic range finders. Fixed resistances and terminal blocks are normally installed on an arduino proto shield along with a few wires. Wiring and pin configuration is described in the code comments.

cs3WaterMeter .ino This Arduino code counts pulses on interrup and stores them to EEPROM in case the node loses power. When the node's power recovers the node restores the count from EEPROM and resumes counting.

cs3Manifold2.ino This Arduino code is intended for a node that is to be stationed at an irrigation manifold for monitoring of the irrigation system. This code lengthens the analog sense times of the Asense15f code to enable correct readings from the Maxbotix ultrasonic water level sensors and pressure sensors.

OS4valveAct3.ino Arduino code file that will run on an arduino stalker from SeeedStudio with a RaysHobby Open Sprinkler OSBee (CS3-4Vact) 4 bistable valve actuation shield installed. It receives commands from the web across the CS3 network and switches bistable solenoid valves open and closed for specified durations. No additional power supply is needed.

cs3Relay3b .ino This Arduino code is used for closing a 110V relay which can be used to controling a pump or a 24Vac solenoid valve. The pump or valve can be turned on for a fixed time. The node does the timing count down and deactivates the pump or valve even if radio connectivity is lost. Power failure in the node will result in the relay opening and the valve or pump shutting off. For pump control the 110V relay controls current through a larger 220V relay which switches power to the pump. The command protocol is described in the code.

io, interrupt Standard AVR Library code used by the arduino sketches above.

Other code available but not yet posted includes Code for a node with a Spark fun GPS shield to monitor and record vehicle paths during spray and other operations. There is also code to drive a 16 x 2 line display shield which can display text messages from the web or sensor data from local sensors on the CS3 network. This is handy when you need to know the fill level of a tank when you are at a remote pump or valve station. This display does not require an internet connection to report data.

Terraduino AtMega 2560 based node with a Davis Weather station code from SenseTerra

XBee Radio Configurations:

XBee 900HP FCC certified radios with SMA connector are used.

N1165T19Base115k2m.pro CS3 Gateway Base radio configuration.

N2249T21Node.pro Typical CS3 field station node radio configuration.

N1325T0TerrWSNode.pro Terraduino Weather station node radio configuration.

Note: file extentions were removed from the above files to allow browsers to display them rather than run them. To run them copy the code to the location where you want to run them and add the appropriate extention back to the file and enable execution.

   

Send mail to mholler@pacbell.net with questions or comments about this web site. 
Copyright 2016 Camalie Networks LLC
Last modified: 2/14/16        Note on pronunciation:  Camalie rhymes with "family"