How to get my data to actually show up in the DynamoDB?

33 Views Asked by At

I am having trouble getting my dynamoDB to actually show any data when I look at table contents.

Fairly novice to the AWS side of things so bare with me.

I currently have an esp8266 that is measuring a frequency and I have it actually uploading the data to the MQTT Test client. The code is like this in the Arduino:

void loop() {
  if (ESPserial.available() > 0) {
  String incomingData = ESPserial.readStringUntil('\n'); // Read until new line
  int delimiterIndex = incomingData.indexOf(','); // Locate delimiter
  if (delimiterIndex != -1) {
    int frequency = incomingData.substring(0, delimiterIndex).toInt(); // Extract frequency
    int temperature = incomingData.substring(delimiterIndex + 1).toInt(); // Extract temperature
    Serial.print("freq: ");
    Serial.println(frequency);
    Serial.print("temp: ");
    Serial.println(temperature);
  }
    // Prepare and publish the MQTT message
    StaticJsonDocument<200> doc;
    doc["frequency"] = incomingData; // Adds the frequency data to the JSON document
    char jsonBuffer[512];
    serializeJson(doc, jsonBuffer); // Serialize the JSON into a string
      
    client.publish(AWS_IOT_PUBLISH_TOPIC, jsonBuffer); // Publish to the AWS IoT topic
  
  }
}

Output on the MQTT looks like this and updates every second (will probably change to 5-10 seconds):

{ "frequency": 0
}

I first go to set up a rule. In this rule I have tried Partition key frequency Partition key type STRING Partition key value $frequency

And made the partition key in the dynamoDB the same thing as frequency. when I go to select this dynamoDB however, I never see any data appear. I have seen youtube tutorials and other versions of trying to do this and it seems that people use timestamp as the partition key, type, value. I tried this and did not get anything either. I was wondering if I need to spit out a timestamp myself first and then maybe a sort key for frequency if I were publishing something like this: { "timestamp": "3/20/24 11:11:11", "frequency": "100000"}

Could someone please tell me what I am missing or what I am doing wrong so that the values appear in the dynamoDB?

0

There are 0 best solutions below