3

I am an arduino beginner and I am trying to make a speed camera alert system, it would start beeping if I am above the speed limit and getting close to the speed camera. There is this website where I can get all the data I need, coordinates, direction and speed limit of every 36000 speed cams in my country.

I would need some extra memory space to be able to store all this data, would an eeprom chip do the job? and would it be able to keep up with a for loop going through all those 36000 speed cam locations to check if i am close to it and above the speed limit?

Edit: since going through all those locations on a loop would be a lot for the processor to handle, someone recommended the creation of a temp file that would narrow that list down by direction, and when that direction changed it would recalculate that temp file. This is what I came up with:

void setup() {
  int tempDirection = gpsDirection;
  writeTempFile();
}

void loop() {
  //this will recalculate the temp file when the gpsDirection changes
  if(gpsDirection > tempDirection +5 || gpsDirection < tempDirection -5){
    tempDirection = gpsDirection;
    writeTempFile();
  }

  for(temp file){
    if(distance <= 100 && speed > speedlimit){
      //start beeping
    }
  }
}

void writeTempFile(){
  //this will write a temp file with every cam with a direction that's similar the gps direction
  for(each line of the file){
    if(gpsDirection + 10 > camDirection || gpsDirection - 10 < camDirection ){
      add cam to temp file;
    }
  }
}

  • 1
    SD card and ordered data – Juraj Jun 1 at 6:00
  • EEPROM would works. SD is probably easier to keep up-to-date, and about the same price. – Gerben Jun 1 at 13:40
2

EEPROM writes are limited to about 100k cycles. They are for permanent or semi-permanent data (like your absolute speed threshhold - 120kmh, for example).

You should not store your speed camera base here.

Get a MicroSD adapter and save your data there. Looping thru 36000 speed trap locations is going to put a toll on your processor and memory. I recommend that you determine a binding box (+/- 2 degrees, for example) and save a temp file with only those traps inside the box. recheck every time your position changes a full degree (N/S or E/W).

Notice: in some countries, Brazil for example, distributing information regarding speed trap locations is illegal (obstruction of justice).

  • 1
    I edited my post adding some code based on that binding box idea of yours to improve the processing. Would you give me your thoughts on it? – Phamaral Jun 1 at 21:01
  • 1
    Been working wih GPS applications since 1995:i wouldnt work with direction, youd have to go into more complex calculations, which will eat your clock.You could store them by latitude (file21S.txt, file22S.txt, file23S.txt,...) and, depending on the lat you are on, you open the specific file. Or you could have smaller files with latLon (file22S51W.txt, file22S52W.txt, file21S51W.txt and so on) – tony gil Jun 2 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.