There's not much time left before the end of the Remote Monitoring and Control Project14 competition so I'm rushing to get finished, or at least, nearer to finishing. I have combined the two Arduino programmes I have been working with; one from the GridEye sensor and one for an Artificial Neural Network (ANN) into a single working programme. It is a bit of a bodge in places as I didn't want to spend too much time on good solutions if it wasn't going to work. The main problem I have had is to convert the 8x8 GridEye sensor data into the 7x7 array that is the biggest array I can use with the ANN (for some reason as of yet unknown). The data comes from the GridEye as a single 1x64 element array rather than a 8x8 data structure. The ANN also uses a single dimension array of 1x49. I decided to use the top 7x7 array part of the original 8x8 array - no particular reason for this, I could have used any part. I couldn't think of a neat way of doing this so just copied the first 7 elements from each of the first seven rows, as listed below.

 

// Get the 7x7 data from the 8x8 array

    for(int i=0; i<=6; i++){pixels49[i] = pixels[i];}
    for(int i=7; i<=13; i++){pixels49[i] = pixels[i+1];}
    for(int i=14; i<=20; i++){pixels49[i] = pixels[i+2];}
    for(int i=21; i<=27; i++){pixels49[i] = pixels[i+3];}
    for(int i=28; i<=34; i++){pixels49[i] = pixels[i+4];}
    for(int i=35; i<=41; i++){pixels49[i] = pixels[i+5];}
    for(int i=42; i<=48; i++){pixels49[i] = pixels[i+6];}

 

(If anyone can think of a clever way of doing this, do please let me know.)

 

I have also normalised the data rather than having temperatures as the ANN works better. There are a number of different normalisations that I could use but in the end decided on a simple linear one. I am not expecting the temperature to drop below 5 C at night so I am subtracting that from the temperature. I have decided on 30 C as my maximum temperature as this is about the maximum temperature a cat has. Even if the temperature of the cat was higher, all it would do would be to create a normalised value slightly greater than 1.0, and the ANN would still be O with that - one of the beauties of ANN is the ability to cope with different data ranges. So I am dividing the values by 25 (which is 30 - 5 = 25), using the code fragment below.

 

    for(int i=1; i<=49; i++)

      {

          pixels49[i-1] = (pixels49[i-1] - 5.0) / 25.0;

          Serial.print(pixels49[i-1]);

          Serial.print(" ");

        if( i%7 == 0 ) Serial.println();

      } /* for */

    Serial.println();

 

This produces normalise data arrays such as that shown below.

 

 

The data under the test 'Inputs' is the 7x7 normalised array being provided to the ANN This data was taken during the day when the room temperature is about 22 C so the data is all between about 0.6 and 0.7. This is not quite what I was expecting, mainly because I didn't think about it enough. Testing during the daytime inside isn't all that applicable to when it is used outside. This is illustrated at the bottom of the image above where the test 'Output = 0.77 which is effectively a probability of there being a cat at 77%, which is obviously not correct. This is because the training data has been created assuming a background temperature of 7 C. I will need to try it out tonight outside once the temperature has dropped.

 

However, just to show that something happens, the image below shows the data output when I put my hand in front of the sensor, which has a tmeprature of about 27 - 29 C so creates array values nearer to 0.8 or 0.9 or even higher.

 

The output is now shown as 0.90 which is indicating there is a 90% probability that a cat has been detected. Well, at least it has detected a hotter body which would be enough for this sensor system.

 

I'll see about trying this out tonight and see what data can be obtained.

 

Dubbie