0

I'm fairly new to Arduino. I'm working on a project where I'm making HTTP requests using a python code and this lets me read and write to a JSON file on my desktop. I have an Arduino with sensors that records values and I want to take those recorded values and update them to the JSON file on my desktop in real-time. I looked online and many suggested using some Arduino library, but it was only for reading. I'm still confused about reading and writing to the JSON file on my desktop. I appreciate any help to guide me in the right direction. Thank you.

5
  • The Arduino cannot just write to your PCs storage. There must be some kind of program on the PC to do the writing. Thus you don't need an Arduino JSON library. You could let your python code, that already writes to the JSON file, also read data from the Arduino (for example over serial) and put that data into the file – chrisl Nov 9 '20 at 16:22
  • @chrisl is there a reliable resource you recommend that demonstrates how the python code can read data from the Arduino. From a quick search, I was able to find some examples of communication over serial. – Mike Nov 9 '20 at 16:53
  • The way the PC and the Arduino communicate depends on the used interface. If you connect the Arduino via USB, then it will be Serial. If you have a Wifi Arduino or an Ethernet shield, you could also send data via network connection. But it seems, you want serial here. I have no source, but you can google it. Probably you also should read Majenkos take on Serial on the Arduino. – chrisl Nov 9 '20 at 17:54
  • When googling you can separate the Arduino from the PC, meaning, that you can google for something like "python reading serial" and then "Arduino serial" individually, instead of googling it together. Though you might find good resources with that too – chrisl Nov 9 '20 at 17:55
  • Thank you, I'll check it out. – Mike Nov 9 '20 at 19:24
1

The Arduino cannot access files on a desktop computer.

However you can write software on your computer (you already use Python, so why not use that?) to accept information over Serial, process it, and store it in any way you like (including JSON), or return data from the computer to the Arduino if needed.

1
  • These were links I was looking at, thank you. I'm not too familiar with the coding to do this so I'm relying on sample codes that I can modify for my needs. – Mike Nov 9 '20 at 22:29

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.