WeatherPiArduino SDL_RasPiGraphLibrary Library Released

WeatherPiArduino RasPiConnect
WeatherPiArduino RasPiConnect Control Panel

WeatherPiArduino SDL_RasPiGraphLibrary RasPiConnect / ArduinoConnect Library Released

WeatherPiArduino uses the MiloCreek app RasPiConnect (or ArduinoConnect) to display and the WeatherArduino board.   To make this easier I developed the SDL_RasPiGraphLibrary for the Simple Line Graph Controls in RasPiConnect. In this control panel I use 4 different RasPiConnect Simple Line Graph Controls.  I also use one of the new bubble controls.  Aren’t they neat?  I love the status bubbles. Another version of this is being written in Python for the Raspberry Pi.

The control panel on my iPad for WeatherArduino looks like this:

WeatherArduino RasPiConnect
WeatherArduino RasPiConnect Control Panel

Since I was using four of the same graph control, I decided that it would be a good idea to write a class for the Arduino that could handle the more complex parts of the code.  Specifically, manage the strings that need to be generated on the Arduino to send to the iPad or iPhone to show the results. SDL_RasPiGraphLibrary was born.

Arduino Adafruit SparkFun
Fully Populated WeatherArduino Board

The WeatherPiArduino Board connects the WeatherRack sensors and some additional I2C devices (DS3231 RTC,  32KB FRAM and an Adafruit ADS1015 ADC board) to an Arduino.  The Arduino takes the information using the SDL_Weather_80422 SparkFun Class Library I released last week and uses the new SDL_RasPiGraphLibrary library to send the information via a web server back to RasPiConnect and the iPad.

SDL_RasPiGraphLibrary

SparkFun
SparkFun Weather Meter Sensors

Here what RasPiConnect is looking for from the Arduino in response to a refresh request from the iPad in terms of the XML payload (called response here).  This is from the RasPiConnect documentation:

Response for Simple Graph LIVE

Returns string values of data and labels to generate the graph

Returns A^^....||N^^.....

Where:
A... is floating point data
N... are labels for the X Axis

example return:
68672.000000^^17457.000000^^16954.000000^^723.000000^^10874.000000^^10367.000000^^59561.000000^^56276.000000^^6379.000000^^40763.000000||1^^2^^3^^4^^5^^6^^7^^8^^9^^10

The example return is all one line with no embedded new lines.

Using the SDL_RasPiGraphLibrary Class

The  SDL_RasPiGraphLibrary creates the graph data such as is shown in the example return above. The SDL_RasPiGraphLibrary is a class to easily generate a moving graph with the results formatted like this. It is is located on github.com/switchdoclabs/SDL_RasPiGraphLibrary. To use this class you first allocate a buffer:

char windSpeedBuffer[150]; // wind speed graph

Then you instantiate the class:

SDL_RasPiGraphLibrary windSpeedGraph(10,SDL_MODE_LABELS);

This gives you 10 values in the graph. You need to make sure that the windSpeedBuffer is large enough for the number of values you have plus the labels. Print it out and count it! And finally in the main Arduino loop, wherever you want to add data to the graph you use:

windSpeedGraph.add_value(currentWindSpeed);

And lastly, you put the latest graph string into the buffer.

windSpeedGraph.getRasPiString(windSpeedBuffer, windSpeedBuffer);

My previous article on the WeatherPiArduino Control Panel software talks about how you use this in the Local.h file of the ArduinoConnect server program.

1 Trackback / Pingback

  1. WeatherArduino Complete and Ready for the Caribbean - SwitchDoc Labs

Comments are closed.