<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ken Cameron</title>
    <description>The latest articles on DEV Community by Ken Cameron (@ken_cameron111).</description>
    <link>https://dev.to/ken_cameron111</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2424414%2F5268c4c9-9a1e-4807-99ec-83a78a167185.jpg</url>
      <title>DEV Community: Ken Cameron</title>
      <link>https://dev.to/ken_cameron111</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ken_cameron111"/>
    <language>en</language>
    <item>
      <title>Using AWS Lambda as data processing for any IoT project.</title>
      <dc:creator>Ken Cameron</dc:creator>
      <pubDate>Fri, 20 Dec 2024 08:18:10 +0000</pubDate>
      <link>https://dev.to/ken_cameron111/using-aws-lambda-as-data-processing-for-any-iot-project-3jgl</link>
      <guid>https://dev.to/ken_cameron111/using-aws-lambda-as-data-processing-for-any-iot-project-3jgl</guid>
      <description>&lt;p&gt;To start something, proper planning and preparation is needed. This idea came to me when I had an elective called Internet of Things. It wasn't taught well😄 but it gave me this idea. A simple moisture checker can update you when you need to water your plants.🪴 Using Aws Lambda, we could use their server instead of using laptops and keeping it on for a long time when it could be used for something else. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why AWS Lambda?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Costs: It's fairly cheap and it has an option where the first interactions are free. So, for someone who wants to start but is tight on money, AWS Lambda is a good option. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Real Time Processing: With servers that are always on, it can process data in real time, do actions based on the received data, and send notifications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scalability: In time, if you want to increase this project, AWS Lambda can scale well into anything that you need. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Integration with other AWS Services: Since AWS provides a lot of services, it acts as a one-stop shop for your needs. No need to look anywhere else if the services you're looking for is already here. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The IoT Use Case: Temperature Monitoring 🌡️
&lt;/h2&gt;

&lt;p&gt;Let’s imagine a moisture monitoring system. Sensors periodically send data to AWS IoT Core, which triggers a set-up AWS Lambda function to process and store the data in DynamoDB. The Lambda function also sends notifications to users.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-by-Step Guide to Deploy Your IoT Project 🚀
&lt;/h2&gt;

&lt;p&gt;1) Set Up AWS IoT Core 🛠️&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create an IoT Thing: Navigate to the AWS IoT Core Console and define your IoT device.&lt;/li&gt;
&lt;li&gt;Generate Certificates: Download the device certificate and keys for secure communication.&lt;/li&gt;
&lt;li&gt;Attach Policies: Grant your IoT device permission to publish and subscribe to topics.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2) Write the Lambda Function 💻&lt;br&gt;
Create a Python function to process incoming IoT data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import json
import boto3

def lambda_handler(event, context):
    # Parse the incoming event
    payload = json.loads(event['body'])
    temperature = payload['temperature']
    device_id = payload['device_id']

    # Store in DynamoDB
    dynamodb = boto3.client('dynamodb')
    dynamodb.put_item(
        TableName='TemperatureReadings',
        Item={
            'DeviceID': {'S': device_id},
            'Temperature': {'N': str(temperature)},
        }
    )

    # Send an alert if temperature exceeds threshold
    if temperature &amp;gt; 30:
        print(f"ALERT! High temperature: {temperature}°C")

    return {
        'statusCode': 200,
        'body': json.dumps('Data processed successfully!')
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3) Connect IoT Core to Lambda 🔗&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a Rule: In AWS IoT Core, create a rule to trigger your Lambda function.&lt;/li&gt;
&lt;li&gt;Define the Topic: Specify the MQTT topic your device publishes to (e.g., sensors/temperature).&lt;/li&gt;
&lt;li&gt;Add the Action: Link the rule to your Lambda function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;4) Deploy the Lambda Function 🚀&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Upload your code as a .zip file or use the inline code editor in the AWS Management Console.&lt;/li&gt;
&lt;li&gt;Set the necessary environment variables and configure a trigger from IoT Core.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;5) Test Your Setup 🧪&lt;br&gt;
Publish a test message to the MQTT topic from your IoT device:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mosquitto_pub -h &amp;lt;Your IoT Core Endpoint&amp;gt; -t "sensors/temperature" -m '{"device_id": "sensor1", "temperature": 35}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final Thoughts 🌟
&lt;/h2&gt;

&lt;p&gt;Deploying an IoT project with AWS Lambda is a game-changer for developers, offering scalability, cost-effectiveness, and a serverless experience. By combining IoT Core and Lambda, you can build responsive and intelligent systems that grow with your needs.&lt;/p&gt;

&lt;p&gt;Happy Holidays! ☃︎🎅🎄❄️☃️🎁🦌&lt;/p&gt;

</description>
      <category>python</category>
      <category>mqtt</category>
      <category>aws</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Simple game to kickstart things...</title>
      <dc:creator>Ken Cameron</dc:creator>
      <pubDate>Tue, 17 Dec 2024 09:51:56 +0000</pubDate>
      <link>https://dev.to/ken_cameron111/simple-game-to-kickstart-things-4h11</link>
      <guid>https://dev.to/ken_cameron111/simple-game-to-kickstart-things-4h11</guid>
      <description>&lt;p&gt;Since our professors are mandating us to use C# and PHP for our thesis, maybe a making simple game using those languages can help me review my understanding of the syntax. Need to review again... It's hard but kinda fun when it works. Will update you guys. Peace✌️!&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>php</category>
      <category>gamedev</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
