IoT and AWS - part 1

By Mateo Spak Jenbergsen
Published on 2023-03-07 (Last modified: 2023-09-16)

...

In this first part, I show how you can wire up an Adafruit-ina260 power sensor to an Arduino UNO. The purpose of using the power sensor, is to be able to measure current, voltage and power from a small solar panel. This particular example is specific to the power sensor, however, even though the wiring part is of course different if using other components, much of this article is still relevant.

I recommend to do some research about Arduino and the components you are going to use.

Parts used in this project

 

Tools used in this project

 

Soldering the solar panel

I'm using a 5V solar panel from All Powers. Here I've soldered the orange wire to the negative pole and the yellow wire to the positive pole.  

aws-iot-1

 

Wiring

In this section I try to illustrate how the wiring is done. The positive wire from the solar panel is connected to Vin+ and the negative wire through our LED light and to Vin- on the Adafruit power sensor. I've also connected the Arduino SCL to the power sensor SCL and the Arduino SDA to the power sensor SDA. Since this article series is not specifically aimed at solar panel monitoring, but more towards AWS and IOT, I will not go through how this power sensor works in detail. You can read more about it here.

 

aws-iot-2

 

Code

After wiring up our breadboard and Arduino we can start writing our code. For this article I will be using the standard Arduino IDE. If you don't have the IDE, this article shows how to download it. To start reading data from our Adafruit-ina260 power sensor we need to download the Adafruit_INA260 library from the Arduino IDE library manager. This can be found under Sketch -> Include library -> Manage libraries. Search for 'Adafruit INA260' and choose install. Now that we have correct library installed we can start coding. 

Create a file and insert the following:

#include <Adafruit_INA260.h>

Adafruit_INA260 ina260 = Adafruit_INA260();

void setup() {        
  Serial.begin(9600);
  // Wait until serial port is opened
  while (!Serial) { delay(10); }

  Serial.println("Adafruit INA260 Test");

  if (!ina260.begin()) {
    Serial.println("Couldn't find INA260 chip");
    while (1);
  }
  Serial.println("Found INA260 chip");
}

void loop() {
  Serial.print("Current: ");
  Serial.print(ina260.readCurrent());
  Serial.println(" mA");

  Serial.print("Bus Voltage: ");
  Serial.print(ina260.readBusVoltage());
  Serial.println(" mV");

  Serial.print("Power: ");
  Serial.print(ina260.readPower());
  Serial.println(" mW");

  Serial.println();
  delay(1000);
}

Note that this is just the library standard code but shows how we can monitor current, bus voltage and power from our Adafruit INA260 sensor. Now we can open our serial monitor on baud 9600 and monitor the output.

 

Conclusion

In this article we have looked at how we can monitor power produced from a solar panel with our Adafruit power sensor and Arduino UNO. In the next article, we'll look at how we can combine what we did in this article with a Raspberry PI to send the data collected from our solar panel to AWS IOT.




About the author



Mateo Spak Jenbergsen

Mateo is a Devops at Spak Consultants, with strong focus on AWS, Terraform and container technologies. He has a strong passion for pushing the limits when it comes to building software on cloud platforms.

Comments