Oct 6th
This image please: I have a weather station. It takes in information, real-time. Every hour I want all the standing information put in a database. Then I want it to sleep for an hour. My project involves magnetic north. I want it to wake up every fifteen minutes, turn on the 4.5-volt laser, take a reading and go back to sleep. I want the data, actually, just one number, put into a database with the UNIX time. I use Python and sqlite3 and have used this system successfully with other projects.
The whole is working, to a first approximation, fine. But the database is picking up extra lines. The C++ is sending line breaks to the python and the Python is adding extra rows. Like 20 to 200 blank rows,
I am doing the delay with a ‘for loop’ and then a “delay(60000)” with every iteration. So, the i=i+1 value is the number of minutes. (60000 milliseconds in a minute)
I am pretty sure that the handling of the delay is the problem (not the Python). If I change the 60000 and the iteration of the ‘for loop’ the number of blank lines changes.
I tried a straight “delay(900000)” and the database picked up 298 blank lines.
Should I just go toward a millis() function?
I have included the C++ (I use a mega board because it has the extra digital inputs.)
//This is the delay platform
//my delay functions are not working correctly. I am just now understanding it!!
// this is also a practice platform for the laser relay (4.5V)
const int relayPin = 8; //output... at intervals, the laser is turned on
int i = 0; // for loop variable
void setup()
{
pinMode (relayPin, OUTPUT);
digitalWrite (relayPin,HIGH); // relay high is the default off; normally open is open
Serial.begin(9600);
Serial.println("hello world i is 2 the deklay is 60k"); //this is a 2 minute daley and my wake up for the python
numberForPython = 777777;
}
void loop() {
Serial.println (numberForPython); //this goes out to Python "start Python signal"
numberForPython = (numberForPython + 1); // this goes into the database as a series of numbers
delay (900);
/*
this is the delay
* what is the interval?
*
* the ' i ' in the 'for loop' is the number of minutes
and the 'delay' is the 60 thousand milliseconds for one minute
*/
for (i = 0 ; i < 10; i++) {
delay(60000); // this would be a ten minute delay
}
/* this is the locaion of the 40 LDR sensors. I have it as 40 'if' statements.
* only one should go positive and that is sent out to Python and put in a
* database.
*
* THE PROBLEM IS THAT THE ARDUINO IS SENDING OUT LINE BREAKS THAT GO INTO (Python) THE
* DATABASE AS EMPTY ROWS WITH JUST THE UNIX TIME.
*
* If I modify the above 'if' loop the number of rows changes. I can find no relationship.
* Elliminating the 'if' statement (just a big 'delay()') seems to produce more lines!
*/
digitalWrite (relayPin, LOW); // low is on .. green light on turn on the laser
//the green light should come on (module JQ3CF- 05vDC works fine)
// for a few seconds LASER ON
delay(1000);
digitalWrite(relayPin, HIGH); //turns off the laser HIGH is off (module JQ3CF- 05vDC works fine)
Serial.println (numberForPython); //goes out to python
}