4
votes

I am trying to program a raspberry pi so it can take picture every 1o seconds and upload to DynamoDB through AWS IoT. So far I have programmed pi to take picture every 10 minutes. But I am not being able to send it to AWS IoT. I have been working on this for weeks now. Can anybody help me pleaseeee ?? I would really appreciate it. I am very new to programming. Thank you in advance

Things I have already done: I have created a thing in AWS I have also created certificate and that kind of stuff. I have also created a table in DynamoDB

I need help with what codes do I need to add on what I have right now. So the pictures taken by Pi is uploaded to DynamoDB instead of saving in pi. If you can direct me to other websites or places you know where i can get help will be really appreciated.

Here is my code

ROLL=$(cat /var/tlcam/series)

SAVEDIR=/var/tlcam/stills

while [ true ]; do

filename=$ROLL-$(date -u +"%d%m%Y_%H%M-%S").jpg

/opt/vc/bin/raspistill -o $SAVEDIR/$filename

sleep 4;

done;
1
Update your question with what you have tried already and somebody will probably help with improving/fixing it. But given you've mentioned it's a school project most will object to just handing you an answerhardillb
thank u sir. I just edited my questionChilean Miner
This looks scripted to me - chances are you'll need to use a more powerful language. But the way you will most likely want to do this is by making the payload of the MQTT message the bytes that represent the JPG, then perhaps the name of the JPG as the tail end of the topic. But you're going to have to write more code than you have here to do that. You will most likely need something on the AWS IoT side to take that MQTT message as it's received and commit it to your database. This is only one way to do this, maybe not the best. This is not particularly difficult, but requires some work.Preston

1 Answers

1
votes

I believe you want to use S3 instead of DynamoDB. The object limit in DynamoDB is 64KB, which would be a very small picture. S3 will allow you to store an object up to 5TB's in size. (Storing a lot of images S3 vs DynamoDB)

S3 has a couple SDK's available for use (aws.amazon.com/code), but since you are using a Raspberry Pi I'd assume you would want to use Python or CLI. You can find some Python examples using S3 here: boto3.readthedocs.org/en/latest/guide/s3.html. You can also find examples for using the CLI here: docs.aws.amazon.com/cli/latest/reference/s3api/index.html

These SDK's will allow you to upload images to S3 and download the images from S3 (say to a web interface or app).