Best way to write remotely accessible text file from Arduino

Hello everyone,

I’m a biologist trying to get my feet wet with electronics, which are seemingly much more complicated than brains. I’m giving a lot of background on the project, so the post is long for those interested in the specifics. Otherwise, the keywords here are: data logging and remote access? I’m interested in getting opinions on the best way to upload a file either to a desktop that I can then access remotely or directly to the internet (google sheets or something?) which I can then access remotely as well.

Here’s the background- I’m a circadian biologist and I’m trying to create an actogram file to look at mouse running wheel behavior patterns. This is literally the most simple file type ever- just a text/csv file with one column for time stamp (down to the minute) and one column for amount of times the running wheel turns in that minute. My study is dealing with jet lag and scheduled exercise. Basically, I only want the mice to run during certain hours of the day, and these hours will shift over the course of several weeks as the mice are simultaneously jet lagged. If I were to do this experiment in a non-automated way, that means I have to also be jet lagged and go into the animal facility in the middle of the night to put the running wheels into the cages and then take them out. I’ve done this before, and it sucked. Hence the automation- I made an Arduino script that reads the time from a DS3231 and moves a servo with a pin attached to it into the wheel to stop it from turning during the hours that the wheel should be locked. A rotary encoder connected to the shaft of the wheel counts rotations/minute. I want to send a log of “time stamp minute, number of wheel turns in that minute” to some sort of remotely accessible file- either a Google sheet or something written to a desktop in the room that I can then screen capture remotely. This way, instead of going into work in the middle of the night to check that the locking mechanism is working, I can just wake up in the middle of the night and check my computer to see if it’s working. Even better would be for the system to just send me a notification if something goes wrong, but beggars can’t be choosers and I know I’m not that advanced.

My ultimate question is- what method of file writing/transfer should I research more to accomplish this? I want the file to be available at the end of the study so that I can turn it into an actogram, so I can’t have the data be overwritten every minute. These files get very long very fast, and since my study should be about 3-4 weeks, I’m estimating my files should be around 35,000 rows long. I don’t know if that complicates things but it wouldn’t surprise me. I’ve read about FTP, but since my institution has a network that requires both a username and password it seemed to get a bit complicated. I read something about using a router to create a new server that feeds into the main university’s network? I also saw some posts about writing a file to google sheets with some JavaScript code. I have ESP8266s as I can’t have all the devices connected directly to the computer (lots of mouse cages, so lots of Arduinos; I’ll probably have 12-16 going at one time so I’ll likely need 12-16 files?), but maybe ESP8266s aren’t the best thing to use in this situation and I’m open to getting something else. If anyone has any suggestions on which method might work best, I’ll feel better committing to one method and putting my efforts into researching one thing. I’m sure there are a ton of ways to do this, so I’m just looking for a middle ground between something decently easy to tackle as a beginner and something that will be reliable enough to let run on its own.

Thank you for reading and for any suggestions you may have! You’re helping put together a cool neuroscience experiment and potentially saving me from weeks of sleep deprivation and I appreciate it!

-Sam

If your arduino is connected to a PC, the easiest way would be to use the Serial port to simply send that data back to the PC. You will need a program on the PC to capture that output, but that can be done with any sort of freeware terminal program that will capture this data and log it to a file. If you can remotely log into that PC, you will be able to see it.

If you want to get more sophisticated (sounds like maybe not due to your experience), you can also use an arudino that has WiFi capability to connect wirelessly to the internet to save your data anywhere you want.

I would recommend you start simple. Get an arduino Uno or Nano and get it working with your encoder on the mouse wheel. Once that is done, look at sending the data back to the PC and storing it

Since you have wifi enabled controllers, maybe try MQTT. Have each cage system publish what's happening to a separate topic. On the MQTT server (Pi or PC), have something that subscribes to the feeds and pushes the data to a file or database (probably better).

If you get ambitious, add a subscriber that can let you know if there's a mouse running when its wheel should be locked down.

Thank you for the replies! @blh64, I won't be able to have them hooked up to the computer directly because I'll have a bunch of Arduinos and the room is pretty large, so I think I'll have to go the wireless route. I've got the code working up until sending the data, so luckily I've gotten this far.

@wildbill, thank you for the suggestion! I'll look into MQTT and see if I can get that working. I think that's what I had in mind but I just didn't know the correct terms to research.

Thank you both for your help!