I want to do a project where I gather data such as sunlight hours per day, as well as temperature highs/lows. Once I have gathered 24 hours worth of data, I want to hook it up to the computer to read off the values in Serial monitor. When I try and open the Serial monitor, it restarts the program wiping all the memory. I tried doing something with PROGMEM, but that didn't seem to help as it is only for constants. I want to avoid using an LCD to display data if possible.
-
Are you going to cut power before connecting to the pc? How much data do ypu expect to accumulate within those 24h? Is there just one value each for sunlight hours, temperature max and temperature min?– Sim SonCommented Oct 15, 2020 at 14:55
-
It will be powered by the 9V port, so it will not lose power. I am just storing 5 variables. Hours of sunlight, temperature high, temperature low, humidity high, and humidity low.– Austin John LippincottCommented Oct 15, 2020 at 15:00
-
1The reason you lose your data at the moment is because opening the serial port resets the Arduino. That's how it gets the bootloader going for programming. You will have to disable that to prevent the reset. There's a trace inside a jumper "RESET EN" which you can cut to disable the reset, then bridge the jumper again when you want to reprogram. Or you can add a large capacitor (100uF for example) between RESET and GND to try and negate the reset pulse.– MajenkoCommented Oct 15, 2020 at 15:24
1 Answer
Yes, this is perfectly possible. You will need to write a routine that you can trigger via Serial. For example you will listen on Serial until you get the dump
command. Then run a function that spits your variables out to Serial.
You just have to be careful where you save your 5 variables.
If stored in memory (RAM), you should avoid power loss. Therefore I'd suggest a FTDI USB-to-Serial adapter. There you just connect the TX, RX and GND wires and proceed with the Arduino IDE's Serial Monitor.
If stored in EEPROM, you can use the regular USB connector of Arduino.
-
I will not have any power loss as I am using the 9V barrel jack. Maybe there is a brief power loss once I connect it to the computer and then it switches power sources? EEPROM might be a good option. I am just worried that it will fill up too quickly after awhile. Commented Oct 15, 2020 at 15:25
-
You should not attempt to power Arduino from Barrel Jack AND USB at once.– KwasmichCommented Oct 15, 2020 at 15:29
-
-
1@AustinJohnLippincott it's my understanding that Arduinos include protection circuitry so that you CAN connect both the USB and barrel jack at the same time– Duncan CCommented Oct 15, 2020 at 19:02